Purchasing API
...
Purchasing
Create/Update Purchase
code examples curl location globoff request put '/api/v1/purchases/{lookupby}/{identifier}' \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ data '{ "type" "order", "purchase identifiers" { "sparklayer" "63428136 658f 48a6 beb7 7f333dfd9686" }, "customer identifiers" {}, "dates" {}, "calculated total" { "number" "15 99", "currency" "gbp" }, "calculated total usd" { "number" "15 99", "currency" "gbp" }, "billing address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "packages" { "identifiers" { "sparklayer package id" "63428136 658f 48a6 beb7 7f333dfd9686" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "line items" \[ { "identifiers" {}, "name parent" "t shirt", "quantity" 4, "custom attributes" \[ { "key" "mug text", "value" "best company ever" } ], "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } } ], "shipping method" { "name" "standard shipping", "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } }, "shipping address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "shipments" \[ { "carrier" "carrier company ltd", "carrier id" "" } ], "type" "" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "custom fields" \[ { "name" "delivery date" } ], "metadata" \[ { "name" "example key", "value" "1234" } ] }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); var raw = json stringify({ "type" "order", "purchase identifiers" { "sparklayer" "63428136 658f 48a6 beb7 7f333dfd9686" }, "customer identifiers" {}, "dates" {}, "calculated total" { "number" "15 99", "currency" "gbp" }, "calculated total usd" { "number" "15 99", "currency" "gbp" }, "billing address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "packages" { "identifiers" { "sparklayer package id" "63428136 658f 48a6 beb7 7f333dfd9686" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "line items" \[ { "identifiers" {}, "name parent" "t shirt", "quantity" 4, "custom attributes" \[ { "key" "mug text", "value" "best company ever" } ], "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } } ], "shipping method" { "name" "standard shipping", "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } }, "shipping address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "shipments" \[ { "carrier" "carrier company ltd", "carrier id" "" } ], "type" "" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "custom fields" \[ { "name" "delivery date" } ], "metadata" \[ { "name" "example key", "value" "1234" } ] }); var requestoptions = { method 'put', headers myheaders, body raw, redirect 'follow' }; fetch("/api/v1/purchases/{lookupby}/{identifier}", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("/api/v1/purchases/{lookupby}/{identifier}") http = net http new(url host, url port); request = net http put new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request body = json dump({ "type" "order", "purchase identifiers" { "sparklayer" "63428136 658f 48a6 beb7 7f333dfd9686" }, "customer identifiers" {}, "dates" {}, "calculated total" { "number" "15 99", "currency" "gbp" }, "calculated total usd" { "number" "15 99", "currency" "gbp" }, "billing address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "packages" { "identifiers" { "sparklayer package id" "63428136 658f 48a6 beb7 7f333dfd9686" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "line items" \[ { "identifiers" {}, "name parent" "t shirt", "quantity" 4, "custom attributes" \[ { "key" "mug text", "value" "best company ever" } ], "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } } ], "shipping method" { "name" "standard shipping", "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } }, "shipping address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "shipments" \[ { "carrier" "carrier company ltd", "carrier id" "" } ], "type" "" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "custom fields" \[ { "name" "delivery date" } ], "metadata" \[ { "name" "example key", "value" "1234" } ] }) response = http request(request) puts response read body import requests import json url = "/api/v1/purchases/{lookupby}/{identifier}" payload = json dumps({ "type" "order", "purchase identifiers" { "sparklayer" "63428136 658f 48a6 beb7 7f333dfd9686" }, "customer identifiers" {}, "dates" {}, "calculated total" { "number" "15 99", "currency" "gbp" }, "calculated total usd" { "number" "15 99", "currency" "gbp" }, "billing address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "packages" { "identifiers" { "sparklayer package id" "63428136 658f 48a6 beb7 7f333dfd9686" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "line items" \[ { "identifiers" {}, "name parent" "t shirt", "quantity" 4, "custom attributes" \[ { "key" "mug text", "value" "best company ever" } ], "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } } ], "shipping method" { "name" "standard shipping", "line total" { "total net" { "number" "15 99", "currency" "gbp" }, "discount net" { "number" "15 99", "currency" "gbp" } } }, "shipping address" { "address line1" "7 philosophy way", "city" "willerby", "country code" "gb" }, "shipments" \[ { "carrier" "carrier company ltd", "carrier id" "" } ], "type" "" }, "accounting files" \[ { "identifiers" { "visible" "inv011" }, "data" { "type" "uri" }, "file type" "invoice" } ], "custom fields" \[ { "name" "delivery date" } ], "metadata" \[ { "name" "example key", "value" "1234" } ] }) headers = { 'accept' 'application/json', 'content type' 'application/json' } response = requests request("put", url, headers=headers, data=payload) print(response text) responses { "type" "order", "purchase identifiers" { "sparklayer" "63428136 658f 48a6 beb7 7f333dfd9686", "platform" "123456789", "internal" "", "visible" "b2b01123" }, "customer identifiers" { "sparklayer" "cu 123", "sparklayer impersonator" "cu 123", "sparklayer child" "cu 123" }, "payment method" "", "dates" { "created at" "2020 01 01t00 00 00+02 00", "updated at" "2020 01 01t00 00 00+02 00", "placed at" "2020 01 01t00 00 00+02 00", "calculated submitted at" "2020 01 01t00 00 00+02 00" }, "customer reference" "po number", "currency code" "gbp", "calculated shipping address" "john spark, sparklayer, sparklayer hq, example city, 12345", "calculated total" {}, "calculated total usd" {}, "calculated fulfilment status" "processing", "revision date" "2020 01 01t00 00 00+02 00", "billing address" { "name" "tom jones", "company" "tom jones hardware ltd", "address line1" "7 philosophy way", "address line2" "", "city" "willerby", "region code" "", "postal code" "bj6 9mk", "country code" "gb", "phone" "0123456789", "sparklayer id" "ca 100" }, "packages" {}, "accounting files" \[ { "identifiers" { "internal" "inv011", "visible" "" }, "data" {}, "file type" "invoice" } ], "custom fields" \[ { "name" "delivery date", "value" "2023 10 28" } ], "metadata" \[ { "name" "example key", "value" "1234" } ] }// trying to update purchase sparklayer id, which is immutable // error response // a conflict has occurred // error response