Update the Specified Customer

You can use this request to update a specific customer's properties. Use the customer's ID to specify which customer to update, and submit the properties to update in a table.


The Method

API Method
RESTPUThttp://[Your URL]/api/2.0/customers/$id
XML-RPCCallUpdateCustomer
Your URL is the address of your Everlytic install.

Your method must be structured as follows:

UpdateCustomer(integer $id, \struct | array $properties) : int

Parameters

Required Parameters

You must specify the ID of the customer you want to update.

PropertyTypeDescriptionRequired
$idintegerThe ID of the customer you need to update.yes
$properties\structarrayThe properties of the customer which need to be updated. Required properties are:
hash
name
email
(See Properties table below for more details.)
yes

Properties

You can update the following properties using this request:

PropertyTypeDescriptionDefaultRead Only
hashstringHashemptyno
namestringNameemptyno
statusstringStatus
Possible values:
on
off
suspended
deleted
emptyno
emailstringEmail addressemptyno
email_package_idintegerPackage identifieremptyno
email_quotaintegerPrepaid email quotaemptyno
sms_quotaintegerPrepaid SMS quotaemptyno
transactions_package_idintegerPackage identifieremptyno
transactions_quotaintegerTransactions prepaid quotaemptyno
deletedstringCustomer deleted
Possible values:
yes
no
emptyno
addressstringAddressemptyno
state_provincesstringState or provinceemptyno
postal_codestringPostal or Zip codeemptyno
telephonestringTelephone numberemptyno
website_urlstringWebsite URLemptyno
countrystringTwo-character country code.emptyno
industrystringCustomer industry. Possible values:
Personal Use,
Agriculture & Environmental,
Automotive,
Business & Consulting Services,
E-commerce,
Education & Training,
Financial Institutions,
Governmental Organisations,
Hospitality, Travel & Tourism,
Industry, Trade & Manufacture,
Lifestyle, Arts & Entertainment,
Logistic Services,
Publishing & Media,
Agencies & Marketing,
Medical & Healthcare,
Non Governmental Organisations,
Property & Real Estate,
Retail & Wholesale,
Technology & Science.
emptyno
unique_idstringUnique customer identifier.emptyno

Responses

TypeDescription
integerThe ID of the updated customer.

Code Samples

PHP (using the REST API)

Tutorial

The rest of this document describes the example above, step-by-step.

In our Getting Started section we covered the four important components of an API request; URL, method, headers, and body.

RequestStructure

et's analyse the code sample above to determine where each line fits into this outline.

1. JSON

We use JSON to enclose the variables at the top of the API request (above the URL section).

$json = '

{

"email":"customer@email.com"

}

';

2. Load the Everlytic API

The following line of code tells the server which API URL to access for the request:

$url = '(Your URL)/api/2.0/customers/:customer_id;

Your URL is the URL of your Everlytic installation.

3. Method

In this line of code, you tell the API which REST function to use:

$method = 'PUT';

4. cURL

cURL is a tool for sending and receiving files from a web server. This line of code initialises the cURL session.

$cSession = curl_init();

5. Initiate the Headers

This section of the code opens the headers section and passes the authentication (including your API key).

$headers = array();

$auth = base64_encode($username . ':' . $apikey);

$headers[] = 'Authorization: Basic ' . $auth;

6. Set various cURL options for the session

These lines of code tell the server that we're using cURL to transfer data.

curl_setopt($cSession, CURLOPT_URL, $url);

curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);

curl_setopt($cSession, CURLOPT_HEADER, false);

curl_setopt($cSession, CURLOPT_CUSTOMREQUEST,

strtoupper($method));

curl_setopt($cSession, CURLOPT_POSTFIELDS, $json);

7. Tell the server to read the variables from the JSON string

$headers[] = 'Content-Type: application/json';

curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);

8. Output the API response

$result = curl_exec($cSession);

9. Close the cURL session

curl_close($cSession);
Translate »