Open2b versione 7.5

contacts

contacts.find

Returns the contacts that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.contacts.find', request, function(response) { … });
HTTP POST
/api/v10/commerce.contacts.find
{
  "conditions" : { // returns the contacts of this …
    "customer" : 37091, // … customer (id) - int(1…)
    "after" : 59068 // … with identifier after this value - int(0…)
  },
  "fields" : [ "id", "customer", … ], // fields to return - string
  "order" : [ "id" ], // sort order of returned contacts, can contain "id", "-id", "customer", "-customer", "name", "-name",
                      // "phone", "-phone", "email", "-email", "note" and "-note" - string
  "limit" : 10, // maximum number of contacts to return - int(1…)
  "first": 0 // index of the first contact to return - int(0…)
}

Response

{
  "status" : "ok",
  "contacts" : [ {
    "id" : 59068, // identifier - int(1…)
    "customer" : 37091, // customer (id) - int(1…)
    "name" : "John Smith", // name - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address - string(3…120)
    "note" : "" // note - string(0…255)
  }, … ]
}

contacts.get

Returns a contact given its identifier.

Request

Admin SDK
Admin.api('commerce.contacts.get', request, function(response) { … });
HTTP POST
/api/v10/commerce.contacts.get
{
  "id" : 59068, // identifier (required) - int(1…)
  "fields" : [ "id", "customer", … ] // fields to return - string
}

Response

{
  "status" : "ok",
  "contact" : { // (can be null)
    "id" : 59068, // identifier - int(1…)
    "customer" : 37091, // customer (id) - int(1…)
    "name" : "John Smith", // name - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address - string(3…120)
    "note" : "" // note - string(0…255)
  }
}

contacts.count

Number of contacts that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.contacts.count', request, function(response) { … });
HTTP POST
/api/v10/commerce.contacts.count
{
  "conditions" : { // counts the contacts of this … (can be null)
    "customer" : 37091, // … customer (id) - int(1…)
    "after" : 59068 // … with identifier after this value - int(0…)
  }
}

Response

{
  "status" : "ok",
  "count" : 67 // number of contacts - int(0…)
}

contacts.create

Create a new contact.

Request

Admin SDK
Admin.api('commerce.contacts.create', request, function(response) { … });
HTTP POST
/api/v10/commerce.contacts.create
{
  "contact" : { // contact to create (required)
    "customer" : 37091, // customer (id) (required) - int(1…)
    "name" : "John Smith", // name (required) - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address (can be null) - string(3…120)
    "note" : "" // note - string(0…255)
  }
}

Response

{
  "status" : "ok",  
  "id" : 59068 // identifier of the new contact - int(1…)
}

Errors

Field Type Description
customer NotFound Customer <customer> does not exist
email InvalidValue '<email>' is not a well formed email address

contacts.update

Updates a contact. Any fields left out of the request will remain unchanged.

Request

Admin SDK
Admin.api('commerce.contacts.update', request, function(response) { … });
HTTP POST
/api/v10/commerce.contacts.update
{
  "id" : 59068, // identifier of the contact to update (required)
  "contact" : { // contact's fields to update (required)
    "customer" : 37091, // customer (id) - int(1…)
    "name" : "John Smith", // name - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address (can be null) - string(3…120)
    "note" : "" // note - string(0…255)
  }
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
customer NotFound Customer <customer> does not exist
email InvalidValue '<email>' is not a well formed email address
id NotFound Contact <id> does not exist

contacts.delete

Deletes one or more contacts.

Request

Admin SDK
Admin.api('commerce.contacts.delete', request, function(response) { … });
HTTP POST
/api/v10/commerce.contacts.delete
{
  "ids" : [ 59068, 12078, 23939, … ] // identifiers of the contacts to delete (required) - int(1…)
}

Response

{
  "status" : "ok"
}