composer require almalio/api-php$api = new Almalio('API_KEY');
$result = $api->addContact('SITE_KEY', [
'order_number' => '12345',
'order_total' => 123.45,
'order_currency' => 'EUR',
'order_delivery_type' => 1,
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'phone' => '+421905000000',
'street' => 'Main Street 123',
'city' => 'New York',
'postcode' => '12345',
'country_code' => 'SK',
]);
// Check if the request was successful, otherwise check the error message, validate data (see rules lower) and try again__construct(string $apiKey, string $apiUrl = 'https://almalio.com/api/v1')
Create new instance of Almalio API wrapper.
string $apiKey- API keystring $apiUrl- API URL
Add contact to the Almalio system.
string $siteKey- Site keyarray $data- Contact dataorder_number- Order number (required|string|between:1,255)order_total- Order total (required|numeric|min:0)order_currency- Order currency code (required|string|size:3) - ISO 4217, e.g. EURorder_delivery_type- Order delivery type (required|integer|in:1,2) - ENUM, see belowfirstname- First name (required|string|between:1,255|regex:/^[\p{L} ]+$/u)lastname- Last name (required|string|between:1,255|regex:/^[\p{L} ]+$/u)email- Email (required|email|between:1,255)phone- Phone (required|string|between:1,255)street- Street (required|string|between:1,255|regex:/^(?=.*\d)(?=.*[a-zA-Z].*[a-zA-Z]).+$/)city- City (required|string|between:1,255|regex:/^[\p{L} ]+$/u)postcode- Postcode (required|string|between:1,255)country_code- Country code (required|string|size:2) - ISO 3166-1 alpha-2, e.g. SKtesting- Testing mode (optional|boolean) - do not send on production, it is only used to validate the request
1- Delivery to the address2- Personal pickup
Status code: 400
{
"message": "Validation failed",
"error": [
"The street field format is invalid.",
"The postcode field is required."
]
}Status code: 200
{
"message": "Contact added to queue successfully",
"success": true
}Status code: 200
{
"message": "Contact already imported",
"success": false
}Status code: 200
{
"message": "Test successful",
"success": true,
"data": {
"order_number": "12345",
"order_total": 123.45,
"order_currency": "EUR",
"order_delivery_type": 1,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"phone": "+421905000000",
"street": "Main Street 123",
"city": "New York",
"postcode": "12345",
"country_code": "SK"
}
}