|
6 | 6 | <a href="https://pub.dev/packages/aws_request"> |
7 | 7 | <img alt="Pub Package" src="https://img.shields.io/pub/v/aws_request.svg?logo=dart&logoColor=00b9fc"> |
8 | 8 | </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> |
15 | 9 | <a href="https://github.com/Zsmerritt/Flutter_AWS_Request/issues"> |
16 | 10 | <img alt="Open Issues" src="https://img.shields.io/github/issues/Zsmerritt/Flutter_AWS_Request?logo=github&logoColor=white"> |
17 | 11 | </a> |
|
21 | 15 | <a href="https://github.com/Zsmerritt/Flutter_AWS_Request/blob/main/LICENSE"> |
22 | 16 | <img alt="License" src="https://img.shields.io/github/license/Zsmerritt/Flutter_AWS_Request?logo=open-source-initiative&logoColor=blue"> |
23 | 17 | </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> |
24 | 21 | </p> |
25 | 22 |
|
26 | 23 | <p align="center"> |
@@ -79,38 +76,52 @@ headers: any required headers. Any non-default headers included in the signedHea |
79 | 76 | must be added here. |
80 | 77 | jsonBody: the body of the request, formatted as json |
81 | 78 | 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 |
83 | 80 | ~~~ |
84 | 81 |
|
85 | 82 | Supported HTTP methods are get, post, delete, patch, put. |
86 | 83 |
|
87 | | -## Examples |
| 84 | +## Example 1 |
88 | 85 |
|
89 | 86 | Here's an example of using aws_request to send a CloudWatch PutLogEvent request: |
90 | 87 |
|
91 | 88 | ~~~dart |
92 | 89 | import 'package:aws_request/aws_request.dart'; |
93 | | -import 'dart:io'; |
| 90 | +import 'package:http/http.dart'; |
94 | 91 |
|
95 | | -void sendCloudWatchLog(String logString) async { |
| 92 | +void awsRequestFunction(String logString) async { |
96 | 93 | 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( |
110 | 95 | 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'}", |
112 | 121 | target: 'Logs_20140328.PutLogEvents', |
113 | 122 | service: 'logs', |
| 123 | + queryString: {'X-Amz-Expires': '10'}, |
| 124 | + headers: {'X-Amz-Security-Token': 'XXXXXXXXXXXX'}, |
114 | 125 | ); |
115 | 126 | } |
116 | 127 | ~~~ |
|
0 commit comments