buildRequest method
Implementation
@override
BlockCypherRequestDetails buildRequest(int requestID) {
final pathParams = BitcoinProviderUtils.extractParams(method.url);
if (pathParams.length != parameters.length) {
throw DartBitcoinPluginException(
'Invalid Path Parameters.',
details: {
'pathParams': parameters.join(","),
'expectedPathParametersLength': pathParams.length.toString(),
},
);
}
String params = method.url;
for (int i = 0; i < pathParams.length; i++) {
params = params.replaceFirst(pathParams[i], parameters[i]);
}
final queryParams = Map<String, String>.from(queryParameters.notNullValue);
if (queryParams.isNotEmpty) {
params =
Uri.parse(
params,
).replace(queryParameters: queryParams).normalizePath().toString();
}
return BlockCypherRequestDetails(
requestID: requestID,
method: method.url,
bodyBytes: requestMethod.isPost ? body : null,
path: params,
responseEncoding: ServiceReponseEncoding.fromType<RESPONSE>(),
headers: requestMethod.isPost ? ServiceConst.defaultPostHeaders : {},
requestMethod: requestMethod,
);
}