TABLE OF CONTENTS
Requests
Get Base Specification
Pre-Request Script
The signing of the signature requires the endpoint without parameters. The script below prepared the endpoint for signing. It then saves {{timestamp}} and token + signature in {{hmacHeader}} to be used in the request headers ‘x-oneflow-date’ and x-oneflow-authorization.
var key = pm.environment.get("token");
var secret = pm.environment.get("secret");
let endpoint;
if (request.url.includes("?")) {
endpoint = request.url.substring(request.url.indexOf("/api"), request.url.indexOf("?"));
} else endpoint = request.url.substring(request.url.indexOf("/api"));
// resolve any variables in the endpoint
while(endpoint.indexOf('{{') >= 0) {
var varName = endpoint.substring(endpoint.indexOf('{{')+2, endpoint.indexOf('}}'));
var varValue= pm.environment.get(varName);
endpoint = endpoint.replace('{{'+varName+'}}', varValue);
}
var headers = createHeaders (request.method, endpoint);
pm.environment.set("hmacHeader", headers[0]);
pm.environment.set("timestamp", headers[1]);
function createHeaders(method, path) {
var timestamp = (new Date()).toISOString();
var toSign = method.toUpperCase() + " " + path + " " + timestamp;
var hash = CryptoJS.HmacSHA1(toSign, secret);
var sig = CryptoJS.enc.Hex.stringify(hash);
var headers = [ key + ":" + sig, timestamp ];
return headers;
}
Endpoint
/api/specifications
Parameters
query | : | {"description":"{{boilerplateSpecDescr}}" |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Method Execution
// Request
// GET https://product-api.oneflowcloud.com/api/specifications?query={"description":"210x297_Demo_Files"}
GET {{piazza-base}}/api/specifications?query={ "description":"{{boilerplateSpecDescr}}"}
// body.data[0] in Response
{
"total": 1,
"limit": 10,
"skip": 0,
"data": [
{
"_id": "5afcdc87d358b00012c0fd80",
"updatedAt": "2020-04-22T19:06:17.464Z",
"createdAt": "2018-05-17T01:36:07.958Z",
"type": "Book",
"sourceSpecId": "210x297_Demo_Files",
"description": "210x297_Demo_Files",
"width": 210,
"height": 297,
"specTemplateId": "5a31032b4181f700d01e1115",
"accountId": "5ac79ea7b0c3b91a004b7a2a",
"tags": [],
"componentIds": [
"5afcdc8705bb930013af4ed1",
"5afcdc87d358b00012c0fd7f"
],
"__v": 0,
"specTemplate": {
"_id": "5a31032b4181f700d01e1115",
"description": "Soft Case",
"type": "Book",
"variant": "Soft Case",
"tags": [],
"width": 0,
"height": 0,
"identifier": "",
"components": [
{
"code": "cover",
"required": true,
"width": 0,
"height": 0,
"bleed": 3,
"paperSpec": {
"type": "Book Board",
"grade": 200
},
"pages": {
"method": "exact",
"count": 2
},
"includeSpine": true,
"preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx",
"finishingOptions": {
"simplex": false,
"lamination": "gloss",
"foiling": "none"
}
},
{
"code": "text",
"required": true,
"width": 0,
"height": 0,
"bleed": 3,
"paperSpec": {
"type": "80GSM Uncoated Ivory",
"grade": 400
},
"pages": {
"method": "multiple",
"count": 4
},
"includeSpine": false,
"preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx",
"finishingOptions": {
"simplex": false,
"colorProfile": null
}
}
]
},
"components": [
{
"_id": "5afcdc8705bb930013af4ed1",
"updatedAt": "2020-04-22T19:06:17.869Z",
"createdAt": "2018-05-17T01:36:07.301Z",
"code": "cover",
"required": true,
"width": 210,
"height": 297,
"bleed": 3,
"includeSpine": true,
"accountId": "5ac79ea7b0c3b91a004b7a2a",
"finishingOptions": {
"simplex": false,
"lamination": "gloss",
"foiling": "none"
},
"preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx",
"pages": {
"method": "exact",
"count": 2
},
"paperSpec": {
"gradeUnits": "microns",
"type": "Book Board",
"grade": 200
},
"barcodes": [],
"__v": 0
},
{
"_id": "5afcdc87d358b00012c0fd7f",
"updatedAt": "2020-04-22T19:06:17.872Z",
"createdAt": "2018-05-17T01:36:07.321Z",
"code": "text",
"required": true,
"width": 210,
"height": 297,
"bleed": 3,
"includeSpine": false,
"accountId": "5ac79ea7b0c3b91a004b7a2a",
"finishingOptions": {
"simplex": false,
"colorProfile": "color85_economy_uncoated_v3_1"
},
"preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx",
"pages": {
"method": "multiple",
"count": 2
},
"paperSpec": {
"gradeUnits": "microns",
"type": "80GSM Uncoated Ivory",
"grade": 400
},
"barcodes": [],
"__v": 0
}
],
"active": true
}
]
}
Post-response Script
Capture {{accountId}}.
var body = JSON.parse(responseBody); pm.environment.set("accountId", body.data[0].accountId); tests["Account Id found"] = (body.data[0].accountId !== "" && body.data[0].accountId !== undefined); tests["Status code is 200"] = responseCode.code === 200;
|
Post cover component
POST cover component
Pre-request Script
Same as in Pre-Request Script.
Endpoint
/api/components
Parameters
None
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Content-Type | : | Application/json |
Body
{ "code": "cover", "required": true, "width": 189, "height": 246, "bleed": 3, "includeSpine": true, "accountId": "5ac79ea7b0c3b91a004b7a2a", "finishingOptions": { "simplex": false, "lamination": "gloss", "foiling": "none" }, "preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx", "pages": { "method": "exact", "coun{ "code": "cover", "required": true, "width": 189, "height": 246, "bleed": 3, "includeSpine": true, "accountId": "5ac79ea7b0c3b91a004b7a2a", "finishingOptions": { "simplex": false, "lamination": "gloss", "foiling": "none" }, "preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx", "pages": { "method": "exact", "count": 2 }, "paperSpec": { "gradeUnits": "microns", "type": "Book Board", "grade": 200 } } t": 2 }, "paperSpec": { "gradeUnits": "microns", "type": "Book Board", "grade": 200 } }
|
Method Execution
// Request // POST https://product-api.oneflowcloud.com/api/components POST {{piazza-base}}/api/components
// Response { "paperSpec": { "gradeUnits": "microns", "type": "Book Board", "grade": 200 }, "preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx", "_id": "5f8302e1f418ea001288ed35", "code": "cover", "required": true, "width": 189, "height": 246, "bleed": 3, "includeSpine": true, "finishingOptions": { "simplex": false, "lamination": "gloss", "foiling": "none" }, "pages": { "method": "exact", "count": 2 }, "accountId": "5ac79ea7b0c3b91a004b7a2a", "barcodes": [], "createdAt": "2020-10-11T13:04:33.184Z", "updatedAt": "2020-10-11T13:04:33.184Z", "__v": 0 } |
Post-response script
Capture coverCompId
var body = JSON.parse(response.body); pm.environment.set("coverCompId", body._id); tests["Cover component Id found"] = (body._id !== "" && body._id !== undefined); tests["Status code is 200"] = responseCode.code === 200; |
Post text component
POST text component same way as cover component procedure
Method Execution
// Request // POST https://product-api.oneflowcloud.com/api/components POST {{piazza-base}}/api/components
// Response { "paperSpec": { "gradeUnits": "microns", "type": "80GSM Uncoated Ivory", "grade": 400 }, "preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx", "_id": "5f8310ece0f8bd00120fed8b", "code": "text", "required": true, "width": 189, "height": 246, "bleed": 3, "includeSpine": false, "finishingOptions": { "simplex": false, "colorProfile": "color85_economy_uncoated_v3_1", "hdnaRequired": false }, "pages": { "method": "multiple", "count": 4 }, "accountId": "5ac79ea7b0c3b91a004b7a2a", "barcodes": [], "createdAt": "2020-10-11T14:04:28.436Z", "updatedAt": "2020-10-11T14:04:28.436Z", "__v": 0 } |
Post response script
Capture textCompId
var body = JSON.parse(response.body); pm.environment.set("textCompId", body._id); tests["Cover component Id found"] = (body._id !== "" && body._id !== undefined); tests["Status code is 200"] = responseCode.code === 200 |
Patch component
If a change is required in a component, use the PATCH method.
Pre-request Script
Same as in Pre-Request Script.
Endpoint
/api/components/{{coverCompId}}
Content-Type | : | application/json |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Body
{ “code”: “cover”, "width": 407, "bleed": 2 } |
Method Execution
// Request // PATCH https://product-api.oneflowcloud.com/api/components/5f8302e1f418ea001288ed35 PATCH {{piazza-base}}/api/components/{{coverCompId}}
// Response { "paperSpec": { "gradeUnits": "microns", "type": "80GSM Uncoated Ivory", "grade": 400 }, "preflightProfile": "piazza/PDFX-4-With-Image-Sampling.kfpx", "_id": "5f8310ece0f8bd00120fed8b", "code": "text", "required": true, "width": 407, "height": 246, "bleed": 2, "includeSpine": false, "finishingOptions": { "simplex": false, "colorProfile": "color85_economy_uncoated_v3_1", "hdnaRequired": false }, … } |
Post Specification
Pre-request script
Same as in Pre-request script.
Endpoint
/api/specifications
Content-Type | : | application/json |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Body
{ "type": "Book", "variant": "Soft Case", "sourceSpecId": "PRS-189x246-Soft", "description": "186x243 Soft Book 3", "width": 189, "height": 246, "componentIds": [ "{{coverCompId}}", "{{textCompId}}" "specTemplateId": "{{specId}}", "accountId": "{{accountId}}", "tags": [ "Demo" ] } |
Method Execution
// Request // POST https://product-api.oneflowcloud.com/api/specifications POST {{piazza-base}}/api/specifications
// Response { "componentIds": [ "5f8302e1f418ea001288ed35", "5f8310ece0f8bd00120fed8b" ], "tags": [ "demo" ], "_id": "5f8c0b9df418ea001293d2de", "type": "Book", "variant": "Soft Case", "sourceSpecId": "PRS-189x246-Soft", "description": "186x243 Soft Book 3", "width": 189, "height": 246, "specTemplateId": "5a31032b4181f700d01e1115", "accountId": "5ac79ea7b0c3b91a004b7a2a", "createdAt": "2020-10-18T09:32:13.548Z", "updatedAt": "2020-10-18T09:32:13.548Z", "__v": 0 } |
Post-response script
Capture specId
var body = JSON.parse(response.body); pm.environment.set("specCompId", body._idc); tests["Specification Id found"] = (body._id !== "" && body._id !== undefined); tests["Status code is 200"] = responseCode.code === 200; |
Get a signed S3 URL
Pre-request script
Same as in Pre-request script.
Endpoint
/api/files/getuploadurl
Parameters
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Method Execution
// Request // GET https://file-api.oneflowcloud.com/api/files/getuploadurl?type=application/pdf GET {{file-base}}{{endpoint}}?type=application/pdf
// Response { "url": "https://s3.amazonaws/etc/", "s3Path": "PATH-ON-S3" } |
Post-response script
Capture coverS3UploadUrl and coverS3Path for later use.
var body = JSON.parse(responseBody); pm.environment.set("coverS3UploadUrl", body.url); pm.environment.set("coverS3Path", body.s3Path); tests["s3UploadUrl not empty"] = body.url !== ""; tests["Status code is 200"] = responseCode.code === 200; |
Put cover file
Upload cover PDF file to Amazon S3
Pre-request script
Not required
URL
{{coverS3UploadUrl}}
Content-Type | : | application/pdf |
Body
Configure the PDF file to download in Binary format.
Method execution
// Request PUT {{coverS3UploadUrl}} // Response Status Code: 200 OK |
Post-response script
tests["Status code is 200"] = responseCode.code === 200;
Create a record for the cover file
Create cover file path and name.
The base folder is always /Piazza/Assets.
In this example, the cover file is placed under /Piazza/Assets/Book-1.
The upload time is dependent on file size.
Pre-request script
Same as in Pre-request script
Endpoint
/api/browse{{assets-base}}/Book-1
Content-Type | : | application/json |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Body
{ "path": { "type": "file", "name": "UW_9780131974524_cover.pdf" }, "file": { "contentType": "application/pdf", "s3Path": "{{coverS3Path}}" }, "check": true, "createParent": true } |
Method execution
// Request //POST https://file-api.oneflowcloud.com/api/browse/Piazza/Assets/Book-1 POST {{file-base}}/api/browse{{assets-base}}/Book-1 // Response //The response will have a `file` property which will have an `_id` which //should be used for the next step. { "_id": "5f7f499d35e48f1fc9c191d2", "type": "file", "name": "UW_9780131974524_cover.pdf", "parentId": "5f7f426335e48fb675c180a4", "accountId": "5ac79ea7b0c3b91a004b7a2a", "file": { "_id": "5f7f499d35e48fecf3c191d4", "id": "5f7f499d35e48fecf3c191d4" "contentType": "application/pdf", "pathId": "5f7f499d35e48f1fc9c191d2", "name": "UW_9780131974524_cover.pdf", "accountId": "5ac79ea7b0c3b91a004b7a2a", "versions": [{ "_id": "5f7f499d35e48f72ffc191d3", "createdAt": "2020-10-08T17:17:17.513Z", "s3Path": "5ac79ea7b0c3b91a004b7a2a/341fee8e-f5cb-4a31-961c-16d6b8b76083" } ] } } |
Post-response script
Capture coverFileId for later.
var body = JSON.parse(responseBody); pm.environment.set("coverFileId", body.file._id); tests["coverFileId not empty"] = body.url !== ""; tests["Status code is 200"] = responseCode.code === 200; |
Put text file
Create a record for the text file
Follow the procedure specified in specified Creating a Specification to create a record of the text file.
Save the id of the file in textFileId in post response script.
var body = JSON.parse(responseBody); pm.environment.set("textFileId", body.file._id); tests["textFileId not empty"] = body.url !== ""; tests["Status code is 200"] = responseCode.code === 200; |
Book query
Get a boilerplate book
Pre-request script
Same as in Pre-request script.
Endpoint
/api/books
Parameters
query | : | "properties.isbn": "9782359731659", "status": "live" |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Method Execution
// Request // GET https://product-api.oneflowcloud.com/api/books?query={"properties.isbn": "9782359731659", "status": "live"} GET {{piazza-base}}/api/books?query={"properties.isbn": "9782359731659", "status": "live"} // body.data[0] in Response { "_id": "5b17e16b4f98710018f99821", "updatedAt": "2020-05-07T08:20:35.067Z", "createdAt": "2018-06-06T13:28:11.330Z", "sourceProductId": "9782359731659", "weight": 150, "unitPrice": 9.99, "specificationId": "5b0ecbe39eadce001ad5e602", "accountId": "5ac79ea7b0c3b91a004b7a2a", "components": [ { … |
Post-response script
Capture base book.
var body = JSON.parse(responseBody); pm.environment.set("baseBook", JSON.stringify(body.data[0])); tests["live base Book found"] = body.data[0] !== undefined; tests["Status code is 200"] = responseCode.code === 200; |
Post book
POST a new book with references to the newly created specification and components
Pre-request script
Same as in Pre-request script.
Endpoint
/api/books
Content-Type | : | application/json |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Body
{ "sourceProductId": "9782348620548", "specificationId": "5f832e47e0f8bd0012100be3", "accountId": "5ac79ea7b0c3b91a004b7a2a", "tags": [ "Demo", "Title Ingestion" ], "components": [ { "componentId": "5f8302e1f418ea001288ed35" }, { "componentId": "5f8310ece0f8bd00120fed8b" } ], "properties": { "isbn": "9782348620548", "author": "Inigo Montoya", "title": "You killed my father", "publisher": "Prepare to die", "spineBulk": 17, "version": 1, "edition": "first", "volume": 1 }, "unitPrice": 7.98, "weight": 150, "description": "Inigo Montoya from ‘The Princess Bride’", "pages": 244 } |
Method Execution
// Request // POST https://product-api.oneflowcloud.com/api/books POST {{piazza-base}}/api/books
// Response { "status": "dataready", "tags": [ "Demo", "Title Ingestion" ], "_id": "5f842a76f418ea00128a7d9f", "sourceProductId": "9782348620548", "specificationId": "5f832e47e0f8bd0012100be3", "accountId": "5ac79ea7b0c3b91a004b7a2a", "components": [ { "componentId": "5f8302e1f418ea001288ed35", "preflightStatus": "pending", "specCheckStatus": "pending", "specCheckErrors": [], "status": "dataready", "_id": "5f842a76f418ea00128a7da1", "componentId": "5f8302e1f418ea001288ed35", "barcodes": [] }, { "componentId": "5f8310ece0f8bd00120fed8b", "preflightStatus": "pending", "specCheckStatus": "pending", "specCheckErrors": [], "status": "dataready", "_id": "5f842a76f418ea00128a7da0", "barcodes": [] } ], "properties": { "isbn": "9782348620548", "author": "Inigo Montoya", "title": "You killed my father", "publisher": "Prepare to die", "spineBulk": 17, "version": 1, "edition": "first", "volume": 1 }, "unitPrice": 7.98, "weight": 150, "description": "My name is Inigo Montoya. You killed my father. Prepare to die...", "pages": 244, "createdAt": "2020-10-12T10:05:42.673Z", "updatedAt": "2020-10-12T10:05:42.673Z", "__v": 0 } |
Post-response script
Capture bookId.
var body = JSON.parse(response.body); pm.environment.set("bookId", body._id); tests["Book created. bookId found"] = (body._id !== "" && body._id !== undefined); tests["Status code is 200"] = responseCode.code === 200; |
Patch files into Book
Add cover-file reference in book cover-component and text-file reference to text-component.
Pre-request script
Same as in Pre-request script.
Endpoint
/api/books/{{bookId}}
Content-Type | : | application/json |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Body
{ "components": [ { "componentId": "5f8302e1f418ea001288ed35", "fileId": "{{coverFileId}}" }, { "componentId": "5f8310ece0f8bd00120fed8b", "fileId": "{{textFileId}}" } ] } |
Method Execution
// Request // PATCH https://product-api.oneflowcloud.com/api/books/5f842a76f418ea00128a7d9f PATCH {{piazza-base}}/api/books/{{bookId}}
// Response { "_id": "5f842a76f418ea00128a7d9f", "status": "dataready", "components": [ { "_id": "5f84407de0f8bd0012118d1e", "componentId": "5f8302e1f418ea001288ed35", "fileId": "5f82acc4783fd8f5ebdcfcb6", … |
Post book thumbnail
Calculate spine bulk
Start Pre-flight (and spec check)
Start spec Check
Triggering a component pre-flight will also incur a spec check.
The preflight profile to run is set in the component metadata. See 0.
Post cover component Pre-Flight
Pre-request script
Same as in Pre-request script.
Endpoint
/api/books/{{bookId}}/preflight/{{coverCompId}}
Content-Type | : | application/json |
x-oneflow-date | : | {{timestamp}} |
x-oneflow-authorization | : | {{hmacHeader}} |
Method Execution
// Request // POST https://product-api.oneflowcloud.com/api/books/5f842a76f418ea00128a7d9f/preflight/5f8302e1f418ea001288ed35 POST {{piazza-base}}/api/books/{{bookId}}/preflight/{{coverCompId}}
// Response { "_id": "5f842a76f418ea00128a7d9f", "status": "checking", "tags": [ "Demo", "Title Ingestion" ], "errorStatuses": [], "catalogueIds": [], "actionIds": [], "sourceProductId": "9782348620548", "specificationId": "5f832e47e0f8bd0012100be3", "accountId": "5ac79ea7b0c3b91a004b7a2a", "components": [ { "preflightStatus": "started", "specCheckStatus": "pending", "specCheckErrors": [], "status": "checking", "_id": "5f84407de0f8bd0012118d1e", |
Post text component Pre-Flight
Follow procedure described in Appendix Put cover file with in {{textCompId}}.
Get preflight status check
Get the book metadata and see what the status of components pre-flight and spec check is.
// Request // GET https://product-api.oneflowcloud.com/api/books/5f842a76f418ea00128a7d9f GET {{piazza-base}}/api/books/{{bookId}}
// Response { "_id": "5f842a76f418ea00128a7d9f", "status": "printready", "tags": [ "Demo", "Title Ingestion" ], "errorStatuses": [], "catalogueIds": [], "actionIds": [], "sourceProductId": "9782348620548", "specificationId": "5f832e47e0f8bd0012100be3", "accountId": "5ac79ea7b0c3b91a004b7a2a", "components": [ { "preflightStatus": "success", "specCheckStatus": "success", "specCheckErrors": [], "status": "printready", "_id": "5f84407de0f8bd0012118d1e", "componentId": "5f8302e1f418ea001288ed35", "fileId": "5f82acc4783fd8f5ebdcfcb6", "barcodes": [], "preflightReportUrl": "https://live-workforce-files.s3-eu-west-1.amazonaws.com/task...", "preflightReport": […] }, { "preflightStatus": "success", "specCheckStatus": "success", "specCheckErrors": [], "status": "printready", "_id": "5f84407de0f8bd0012118d1d", "componentId": "5f8310ece0f8bd00120fed8b", "fileId": "5f82bbcc783fd841efdd042b", "barcodes": [], "preflightReportUrl": "https://live-workforce-files.s3-eu-west-...", "preflightReport": […] } ] … }
|
Get cover thumbnail URL
Get cover thumbnail URL.
// Request // GET https://file-api.oneflowcloud.com/api/files/5f82acc4783fd8f5ebdcfcb6/thumbnail GET {{file-base}}/api/files/{{coverFileId}}/thumbnail
// Response { "url": "https://oneflow-file-core-api-eu-west-1.s3.eu-west-1.amazonaws.com/5ac79ea7b0c3b91a004b7a2a/7d8a66e7-052f-4891-aedb-a92e96e6dc60thumbs/thumb_0_400.png?AWSAccessKeyId=AKIAJFYOLW5OEPEGHEYA&Expires=1634616042&Signature=2ubgIFX9b5GPfYzPMWSz6r6zupU%3D" } |
Post calculate spine bulk request
Method execution
// Request // Post https://product-api.oneflowcloud.com/api/books/5f82acc4783fd8f5ebdcfcb6/requiredSpine POST {{piazza-base}}/api/books/{{bookId}}/requiredSpine
// Response { /* the full book */ } |
Post-request script
var body = JSON.parse(responseBody); pm.environment.set("spineBulk", body.properties.spineBulk); tests["spine bulk found"] = body.properties.spineBulk !== "" && body.properties.spineBulk !== undefined; tests["Status code is 200"] = responseCode.code === 200; |
Get book
// Request // Post https://product-api.oneflowcloud.com/api/books/5f82acc4783fd8f5ebdcfcb6 POST {{piazza-base}}/api/books/{{bookId}}
// Response {
|