setName method
Updates the name of the user.
Takes the new name of the user and their access token. Data is not used by the Rainmaker service; it's only for convenient storage of user data.
Implementation
Future<void> setName(String name, String accessToken) async {
final uri = _urlBase.getPath(_baseUserEndpoint);
final body = await JsonIsolate().encodeJson({
'name': name,
});
final resp = await put(
uri,
body: body,
headers: {
URLBase.authHeader: accessToken,
},
);
final bodyResp = await JsonIsolate().decodeJson(resp.body);
if (resp.statusCode != 200) {
throw bodyResp['description'];
}
}