send method

Future<Response> send({
  1. required AwsRequestType type,
  2. String? service,
  3. List<String> signedHeaders = const [],
  4. Map<String, String> headers = defaultHeaders,
  5. String jsonBody = '',
  6. String queryPath = '/',
  7. Map<String, String>? queryString,
  8. Duration? timeout,
})

Builds, signs, and mocks aws http requests.

type: request type GET, POST, PUT, etc

service: aws service you are sending request to

signedHeaders: a list of headers aws requires in the signature.

Default included signed headers are: content-type, host, x-amz-date

(You do not need to provide these in headers)

headers: any required headers. Any non-default headers included in the signedHeaders must be added here.

jsonBody: the body of the request, formatted as json

queryPath: the aws query path

queryString: the url query string as a Map

timeout: overrides constructor request timeout

Implementation

Future<Response> send({
  required AwsRequestType type,
  String? service,
  List<String> signedHeaders = const [],
  Map<String, String> headers = defaultHeaders,
  String jsonBody = '',
  String queryPath = '/',
  Map<String, String>? queryString,
  Duration? timeout,
}) async {
  // validate request
  final Map<String, dynamic> validation = validateRequest(
    service ?? this.service,
  );
  if (!validation['valid']) {
    throw AwsRequestException(
        message: 'AwsRequestException: ${validation['error']}',
        stackTrace: StackTrace.current);
  }
  return AwsHttpRequest.send(
    awsAccessKey: awsAccessKey,
    awsSecretKey: awsSecretKey,
    region: region,
    type: type,
    service: service ?? this.service!,
    signedHeaders: signedHeaders,
    headers: headers,
    jsonBody: jsonBody,
    canonicalUri: queryPath,
    canonicalQuery: queryString,
    timeout: timeout ?? this.timeout,
    mockRequest: true,
    mockFunction: mockFunction,
  );
}