Skip to content

Commit cf522cb

Browse files
author
=Zachary Merritt
committed
[Release 0.3.0]
* Migrated from `universal_io` to `http` * Refactored project into discrete testable modules * Added unit tests for each piece * Added MockAwsRequest to mock requests for easier testing * Added AUTHORS file * Added static version of primary method * Updated documentation to illustrate new static call method * Added coverage * Fixed bug with allowing non String values in queryString
1 parent 8fd1108 commit cf522cb

21 files changed

Lines changed: 1450 additions & 394 deletions

.github/workflows/dart.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
run: dart pub get
2525

2626
# Uncomment this step to verify the use of 'dart format' on each commit.
27-
# - name: Verify formatting
28-
# run: dart format --output=none --set-exit-if-changed .
27+
- name: Verify formatting
28+
run: dart format --output=none --set-exit-if-changed .
2929

3030
# Consider passing '--fatal-infos' for slightly stricter analysis.
3131
- name: Analyze project source
@@ -36,3 +36,12 @@ jobs:
3636
# want to change this to 'flutter test'.
3737
- name: Run tests
3838
run: dart test
39+
40+
- name: Generate coverage test
41+
run: source scripts/coverage_helper.sh aws_request
42+
43+
- name: Collect coverage
44+
run: dart test --coverage .
45+
- uses: codecov/codecov-action@v1.0.2
46+
with:
47+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,5 @@ build/
7272
!**/ios/**/default.mode2v3
7373
!**/ios/**/default.pbxuser
7474
!**/ios/**/default.perspectivev3
75+
*.json
76+
test/coverage_helper_test.dart

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Zachary Merritt <zsmerritt@gmail.com>

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [0.3.0] - 2022/01/08
2+
3+
* Migrated from `universal_io` to `http`
4+
* Refactored project into discrete testable modules
5+
* Added unit tests for each piece
6+
* Added MockAwsRequest to mock requests for easier testing
7+
* Added AUTHORS file
8+
* Added static version of primary method
9+
* Updated documentation to illustrate new static call method
10+
* Added coverage
11+
* Fixed bug with allowing non String values in queryString
12+
113
## [0.2.1] - 2022/01/08
214

315
* Fixed issue with rejected headers on web

README.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
<a href="https://pub.dev/packages/aws_request">
77
<img alt="Pub Package" src="https://img.shields.io/pub/v/aws_request.svg?logo=dart&logoColor=00b9fc">
88
</a>
9-
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/commits/main">
10-
<img alt="Last Commit" src="https://img.shields.io/github/last-commit/Zsmerritt/Flutter_AWS_Request?logo=git&logoColor=white">
11-
</a>
12-
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/pulls">
13-
<img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/Zsmerritt/Flutter_AWS_Request?logo=github&logoColor=white">
14-
</a>
159
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/issues">
1610
<img alt="Open Issues" src="https://img.shields.io/github/issues/Zsmerritt/Flutter_AWS_Request?logo=github&logoColor=white">
1711
</a>
@@ -21,6 +15,9 @@
2115
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/blob/main/LICENSE">
2216
<img alt="License" src="https://img.shields.io/github/license/Zsmerritt/Flutter_AWS_Request?logo=open-source-initiative&logoColor=blue">
2317
</a>
18+
<a href="https://codecov.io/gh/Zsmerritt/Flutter_AWS_Request">
19+
<img alt="Coverage" src="https://codecov.io/gh/Zsmerritt/Flutter_AWS_Request/branch/main/graph/badge.svg?token=RY2QXJVTTW"/>
20+
</a>
2421
</p>
2522

2623
<p align="center">
@@ -79,38 +76,52 @@ headers: any required headers. Any non-default headers included in the signedHea
7976
must be added here.
8077
jsonBody: the body of the request, formatted as json
8178
queryPath: the aws query path
82-
queryString: the aws query string, formatted like ('abc=123&def=456'). Must be url encoded
79+
queryString: the url query string as a Map
8380
~~~
8481

8582
Supported HTTP methods are get, post, delete, patch, put.
8683

87-
## Examples
84+
## Example 1
8885

8986
Here's an example of using aws_request to send a CloudWatch PutLogEvent request:
9087

9188
~~~dart
9289
import 'package:aws_request/aws_request.dart';
93-
import 'dart:io';
90+
import 'package:http/http.dart';
9491
95-
void sendCloudWatchLog(String logString) async {
92+
void awsRequestFunction(String logString) async {
9693
AwsRequest request = new AwsRequest('awsAccessKey', 'awsSecretKey', 'region');
97-
String body = """
98-
{"logEvents":
99-
[{
100-
"timestamp":${DateTime
101-
.now()
102-
.toUtc()
103-
.millisecondsSinceEpoch},
104-
"message":"$logString"
105-
}],
106-
"logGroupName":"ExampleLogGroupName",
107-
"logStreamName":"ExampleLogStreamName"
108-
}""";
109-
HttpClientResponse result = await request.send(
94+
Response result = await request.send(
11095
AwsRequestType.POST,
111-
jsonBody: body,
96+
jsonBody: "{'jsonKey': 'jsonValue'}",
97+
target: 'Logs_20140328.PutLogEvents',
98+
service: 'logs',
99+
queryString: {'X-Amz-Expires': '10'},
100+
headers: {'X-Amz-Security-Token': 'XXXXXXXXXXXX'},
101+
);
102+
}
103+
~~~
104+
105+
## Example 2
106+
107+
There is also a static method if you find that more useful:
108+
109+
~~~dart
110+
import 'package:aws_request/aws_request.dart';
111+
import 'package:http/http.dart';
112+
113+
void awsRequestFunction(String logString) async {
114+
115+
Response result = await AwsRequest.staticSend(
116+
awsAccessKey: 'awsAccessKey',
117+
awsSecretKey: 'awsSecretKey',
118+
region: 'region',
119+
type: AwsRequestType.POST,
120+
jsonBody: "{'jsonKey': 'jsonValue'}",
112121
target: 'Logs_20140328.PutLogEvents',
113122
service: 'logs',
123+
queryString: {'X-Amz-Expires': '10'},
124+
headers: {'X-Amz-Security-Token': 'XXXXXXXXXXXX'},
114125
);
115126
}
116127
~~~

example/aws_request.dart

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import 'package:aws_request/aws_request.dart';
2+
import 'package:http/http.dart';
23

3-
void sendCloudWatchLog(String logString) async {
4+
void awsRequestFunction(String logString) async {
45
AwsRequest request = new AwsRequest('awsAccessKey', 'awsSecretKey', 'region');
5-
String body = """
6-
{"logEvents":
7-
[{
8-
"timestamp":${DateTime.now().toUtc().millisecondsSinceEpoch},
9-
"message":"$logString"
10-
}],
11-
"logGroupName":"ExampleLogGroupName",
12-
"logStreamName":"ExampleLogStreamName"
13-
}""";
14-
await request.send(
6+
Response result = await request.send(
157
AwsRequestType.POST,
16-
jsonBody: body,
17-
target: 'Logs_XXXXXXXX.PutLogEvents',
8+
jsonBody: "{'jsonKey': 'jsonValue'}",
9+
target: 'Logs_20140328.PutLogEvents',
1810
service: 'logs',
11+
queryString: {'X-Amz-Expires': '10'},
12+
headers: {'X-Amz-Security-Token': 'XXXXXXXXXXXX'},
1913
);
2014
}

example/pubspec.lock

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ packages:
1414
name: aws_request
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "0.2.1"
17+
version: "0.3.0"
1818
boolean_selector:
1919
dependency: transitive
2020
description:
@@ -74,6 +74,20 @@ packages:
7474
description: flutter
7575
source: sdk
7676
version: "0.0.0"
77+
http:
78+
dependency: "direct main"
79+
description:
80+
name: http
81+
url: "https://pub.dartlang.org"
82+
source: hosted
83+
version: "0.13.4"
84+
http_parser:
85+
dependency: transitive
86+
description:
87+
name: http_parser
88+
url: "https://pub.dartlang.org"
89+
source: hosted
90+
version: "4.0.0"
7791
intl:
7892
dependency: transitive
7993
description:

example/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ dependencies:
99
flutter:
1010
sdk: flutter
1111

12-
aws_request: 0.2.1
12+
aws_request: 0.3.0
13+
http: ^0.13.0
1314

1415
dev_dependencies:
1516
flutter_test:

0 commit comments

Comments
 (0)