Skip to content

Commit cca44d6

Browse files
author
Sergey Khomushin
committed
add EmailJSResponseStatus modal
1 parent c239b5f commit cca44d6

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

.github/workflows/flutter_action.yml renamed to .github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,29 @@
33
# separate terms of service, privacy policy, and support
44
# documentation.
55

6-
name: Flutter Action
6+
name: CI
77

8+
# Controls when the workflow will run
89
on:
10+
# Triggers the workflow on push or pull request events but only for the master branch
911
push:
10-
branches: [ "main" ]
12+
branches: [main]
1113
pull_request:
12-
branches: [ "main" ]
14+
branches: [main]
1315

16+
# Allows you to run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
19+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1420
jobs:
21+
# This workflow contains a single job called "build"
1522
build:
23+
# The type of runner that the job will run on
1624
runs-on: ubuntu-latest
1725

26+
# Steps represent a sequence of tasks that will be executed as part of the job
1827
steps:
28+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
1929
- uses: actions/checkout@v3
2030
- uses: subosito/flutter-action@v2
2131

lib/src/api/send_json.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:http/http.dart' as http;
2+
import '../models/emailjs_response_status.dart';
23

3-
Future<String> sendJSON(http.Client client, Uri uri, String data) async {
4+
Future<EmailJSResponseStatus> sendJSON(http.Client client, Uri uri, String data) async {
45
try {
56
var response = await client.post(
67
uri,
@@ -11,9 +12,9 @@ Future<String> sendJSON(http.Client client, Uri uri, String data) async {
1112
);
1213

1314
if (response.statusCode == 200) {
14-
return response.body;
15+
return EmailJSResponseStatus(response.statusCode, response.body);
1516
} else {
16-
throw response.body;
17+
throw EmailJSResponseStatus(response.statusCode, response.body);
1718
}
1819
} finally {
1920
client.close();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class EmailJSResponseStatus {
2+
int status = 0;
3+
String text = 'Network Error';
4+
5+
EmailJSResponseStatus(int? status, String? text) {
6+
this.status = status ?? 0;
7+
this.text = text ?? 'Network Error';
8+
}
9+
}

0 commit comments

Comments
 (0)