Adding a Customer
To add a customer to the system, you need to create
a CreateCustomerRequest object and pass it
to the Customers.CreateCustomerAsync method on the API client.
var request = new CreateCustomerRequest
{
Address = new CustomerAddress
{
HouseNameNumber = "1",
Street = "Test Street",
Locality = "Test Locality",
City = "Test City",
County = "Test County",
Postcode = "TE1 1ST",
Country = "GB"
},
Email = "test@example.com",
Title = "Mr",
FirstName = "Test",
LastName = "User",
Mobile = "01234567890"
};
var response = await client.Customers.CreateCustomerAsync(request);
In the above example, we are creating a new customer with the following details:
- Title: Mr
- First Name: Test
- Last Name: User
- Email: test@example.com
- Mobile: 01234567890
- Address:
- House Name/Number: 1
- Street: Test Street
- Locality: Test Locality
- City: Test City
- County: Test County
- Postcode: TE1 1ST
- Country: GB
The response object will contain the following properties:
IsSuccess:trueif the customer was created successfully,falseotherwise.CustomerId: The ID of the customer that was created.ErrorResponse: AnErrorResponseobject containing details of any errors that occurred during the operation.
Validation
Request
| Name | Type | Required | Max Length | Other Rules |
|---|---|---|---|---|
| string | Yes | 255 | ||
| Mobile | string | No | 100 | |
| Title | string | No | - | |
| FirstName | string | Yes | 100 | |
| LastName | string | Yes | 100 | |
| Address | CustomerAddress | Yes | - | Validated by Address rules as outlined below |
Address
| Name | Type | Required | Max Length | Other Rules |
|---|---|---|---|---|
| HouseNameNumber | string | Yes | 200 | |
| Street | string | Yes | 200 | |
| Locality | string | No | 50 | |
| City | string | Yes | 50 | |
| County | string | Yes | 50 | |
| Postcode | string | Yes | 10 | |
| Country | string | Yes | 2 | Length: 2, Format: ISO 3166-1 alpha-2 |