product-files

product-files.find

Returns the files of a product.

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

request

{
  "conditions" : { // returns only the files …
    "product" : 281 // … of this product (id) - int(1…)
  },
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "address", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned files, can contain "id", "-id", "product", "-product", "type", "-type",
                        // "size", "-size", "description" and "-description" - string
  "limit" : 10, // maximum number of files to return - int(1…100)
  "first" : 0 // index of the first file to return - int(0…)
}

response

{
  "status" : "ok",
  "files" : [ {
    "id" : 703, // identifier - int(1…)
    "product" : 281, // product (id) - int(1…)
    "address" : "http://…", // url address - string(42…255)
    "type" : "pdf", // type - string(3)
    "size" : 549071, // size in bytes - int(1…)
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Manual",
      "it" : "Manuale"
    }
  }, … ]
}

product-files.get

Returns a product file.

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

request

{
  "id" : 703, // identifier of the file - int(1…)
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "address", … ] // fields to return - string
}

response

{
  "status" : "ok",
  "file" : { // (can be null)
    "id" : 703, // identifier - int(1…)
    "product" : 281, // product (id) - int(1…)
    "address" : "http://…", // url address - string(42…255)
    "type" : "pdf", // type - string(3)
    "size" : 549071, // size in bytes - int(1…)
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Manual",
      "it" : "Manuale"
    }
  }
}

product-files.count

Number of files tha meet the given conditions.

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

request

{
  "conditions" : { // returns only the files …
    "product" : 281 // … of this product (id) - int(1…)
  }
}

response

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

product-files.create

Creates a product file.

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

request

{
  "file" : { // product file to create (required)
    "product" : 281, // product (id) (required) - int(1…)
    "file" : { // file (required)
      "name" : "manual.pdf", // name (required) - string(1…255)
      "content" : "Y810D…B031M==" // content in base64 format (required) - string
    },
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Manual",
      "it" : "Manuale"
    }
  }
}

response

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

Errors

Field Type Description
product NotFound Product <product> does not exist

product-files.update

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

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

request

{
  "id" : 703, // identifier (required) - int(1…)
  "file" : { // file's fields to update (required)
    "file" : { // file
      "name" : "manual.pdf", // name (required) - string(1…255)
      "content" : "Y810D…B031M==" // content in base64 format (required) - string
    },
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Manual",
      "it" : "Manuale"
    }
  }
}

response

{
  "status" : "ok"
}

Errors

Field Type Description
id NotFound Product file <id> does not exist

product-files.delete

Deletes one or more product files.

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

request

{
  "ids" : [ 703, 1085, 280, … ] // identifiers of the files to delete (required) - int(1…)
}

response

{
  "status" : "ok"
}