addNodeMapping method

Future<String> addNodeMapping(
  1. String nodeId,
  2. String secretKey
)

Adds a user node mapping and returns the request id.

Will throw an exception when there is a failure containing a description of the failure.

Implementation

Future<String> addNodeMapping(String nodeId, String secretKey) async {
  final uri = _urlBase.getPath(_nodeMapping);

  final body = await JsonIsolate().encodeJson({
    'node_id': nodeId,
    'secret_key': secretKey,
    'operation': 'add',
  });

  final resp = await put(
    uri,
    body: body,
    headers: {
      URLBase.authHeader: accessToken,
    },
  );
  final Map<String, dynamic> bodyResp =
      await JsonIsolate().decodeJson(resp.body);
  if (resp.statusCode != 200) {
    throw bodyResp['description'];
  }

  return bodyResp['request_id'];
}