Open2b versione 7.5

product-files

product-files.find

Returns the files of a product.

Admin SDK
Admin.api('commerce.product-files.find', request, function(response) { … });
HTTP POST
/api/v10/commerce.product-files.find

Request

{
  "conditions" : { // returns only the files …
    "product" : 281, // … of this product (id) - int(1…)
    "after" : 703 // … with identifier after this value - int(0…)
  },
  "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…)
  "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" : "https://…", // 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.

Admin SDK
Admin.api('commerce.product-files.get', request, function(response) { … });
HTTP POST
/api/v10/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" : "https://…", // 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.

Admin SDK
Admin.api('commerce.product-files.count', request, function(response) { … });
HTTP POST
/api/v10/commerce.product-files.count

Request

{
  "conditions" : { // counts only the files …
    "product" : 281, // … of this product (id) - int(1…)
    "after" : 703 // … with identifier after this value - int(0…)
  }
}

Response

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

product-files.create

Creates a product file.

Admin SDK
Admin.api('commerce.product-files.create', request, function(response) { … });
HTTP POST
/api/v10/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.

Admin SDK
Admin.api('commerce.product-files.update', request, function(response) { … });
HTTP POST
/api/v10/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.

Admin SDK
Admin.api('commerce.product-files.delete', request, function(response) { … });
HTTP POST
/api/v10/commerce.product-files.delete

Request

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

Response

{
  "status" : "ok"
}