post static method

Future post(
  1. String uri,
  2. String contract
)

Make a POST 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> post(String uri, String contract) {
  final mdscompleter = Completer<dynamic>();

  MdsImpl().post(uri, contract, (data, status) {
    final content = data.isEmpty ? {} : jsonDecode(data);
    debugPrint(" content: $content");
    mdscompleter.complete(content?["Content"]);
  }, (data, status) {
    mdscompleter.completeError(MdsError(status, data));
  });
  return mdscompleter.future;
}