Skip to content

Commit

Permalink
[Release 0.3.0]
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
=Zachary Merritt committed Jan 9, 2022
1 parent 8fd1108 commit cf522cb
Show file tree
Hide file tree
Showing 21 changed files with 1,450 additions and 394 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
run: dart pub get

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

# Consider passing '--fatal-infos' for slightly stricter analysis.
- name: Analyze project source
Expand All @@ -36,3 +36,12 @@ jobs:
# want to change this to 'flutter test'.
- name: Run tests
run: dart test

- name: Generate coverage test
run: source scripts/coverage_helper.sh aws_request

- name: Collect coverage
run: dart test --coverage .
- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ build/
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
*.json
test/coverage_helper_test.dart
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Zachary Merritt <[email protected]>
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [0.3.0] - 2022/01/08

* 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

## [0.2.1] - 2022/01/08

* Fixed issue with rejected headers on web
Expand Down
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
<a href="https://pub.dev/packages/aws_request">
<img alt="Pub Package" src="https://img.shields.io/pub/v/aws_request.svg?logo=dart&logoColor=00b9fc">
</a>
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/commits/main">
<img alt="Last Commit" src="https://img.shields.io/github/last-commit/Zsmerritt/Flutter_AWS_Request?logo=git&logoColor=white">
</a>
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/pulls">
<img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/Zsmerritt/Flutter_AWS_Request?logo=github&logoColor=white">
</a>
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/issues">
<img alt="Open Issues" src="https://img.shields.io/github/issues/Zsmerritt/Flutter_AWS_Request?logo=github&logoColor=white">
</a>
Expand All @@ -21,6 +15,9 @@
<a href="https://github.com/Zsmerritt/Flutter_AWS_Request/blob/main/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/Zsmerritt/Flutter_AWS_Request?logo=open-source-initiative&logoColor=blue">
</a>
<a href="https://codecov.io/gh/Zsmerritt/Flutter_AWS_Request">
<img alt="Coverage" src="https://codecov.io/gh/Zsmerritt/Flutter_AWS_Request/branch/main/graph/badge.svg?token=RY2QXJVTTW"/>
</a>
</p>

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

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

## Examples
## Example 1

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

~~~dart
import 'package:aws_request/aws_request.dart';
import 'dart:io';
import 'package:http/http.dart';
void sendCloudWatchLog(String logString) async {
void awsRequestFunction(String logString) async {
AwsRequest request = new AwsRequest('awsAccessKey', 'awsSecretKey', 'region');
String body = """
{"logEvents":
[{
"timestamp":${DateTime
.now()
.toUtc()
.millisecondsSinceEpoch},
"message":"$logString"
}],
"logGroupName":"ExampleLogGroupName",
"logStreamName":"ExampleLogStreamName"
}""";
HttpClientResponse result = await request.send(
Response result = await request.send(
AwsRequestType.POST,
jsonBody: body,
jsonBody: "{'jsonKey': 'jsonValue'}",
target: 'Logs_20140328.PutLogEvents',
service: 'logs',
queryString: {'X-Amz-Expires': '10'},
headers: {'X-Amz-Security-Token': 'XXXXXXXXXXXX'},
);
}
~~~

## Example 2

There is also a static method if you find that more useful:

~~~dart
import 'package:aws_request/aws_request.dart';
import 'package:http/http.dart';
void awsRequestFunction(String logString) async {
Response result = await AwsRequest.staticSend(
awsAccessKey: 'awsAccessKey',
awsSecretKey: 'awsSecretKey',
region: 'region',
type: AwsRequestType.POST,
jsonBody: "{'jsonKey': 'jsonValue'}",
target: 'Logs_20140328.PutLogEvents',
service: 'logs',
queryString: {'X-Amz-Expires': '10'},
headers: {'X-Amz-Security-Token': 'XXXXXXXXXXXX'},
);
}
~~~
Expand Down
20 changes: 7 additions & 13 deletions example/aws_request.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import 'package:aws_request/aws_request.dart';
import 'package:http/http.dart';

void sendCloudWatchLog(String logString) async {
void awsRequestFunction(String logString) async {
AwsRequest request = new AwsRequest('awsAccessKey', 'awsSecretKey', 'region');
String body = """
{"logEvents":
[{
"timestamp":${DateTime.now().toUtc().millisecondsSinceEpoch},
"message":"$logString"
}],
"logGroupName":"ExampleLogGroupName",
"logStreamName":"ExampleLogStreamName"
}""";
await request.send(
Response result = await request.send(
AwsRequestType.POST,
jsonBody: body,
target: 'Logs_XXXXXXXX.PutLogEvents',
jsonBody: "{'jsonKey': 'jsonValue'}",
target: 'Logs_20140328.PutLogEvents',
service: 'logs',
queryString: {'X-Amz-Expires': '10'},
headers: {'X-Amz-Security-Token': 'XXXXXXXXXXXX'},
);
}
16 changes: 15 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages:
name: aws_request
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
version: "0.3.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -74,6 +74,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
intl:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ dependencies:
flutter:
sdk: flutter

aws_request: 0.2.1
aws_request: 0.3.0
http: ^0.13.0

dev_dependencies:
flutter_test:
Expand Down
Loading

0 comments on commit cf522cb

Please sign in to comment.