storeMobileMetadata function

Future<MetadataResponse> storeMobileMetadata(
  1. String chicoToken,
  2. dynamic client,
  3. Map<String, dynamic> userMetadata
)

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>{});
  }
}