createConversion method
Future<Map>
createConversion(
- String token,
- String? buyAmount,
- String buyCurrency,
- String? conversionDate,
- String? quoteId,
- String reason,
- String requestId,
- String? sellAmount,
- String sellCurrency,
- bool termAgreement,
override
Implementation
@override
Future<Map> createConversion(
String token,
String? buyAmount,
String buyCurrency,
String? conversionDate,
String? quoteId,
String reason,
String requestId,
String? sellAmount,
String sellCurrency,
bool termAgreement) async {
final String baseUrl = await getBaseUrl;
var url = Uri.parse("$baseUrl/api/v1/conversions/create");
var bodyData = {
"buy_currency": buyCurrency,
"reason": reason,
"request_id": requestId,
"sell_currency": sellCurrency,
"term_agreement": termAgreement
};
if (buyAmount != null) {
bodyData.addAll({"buy_amount": buyAmount});
}
if (conversionDate != null) {
bodyData.addAll({"conversion_date": conversionDate});
}
if (quoteId != null) {
bodyData.addAll({"quote_id": quoteId});
}
if (sellAmount != null) {
bodyData.addAll({"sell_amount": sellAmount});
}
var jsonBody = jsonEncode(bodyData);
var response = await http.post(
url,
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer $token"
},
body: jsonBody,
);
var data = jsonDecode(response.body);
return data;
}