storeMobileMetadata function
Implementation
Future<MetadataResponse> storeMobileMetadata(
String chicoToken,
client,
Map<String, dynamic> userMetadata,
) async {
final response = await http.post(
Uri.parse("$API/store-mobile-metadata"),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, dynamic>{
'chico_token': chicoToken,
'client': client,
'metadata': userMetadata,
}),
);
if (response.statusCode == 200) {
// If the server did return a 200 OK response,
// then parse the JSON.
return MetadataResponse.fromJson(jsonDecode(response.body));
} else {
// If the server did not return a 200 OK response,
// then throw an exception.
return MetadataResponse.fromJson(<String, dynamic>{});
}
}