Constructor
new VivochaCustomer(data)
Parameters:
Name | Type | Description |
---|---|---|
data |
CustomerData |
Methods
id() → {string}
Return the customer id.
Returns:
VivochaCustomer id.
- Type
- string
update(data, callback)
Updates the VivochaCustomer data in the Vivocha servers. The CustomerData object passed as first param will override the current one. To save the current data you should call the method VivochaCustomer.save, that calls automatically this method saving only the changed data.
Parameters:
Name | Type | Description |
---|---|---|
data |
CustomerData | |
callback |
GenericCallback | Called when the customer is updated. It returns the VivochaCustomer updated. |
save(callback)
Saves the current customer to the Vivocha server.
Parameters:
Name | Type | Description |
---|---|---|
callback |
GenericCallback | Called when the customer is updated. It returns the VivochaCustomer updated. |
(static) search(query, callback)
Search for a list of customers in the Vivocha Database that match the specified criteria. The callback function will return an array of VivochaCustomer instances for each customer that matches one of the specified criteria.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query |
object | The search criteria. Properties
|
||||||||||||||||
callback |
GenericCallback | Called when the search is terminated and return an array of VivochaCustomer instances. |
(static) get(cid, callback)
Search for a customer using the customer id specified in the ContactData cust_id property.
Parameters:
Name | Type | Description |
---|---|---|
cid |
string | The customer id. |
callback |
GenericCallback | Called when the search is terminated and return the VivochaCustomer instance for the specified customer id. |
(static) merge(cid1, cid2, callback)
Merges the data of the same customer contained in two different CustomerData objects. It could happen that Vivocha is not able to detect that two different contacts have been generated by the same customer. This allows you to instruct Vivocha and merge the CustomerData objects in a unique object.
Parameters:
Name | Type | Description |
---|---|---|
cid1 |
string | The first customer id. |
cid2 |
string | The second customer id. |
callback |
GenericCallback | Called when the merge has been saved in the database, it returns the VivochaCustomer object obtained from the merge. |
(static) update(cid, callback)
Updates the VivochaCustomer data in the Vivocha servers. The CustomerData object passed as second param will override the current one.
Parameters:
Name | Type | Description |
---|---|---|
cid |
CustomerData | |
callback |
GenericCallback | Called when the customer is updated. It returns the VivochaCustomer updated. |
(static) getHistory(cid, callback)
Retrieve the CustomerHistory from Vivocha.
Parameters:
Name | Type | Description |
---|---|---|
cid |
string | The customer id. |
callback |
GenericCallback | Called when the customer history has been retrieved from the Vivocha Server. It returns a CustomerHistory object. |