put static method

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

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

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