customers

customers.find

Returns the customers that meet the given conditions.

JS
CR.api('commerce.customers.find', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.customers.find

request

{
  "conditions" : { // returns the customers …
    "ids" : [ 37091, 722, … ], // … with these identifiers - int(1…)
    "code" : "TF78123", // … with this code - string(0…32)
    "canLogin" : true, // … that can login or not on site -- bool
    "priceList" : 3, // … with this price list - int(1…)
    "email" : "johnsmith@acme.com", // … with this email - string(3…120)
    "personalCode" : "SH239IBA", // … with this personal code - string(1…20)
    "companyCode" : "ACME80193", // … with this company code - string(1…20)
    "keywords" : "acme", // … with these keywords in code, name, personal code, company code or email - string(1…120)
    "country" : "GB", // … with this country - string(2)
    "stateProv" : "LND" // … with this province, state or county - string(1…3)
  },
  "fields" : [ "id", "code", … ], // fields to return - string
  "order" : [ "id" ], // sort order of returned customers, can contain "id", "-id", "code", "-code", "email", "-email",
                      // "canLogin", "-canLogin", "hasPassword", "-hasPassword", "fullName", "-fullName",
                      // "country", "-country", "creationTime", "-creationTime", "updateTime", "-updateTime",
                      // "priceList" and "-priceList" - string
  "limit" : 10, // maximum number of customers to return - int(1…100)
  "first": 0 // index of the first customer to return - int(0…)
}

response

{
  "status" : "ok",
  "customers" : [ {
    "id" : 37091, // identifier - int(1…)
    "code" : "TF78123", // code - string(0…32)
    "canLogin" : true, // indicates if she can login on site - bool
    "hasPassword" : true, // indicates if she has a password - bool
    "encryptedPassword" : "foY5/eLc93Wu5…", // encrypted password - string(45)
    "creationTime" : "2009-05-21 16:49:13", // creation time - datetime
    "loginTime" : "2010-12-13 12:05:44", // last login time (can be null) - datetime
    "updateTime" : "2010-12-05 09:24:01", // last update time - datetime
    "priceList" : 3, // price list (id) of the customer - int(1…)
    "wishList" : [ 340, 981, 18, … ], // products (id) in the customer's wish list - int(1…)
    "cart" : 501741697, // identifier of the saved cart -- int(1…)
    "fullName" : "Investigations Inc", // Company name or first and last name - string(1…100)
    "billingAddress" : { // billing address
      "firstName" : "Sherlock", // first name - string(1…25)
      "lastName" : "Holmes", // last name - string(1…25)
      "personalCode" : "SH239IBA", // personal code - string(0…20)
      "companyName" : "Investigations Inc", // company name - string(0…100)
      "companyCode" : "INV8403MC1", // company code number - string(0…20)
      "companyCode2" : "7J BA3 006", // second company code number - string(0…20)
      "street1" : "221b Baker Street", // street, first row - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city - string(1…25)
      "postalCode" : "NW1 6XE", // postal code - string(1…20)
      "stateProv" : "LND", // state, province or county - string(0…3)
      "country" : "GB", // country (ISO code) - string(2)
      "phoneNumber" : "+44+207 2243688", // phone number - string(0…15)
      "mobileNumber" : "", // mobile number - string(0…15)
      "faxNumber" : "", // fax number - string(0…15)
      "email" : "holmes@inv-london.com" // email address - string(3…120)
    },
    "shippingAddress" : { // shipping address (can be null)
      "name" : "John", // recipient name - string(1…100)
      "street1" : "221b Baker Street", // street, first row - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city - string(1…25)
      "postalCode" : "NW1 6XE", // postal code - string(1…20)
      "stateProv" : "LND", // province, state or county - string(0…3)
      "country" : "GB" // country (ISO code) - string(2)
    }
  }, … ]
}

customers.get

Returns a customer given its identifier.

JS
CR.api('commerce.customers.get', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.customers.get

request

{
  "id" : 37091, // identifier (required) - int(1…)
  "fields" : [ "id", "code", … ] // fields to return - string
}

response

{
  "status" : "ok",
  "customer" : { // (can be null)
    "id" : 37091, // identifier - int(1…)
    "code" : "TF78123", // code - string(0…32)
    "canLogin" : true, // indicates if she can login on site - bool
    "hasPassword" : true, // indicates if she has a password - bool
    "encryptedPassword" : "foY5/eLc93Wu5…", // encrypted password - string(45)
    "creationTime" : "2009-05-21 16:49:13", // creation time - datetime
    "loginTime" : "2010-12-13 12:05:44", // last login time (can be null) - datetime
    "updateTime" : "2010-12-05 09:24:01", // last update time - datetime
    "priceList" : 3, // price list (id) of the customer - int(1…)
    "wishList" : [ 340, 981, 18, … ], // products (id) in the customer's wish list - int(1…)
    "cart" : 501741697, // identifier of the saved cart -- int(1…)
    "fullName" : "Investigations Inc", // Company name or first and last name - string(1…100)
    "billingAddress" : { // billing address
      "firstName" : "Sherlock", // first name - string(1…25)
      "lastName" : "Holmes", // last name - string(1…25)
      "personalCode" : "SH239IBA", // personal code - string(0…20)
      "companyName" : "Investigations Inc", // company name - string(0…100)
      "companyCode" : "INV8403MC1", // company code number - string(0…20)
      "companyCode2" : "7J BA3 006", // second company code number - string(0…20)
      "street1" : "221b Baker Street", // street, first row - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city - string(1…25)
      "postalCode" : "NW1 6XE", // postal code - string(1…20)
      "stateProv" : "LND", // state, province or county - string(0…3)
      "country" : "GB", // country (ISO code) - string(2)
      "phoneNumber" : "+44+207 2243688", // phone number - string(0…15)
      "mobileNumber" : "", // mobile number - string(0…15)
      "faxNumber" : "", // fax number - string(0…15)
      "email" : "holmes@inv-london.com" // email address - string(3…120)
    },
    "shippingAddress" : { // shipping address (can be null)
      "name" : "John", // recipient name - string(1…100)
      "street1" : "221b Baker Street", // street, first row - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city - string(1…25)
      "postalCode" : "NW1 6XE", // postal code - string(1…20)
      "stateProv" : "LND", // province, state or county - string(0…3)
      "country" : "GB" // country (ISO code) - string(2)
    }
  }
}

customers.authenticate

Authenticates a customer given its email and password and on success returns it.

JS
CR.api('commerce.customers.authenticate', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.customers.authenticate

request

{
  "email" : "johnsmith@acme.com", // email (required) - string(3…120)
  "password" : "foY5/eLc93Wu5", // password (required) - string(4…16)
  "fields" : [ "id", "code", … ] // fields to return - string
}

response

{
  "status" : "ok",
  "customer" : { // (can be null)
    "id" : 37091, // identifier - int(1…)
    "code" : "TF78123", // code - string(0…32)
    "canLogin" : true, // indicates if she can login on site - bool
    "hasPassword" : true, // indicates if she has a password - bool
    "encryptedPassword" : "foY5/eLc93Wu5…", // encrypted password - string(45)
    "creationTime" : "2009-05-21 16:49:13", // creation time - datetime
    "loginTime" : "2010-12-13 12:05:44", // last login time (can be null) - datetime
    "updateTime" : "2010-12-05 09:24:01", // last update time - datetime
    "priceList" : 3, // price list (id) of the customer - int(1…)
    "wishList" : [ 340, 981, 18, … ], // products (id) in the customer's wish list - int(1…)
    "cart" : 501741697, // identifier of the saved cart -- int(1…)
    "fullName" : "Investigations Inc", // Company name or first and last name - string(1…100)
    "billingAddress" : { // billing address
      "firstName" : "Sherlock", // first name - string(1…25)
      "lastName" : "Holmes", // last name - string(1…25)
      "personalCode" : "SH239IBA", // personal code - string(0…20)
      "companyName" : "Investigations Inc", // company name - string(0…100)
      "companyCode" : "INV8403MC1", // company code number - string(0…20)
      "companyCode2" : "7J BA3 006", // second company code number - string(0…20)
      "street1" : "221b Baker Street", // street, first row - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city - string(1…25)
      "postalCode" : "NW1 6XE", // postal code - string(1…20)
      "stateProv" : "LND", // state, province or county - string(0…3)
      "country" : "GB", // country (ISO code) - string(2)
      "phoneNumber" : "+44+207 2243688", // phone number - string(0…15)
      "mobileNumber" : "", // mobile number - string(0…15)
      "faxNumber" : "", // fax number - string(0…15)
      "email" : "holmes@inv-london.com" // email address - string(3…120)
    },
    "shippingAddress" : { // shipping address (can be null)
      "name" : "John", // recipient name - string(1…100)
      "street1" : "221b Baker Street", // street, first row - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city - string(1…25)
      "postalCode" : "NW1 6XE", // postal code - string(1…20)
      "stateProv" : "LND", // province, state or county - string(0…3)
      "country" : "GB" // country (ISO code) - string(2)
    }
  }
}

Note

customers.count

Number of customers that meet the given conditions.

JS
CR.api('commerce.customers.count', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.customers.count

request

{
  "conditions" : { // counts the customers with this …
    "ids" : [ 37091, 722, … ], // … with these identifiers - int(1…)
    "code" : "TF78123", // … with this code - string(0…32)
    "canLogin" : true, // … that can login or not on site -- bool
    "priceList" : 3, // … with this price list - int(1…)
    "email" : "johnsmith@acme.com", // … with this email - string(3…120)
    "personalCode" : "SH239IBA", // … with this personal code - string(1…20)
    "companyCode" : "ACME80193", // … with this company code - string(1…20)
    "keywords" : "acme", // … with these keywords in code, name, personal code, company code or email - string(1…120)
    "country" : "GB", // … with this country - string(2)
    "stateProv" : "LND" // … with this province, state or county - string(1…3)
  }
}

response


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

customers.create

Create a new customer.

JS
CR.api('commerce.customers.create', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.customers.create

request

{
  "customer" : { // customer to create (required)
    "code" : "TF78123", // code - string(0…32)
    "canLogin" : true, // indicates if she can login on site - bool
    "password" : { // password (can be null) :
      "value" : "I9bV2crS", // value - string(6…50)
      "cryptedBy" : "CommerceReady" // application witch has crypted the password (can be null) - string
    },
    "creationTime" : "2009-05-21 16:49:13", // creation time - datetime
    "loginTime" : "2013-08-07 10:22:07", // last login time (can be null) - datetime
    "priceList" : 3, // price list (id) associated - int(1…)
    "wishList" : [ 340, 981, 18, … ], // products (id) in the wish list - int(1…)
    "billingAddress" : { // billing address (required)
      "firstName" : "Sherlock", // first name (required) - string(1…25)
      "lastName" : "Holmes", // last name (required) - string(1…25)
      "personalCode" : "SH239IBA", // personal code - string(0…20)
      "companyName" : "Investigations Inc", // company name - string(0…100)
      "companyCode" : "INV8403MC1", // company code number - string(0…20)
      "companyCode2" : "7J BA3 006", // second company code number - string(0…20)
      "street1" : "221b Baker Street", // street, first row (required) - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city  (required) - string(1…25)
      "postalCode" : "NW1 6XE", // postal code (required) - string(1…20)
      "stateProv" : "LND", // state, province or county - string(0…3)
      "country" : "GB", // country (ISO code) (required) - string(2)
      "phoneNumber" : "+44+207 2243688", // phone number - string(0…15)
      "mobileNumber" : "", // mobile number - string(0…15)
      "faxNumber" : "", // fax number - string(0…15)
      "email" : "holmes@inv-london.com" // email address (required) - string(3…120)
    },
    "shippingAddress" : { // shipping address (can be null)
      "name" : "John", // recipient name (required) - string(1…100)
      "street1" : "221b Baker Street", // street, first row (required) - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city (required) - string(1…25)
      "postalCode" : "NW1 6XE", // postal code (required) - string(1…20)
      "stateProv" : "LND", // province, state or county - string(0…3)
      "country" : "GB" // country (ISO code) (required) - string(2)
    }
  }
}

response

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

Errors

Field Type Description
code AlreadyExists Code '<code>' already exists
email InvalidValue '<email>' is not a well formed email address
email AlreadyExists Email '<email>' with an assigned password already exists
password InvalidValue Password must have between 4 and 16 characters
password InvalidValue Password is not a '<cryptedBy>' crypted password
creationTime InvalidValue Creation time '<creationTime>' is in the future

customers.update

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

JS
CR.api('commerce.customers.update', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.customers.update

request

{
  "id" : 37091, // identifier of the customer to update (required)
  "customer" : { // customer's fields to update (required)
    "code" : "TF78123", // code - string(0…32)
    "canLogin" : true, // indicates if she can login on site - bool
    "password": { // password (can be null):
      "value" : "I9bV2crS", // value - string(6…50)      
      "cryptedBy" : "CommerceReady" // application witch has crypted the password (can be null) - string
    },
    "creationTime" : "2009-05-21 16:49:13", // creation time - datetime
    "loginTime" : "2013-08-07 10:22:07", // last login time (can be null) - datetime
    "priceList" : 3, // associated price list (id) - int(1…)
    "wishList" : [ 340, 981, 18, … ], // products (id) in the wish list - int(1…)
    "cart" : null, // identifier of the saved cart (can be null) -- int(1…)
    "billingAddress" : { // billing address
      "firstName" : "Sherlock", // first name (required) - string(1…25)
      "lastName" : "Holmes", // last name (required) - string(1…25)
      "personalCode" : "SH239IBA", // personal code - string(0…20)
      "companyName" : "Investigations Inc", // company name - string(0…100)
      "companyCode" : "INV8403MC1", // company code number - string(0…20)
      "companyCode2" : "7J BA3 006", // second company code number - string(0…20)
      "street1" : "221b Baker Street", // street, first row (required) - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city  (required) - string(1…25)
      "postalCode" : "NW1 6XE", // postal code (required) - string(1…20)
      "stateProv" : "LND", // state, province or county - string(0…3)
      "country" : "GB", // country (ISO code) (required) - string(2)
      "phoneNumber" : "+44+207 2243688", // phone number - string(0…15)
      "mobileNumber" : "", // mobile number - string(0…15)
      "faxNumber" : "", // fax number - string(0…15)
      "email" : "holmes@inv-london.com" // email address (required) - string(3…120)
    },
    "shippingAddress" : { // shipping address (can be null)
      "name" : "John", // recipient name (required) - string(1…100)
      "street1" : "221b Baker Street", // street, first row (required) - string(1…60)
      "street2" : "", // street, second row - string(0…60)
      "city" : "London", // city (required) - string(1…25)
      "postalCode" : "NW1 6XE", // postal code (required) - string(1…20)
      "stateProv" : "LND", // province, state or county - string(0…3)
      "country" : "GB" // country (ISO code) (required) - string(2)
    }
  }
}

response

{
  "status" : "ok"
}

Errors

Field Type Description
id InvalidValue Customer '<id>' does not exist
email InvalidValue Email '<email>' is not a well formed email address
email AlreadyExists Email '<email>' with an assigned password already exists
password InvalidValue 'password' must have between 4 and 16 characters

customers.delete

Deletes one or more customers.

JS
CR.api('commerce.customers.delete', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.customers.delete

request

{
  "ids" : [ 37091, 722, 8216, … ] // identifiers of the customers to delete (required) - int(1…)
}

response

{
  "status" : "ok"
}

note generali

  • Il code se presente è unico per ogni cliente
  • Non si possono avere due clienti con la stessa email ed entrambi con una password assegnata
  • Per gli id in wishList non viene verificata e non è garantita l'effettiva esistenza dei prodotti in catalogo
  • Non viene fatta nessuna verifica su priceList se esiste o no
  • Se la password password.value è in chiaro allora password.cryptedBy non deve essere indicato oppure deve essere "None". Se la password è cifrata allora password.cryptedBy indica l'applicazione con cui è stata cifrata: "CommerceReady", "osCommerce", "ZenCart" o "CRELoaded"