Open2b versione 7.5

suppliers

suppliers.find

Returns the suppliers that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.suppliers.find', request, function(response) { … });
HTTP POST
/api/v10/commerce.suppliers.find
{
  "conditions" : { // returns the suppliers with this …
    "ids" : [ 285, 378, … ], // … identifiers - int(1…)
    "code" : "TF78123", // … code - string(1…32)
    "keywords" : "acme", // … keywords in code, name, company code or email - string(1…20)
    "country" : "GB", // … country (ISO code) - string(2)
    "stateProv" : "LND", // … state, province or county - string(1…3)
    "after" : 285 // … with identifier after this value - int(0…)
  },
  "fields" : [ "id", "code", … ], // fields to return - string
  "order" : [ "id" ], // sort order of returned suppliers, can contain "id", "-id", "code", "-code", "email", "-email",
                      // "companyName", "-companyName", "companyCode", "-companyCode", "country", "-country",
                      // "phoneNumber", "-phoneNumber", "mobileNumber", "-mobileNumber", "faxNumber", "-faxNumber",
                      // "updateTime" and "-updateTime" - string
  "limit" : 10, // maximum number of suppliers to return - int(1…)
  "first" : 0 // index of the first supplier to return - int(0…)
}

Response

{
  "status" : "ok",
  "suppliers" : [ {
    "id" : 285, // identifier - int(1…)
    "code" : "TF78123", // code - string(0…32)
    "firstName" : "Sherlock", // first name - string(0…25)
    "lastName" : "Holmes", // last name - string(0…25)
    "personalCode" : "SH239IBA", // personal code number - string(0…20)
    "companyName" : "Investigations Inc", // company name - string(1…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(0…60)
    "street2" : "", // street, second row - string(0…60)
    "city" : "London", // city - string(0…35)
    "postalCode" : "NW1 6XE", // postal code - string(0…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(0…120)
    "updateTime" : "2020-09-05 15:38:07" // last update time - datetime
  }, … ]
}

suppliers.get

Returns a supplier given its identifier.

Request

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

Response

{
  "status" : "ok",
  "supplier" : { // (can ben null)
    "id" : 285, // identifier - int(1…)
    "code" : "TF78123", // code - string(0…32)
    "firstName" : "Sherlock", // first name - string(0…25)
    "lastName" : "Holmes", // last name - string(0…25)
    "personalCode" : "SH239IBA", // personal code number - string(0…20)
    "companyName" : "Investigations Inc", // company name - string(1…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(0…60)
    "street2" : "", // street, second row - string(0…60)
    "city" : "London", // city - string(0…35)
    "postalCode" : "NW1 6XE", // postal code - string(0…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(0…120)
    "updateTime" : "2020-09-05 15:38:07" // last update time - datetime
  }
}

suppliers.count

Number of suppliers that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.suppliers.count', request, function(response) { … });
HTTP POST
/api/v10/commerce.suppliers.count
{
  "conditions" : { // counts the suppliers with this …
    "ids" : [ 285, 378, … ], // … identifiers - int(1…)
    "code" : "TF78123", // … code - string(1…32)
    "keywords" : "acme", // … keywords in code, name, company code or email - string(1…20)
    "country" : "GB", // … country (ISO code) - string(2)
    "stateProv" : "LND", // … state, province or county - string(1…3)
    "after" : 285 // … with identifier after this value - int(0…)
  }
}

Response

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

suppliers.create

Create a new supplier.

Request

Admin SDK
Admin.api('commerce.suppliers.create', request, function(response) { … });
HTTP POST
/api/v10/commerce.suppliers.create
{
  "supplier" : { // supplier to create (required)
    "code" : "TF78123", // code - string(0…32)
    "firstName" : "Sherlock", // first name - string(0…25)
    "lastName" : "Holmes", // last name - string(0…25)
    "personalCode" : "SH239IBA", // personal code number - string(0…20)
    "companyName" : "Investigations Inc", // company name (required) - string(1…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(0…60)
    "street2" : "", // street, second row - string(0…60)
    "city" : "London", // city - string(0…35)
    "postalCode" : "NW1 6XE", // postal code - string(0…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(0…120)
  }
}

Response

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

Errors

Field Type Description
code AlreadyExists Code '<code>' already exists
email InvalidValue '<email>' is not a well formed email address

suppliers.update

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

Request

Admin SDK
Admin.api('commerce.suppliers.update', request, function(response) { … });
HTTP POST
/api/v10/commerce.suppliers.update
{
  "id" : 285, // identifier of the supplier to update (required) - int(1…)
  "supplier" : { // supplier's fields to update (required)
    "code" : "TF78123", // code - string(0…32)
    "firstName" : "Sherlock", // first name - string(0…25)
    "lastName" : "Holmes", // last name - string(0…25)
    "personalCode" : "SH239IBA", // personal code number - string(0…20)
    "companyName" : "Investigations Inc", // company name - string(1…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(0…60)
    "street2" : "", // street, second row - string(0…60)
    "city" : "London", // city - string(0…35)
    "postalCode" : "NW1 6XE", // postal code - string(0…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(0…120)
  }
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
id NotFound Supplier '<id>' does not exist
code AlreadyExists Code '<code>' already exists
email InvalidValue Email '<email>' is not a well formed email address

suppliers.delete

Deletes one or more suppliers.

Request

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

Response

{
  "status" : "ok"
}