saveClient method

Future<Response> saveClient({
  1. dynamic accessToken,
  2. dynamic createdById,
  3. dynamic clientId,
  4. dynamic name,
  5. List<ClientAttribute>? attribute,
})

Implementation

Future<Response> saveClient(
    {accessToken,
    createdById,
    clientId,
    name,
    List<ClientAttribute>? attribute}) async {
  Client client = Client(
      createdById: createdById,
      clientId: clientId,
      name: name,
      attribute: attribute ?? []);
  String body = jsonEncode(client);

  String api = 'save_client';
  Map<String, String> headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer $accessToken'
  };

  var response =
      await networking.postData(api: api, body: body, headers: headers);

  if (response.isSuccess) {
    return Response(true, message: '', data: response.data);
  } else if (response.message.contains('No records')) {
    return Response(false, message: 'No records');
  }

  return Response(false, message: response.message);
}