create_customer method

dynamic create_customer({
  1. String firstName = '',
  2. String lastName = '',
  3. String phoneNumber = '',
  4. required String email,
  5. required String username,
  6. required String password,
  7. String address1 = '',
  8. String address2 = '',
  9. String city = '',
  10. String state = '',
  11. String postcode = '',
  12. String country = '',
})

Implementation

create_customer({
  String firstName = '',
  String lastName = '',
  String phoneNumber = '',
  required String email,
  required String username,
  required String password,
  String address1 = '',
  String address2 = '',
  String city = '',
  String state = '',
  String postcode = '',
  String country = '',
}) async {
  var customerData = {
    'username': username,
    'password': password,
    'email': email,
    'first_name': firstName,
    'last_name': lastName,
    'billing': {
      'address_1': address1,
      'address_2': address2,
      'city': city,
      'state': state,
      'postcode': postcode,
      'country': country,
    },
    'shipping': {
      'address_1': address1,
      'address_2': address2,
      'city': city,
      'state': state,
      'postcode': postcode,
      'country': country,
    },
  };
  Response res;
  var encodedData_customerData = json.encode(customerData);

  res = await ApiServices().postRequest(
      body: encodedData_customerData,
      request: 'customers',
      baseUrl: baseUrl,
      consumerKey: consumerKey,
      consumerSecret: consumerSecret);

  var decoded_data = json.decode(res.body);
  CustomerModel parsedData = CustomerModel.fromJson(decoded_data);
  return parsedData;
}