Download the PHP package zaius/zaius-php-sdk without Composer
On this page you can find all versions of the php package zaius/zaius-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zaius/zaius-php-sdk
More information about zaius/zaius-php-sdk
Files in zaius/zaius-php-sdk
Package zaius-php-sdk
Short Description The Zaius SDK for PHP. Validated for use in zaius-magento-2, users in custom environments are encouraged to test and validate thoroughly (and note any issues via the GitHub issue tracker).
License MIT
Informations about the package zaius-php-sdk
Zaius SDK for PHP
Getting Started
The Zaius SDK provides a programmatic interface for the Zaius API as documented at https://developers.zaius.com/reference .
To get started, include the library in your project:
You can get an instance of the Zaius client using:
The API key can be obtained from your Zaius account at https://app.zaius.com/app#/api_management . Click on the "Private" tab and use the private API key.
Available methods
Customer management
Create/update a customer
The method takes in a single array with the customer object or an array of customer objects
Example:
Get a customer
This method takes in a filter array with the following possible keys:
- vuid
- customer_id
Note that you need to pass only one of the above. Also, the API supports only exact matches for each field.
Example:
Events
Post an event
Posts an event. The event array object method must have the following keys:
- type - the type of the event (i.e. product)
- action - the event's action (i.e. add_to_cart)
- identifiers - an array with the identifiers. Valid keys are vuid and email
- data - an array with the event-specific data. The full list of the supported values is available at https://developers.zaius.com/reference#upload-events
You can pass an array of events for bulk upload.
Example:
List management
Create a list
Creates a list with the given name.
Example:
Get all lists
Returns all lists.
Example:
Update a list
Updates a list's name. The method expects the following parameters:
- $listId - the ID of the list to change (get it with a getLists() call)
- $newName - the new name for the list
Example:
Subscription management
Get subscriptions
Gets subscriptions based on a filter. The lists of accepted filters is available at https://developers.zaius.com/reference#get-subscriptions-1 .
Example:
Update subscription
Updates a subscription. The subscription array can have three keys:
- list_id (optional) - the list for which to update the subscription
- email - the email to update the subscription for
- subscribed - true/false - whether to subscribe or unsubscribe the user
The method also supports passing an array of subscriptions for bulk updates.
Example:
Update channel opt-in
Updates a subscription. Parameters:
- optedIn - true/false
- email - email address
Example:
Exports
Export all objects
Exports all objects. Parameters:
- objects - array with objects type to export, i.e. array('orders','products'). Leave empty to export all object types
- format - one of csv, parquet. Defaults to csv
- delimiter - one of comma,tab, pipe. Defaults to comma.
Example:
Export filtered objects
Export objects given a filter.
Parameters:
- filter - an array with the filter as described at https://developers.zaius.com/v3/reference#export-filtering
- format - one of csv, parquet. Defaults to csv
- delimiter - one of comma,tab, pipe. Defaults to comma.
Example:
Get the export status
Gets the status of an export. Parameters:
- exportId - the export id
Example:
Schema API
Get all available objects
Returns an array with all available objects schemas.
Example:
Get object schema
Returns the schema for the specified object.
Parameters:
- objectType - a valid object type. Get all object types with the getObjects() method
Example:
Create a new object type
Creates a new object type. Parameters:
- object (unique) id
- object name
- alias
- field definition array
- relation definition array
Example:
Get an object's fields
Gets the fields for an object. Parameters:
- object id
Example:
Create a new field for an object
Creates a new field for an object. Parameters:
- object id
- field id
- field type
- field name
- field description
Example:
Get all object's relations
Gets all relations for an object. Parameters:
- object id
Example:
Posting objects
Post a product
This method also supports passing an array of products for bulk updates.
Post a customer
This method also supports passing an array of customers for bulk updates.
Post an order
This method also supports passing an array of orders for bulk updates.
Posting custom objects
Creates (or updates) an object. Parameters:
- object id
- array with the object data. Must include all required fields per the object's schema.
This method supports passing an array of objects for bulk updates.
Example:
Bulk upload objects to S3
The S3 client can be obtained from the Zaius Client:
To get the needed keys, check https://developers.zaius.com/v3/reference#amazon-s3
Events
Products
Customers
Orders
Supported object types
All Zaius methods expect arrays in a specific format. Besides the keys listed for each object, any other key/value pair is accepted and will be sent as a custom field, if it was defined via the Zaius dashboard/schema API
To see the full list of available fields, access https://app.zaius.com/app#/custom_fields after logging in into your Zaius account.
Customers
Key | Type | Other details |
---|---|---|
string | ||
gender | string | |
name | string | |
first_name | string | |
last_name | string | |
phone | string | |
timezone | string | The timezone of the user in the following format: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones |
street1 | string | |
street2 | string | |
city | string | |
state | string | |
zip | string | |
country | string | |
image_url | string | |
customer_id | string |
Example:
Events
Key | Type | Other details |
---|---|---|
type | string | |
action | string | |
identifiers.email | string | |
identifiers.vuid | string | |
data.ts | integer | Timestamp of the event in unix time (epoch time). Automatically set to now if not present. |
data.product_id | string | |
data.category | string | |
data.channel | string | |
data.ua | string | User agent |
data.ip | string | |
data.title | string | |
data.hostname | string | |
data.page | string | |
data.source | string | |
data.medium | string | |
data.campaign | string | |
data.content | string | |
data.keywords | string | |
data.language | string | |
data.character_set | string | |
data.days_since_last_visit | integer | |
data.landing | bool | |
data.referrer | string | |
data.search_term | string | |
data.filter_field | string | |
data.filter_value | string | |
data.sort_direction | string | |
data.sort_field | string |
Example:
Products
Key | Type | Other details |
---|---|---|
brand | string | |
category_id | integer | |
description | string | |
image_url | string | |
is_in_stock | bool | |
name | string | |
parent_product_id | integer | |
price | number | |
product_id | string | |
qty | integer | |
sku | string | |
special_price | number | |
special_price_from_date | timestamp | |
special_price_to_date | timestamp | |
upc | string |
Example:
Orders
Key | Type | Other details |
---|---|---|
bill_address | string | |
coupon_code | string | |
first_name | string | |
last_name | string | |
name | string | |
discount | number | |
string | ||
order_id | string | |
phone | string | |
ship_address | string | |
shipping | number | |
status | text | |
subtotal | number | |
tax | number | |
total | number | |
user_id | string | |
items.product_id | string | |
items.sku | string | |
items.quantity | integer | |
items.subtotal | number |
Example:
Generic API calls
While the SDK covers all specific operations, it is possible to initiate a general call to the API by using the call() method. Three parameters are expected:
- $parameters - an array of parameters. For get calls, they will be sent as url parameters. For post / put calls, they will be sent as post fields
- $method - a valid http method name, i.e. post or get
- $url - the full endpoint url
The method returns the raw API response. Note that most of the time, this will be a json encoded string.
The method throws a ZaiusException in case the response code is any other than 20x or 404. A 404 response code returns a null body and represents the fact that no entry was found for the provided query.
Example:
Batch processing
While the Zaius API is fast, it is possible to completely decouple it by using batch processing. We are making use of DJJob, https://github.com/seatgeek/djjob as a general queueing mechanism.
Setup
Initialize the mysql database:
Before making a call to push to the queue, you need to ensure that the mysql credentials were initialized:
Push events to the queue
All posting methods have a queue bool parameter that you can set to push to the queue instead of processing instantly:
The returned value from the post calls will be the mysql insert id of the pushed object.
You can later process the queue with:
All versions of zaius-php-sdk with dependencies
aws/aws-sdk-php Version ^3.85
ext-curl Version *
ext-json Version *
seatgeek/djjob Version ^1.0