get static method
Make an async GET request for a resource. uri must include "suunto://" prefix and device serial if needed. contract must be a json string. Returns a Future that completes with the response data in json format.
Implementation
static Future<dynamic> get(String uri, String contract) {
final mdscompleter = Completer<dynamic>();
MdsImpl().get(uri, contract, (data, status) {
debugPrint("MdsAsync.get result: $status, $data");
var content = data.isEmpty ? {} : jsonDecode(data);
// Handle case where content is not in "Content" key (MDS Logbook proxy service)
content = content["Content"] ?? content;
mdscompleter.complete(content);
}, (data, status) {
debugPrint("MdsAsync.get error: $status, $data");
mdscompleter.completeError(MdsError(status, data));
});
return mdscompleter.future;
}