update api call

This commit is contained in:
sneurlax 2023-01-12 14:38:03 -06:00
parent eaaed8a638
commit 8e9150d7fe

View file

@ -141,23 +141,28 @@ class SimplexAPI {
dynamic /*Future<BuyResponse<List<Fiat>>>*/ getSupported() async { dynamic /*Future<BuyResponse<List<Fiat>>>*/ getSupported() async {
// example for quote courtesy of @danrmiller // example for quote courtesy of @danrmiller
// curl -H "Content-Type: application/json" -d '{"digital_currency": "BTC", "fiat_currency": "USD", "requested_currency": "USD", "requested_amount": 100}' http://sandbox-api.stackwallet.com/quote= // curl -H "Content-Type: application/json" -d '{"digital_currency": "BTC", "fiat_currency": "USD", "requested_currency": "USD", "requested_amount": 100}' http://sandbox-api.stackwallet.com/quote
final uri = _buildUri("/quote", {}); // official docs reference eg
// curl --request GET \ // curl --request GET \
// --url https://sandbox.test-simplexcc.com/v2/supported_crypto_currencies \ // --url https://sandbox.test-simplexcc.com/v2/supported_crypto_currencies \
// --header 'accept: application/json' // --header 'accept: application/json'
try { try {
final body = { Map<String, String> headers = {
"digital_currency": "BTC", 'Content-Type': 'application/json',
"fiat_currency": "USD",
"requested_currency": "USD",
"requested_amount": 100
}; };
final jsonArray = await _makePostRequest(uri, body); String data =
'{"digital_currency": "BTC", "fiat_currency": "USD", "requested_currency": "USD", "requested_amount": 100}';
Uri url = Uri.parse('http://sandbox-api.stackwallet.com/quote');
print(jsonArray); var res = await http.post(url, headers: headers, body: data);
if (res.statusCode != 200) {
throw Exception(
'getAvailableCurrencies exception: statusCode= ${res.statusCode}');
}
print(res.body);
return null; return null;
// return await compute(_parseAvailableCurrenciesJson, jsonArray as List); // return await compute(_parseAvailableCurrenciesJson, jsonArray as List);