mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
update api call
This commit is contained in:
parent
eaaed8a638
commit
8e9150d7fe
1 changed files with 15 additions and 10 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue