Evaluate promotions - Fabric
Evaluate promotions
cURL
curl --request POST \
--url https://live.copilot.fabric.inc/v1/promo/evaluate-promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"hierarchy": [
[
"clothingId1",
"footwear",
"sandalsId1"
],
[
"nike",
"sandalsId2"
],
[
"clothingId2",
"beach"
]
],
"productAttributes": {
"color": [
"red",
"green"
],
"brand": "Nike",
"size": "10"
},
"priceParams": {
"options": {
"length": "2",
"width": "15",
"blindMotor": true
}
},
"price": {
"sale": 10,
"base": 123
},
"channel": [
12,
15
],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": true,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": [
"SUPERCOUPON1",
"FIRSTPURCHASE10"
],
"shipping": [
{
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"date": "2019-08-24T14:15:22Z",
"userProfile": {
"Customer Type": [
"Wholesale"
]
}
}
'
Python
import requests
url = "https://live.copilot.fabric.inc/v1/promo/evaluate-promotions"
payload = {
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": ["5e2cfb9b45570b000863c4b5"],
"hierarchy": [[
"clothingId1",
"footwear",
"sandalsId1"
], [
"nike",
"sandalsId2"
], [
"clothingId2",
"beach"
]],
"productAttributes": {
"color": ["red", "green"],
"brand": "Nike",
"size": "10"
},
"priceParams": { "options": {
"length": "2",
"width": "15",
"blindMotor": True
} },
"price": {
"sale": 10,
"base": 123
},
"channel": [12, 15],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": True,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": ["SUPERCOUPON1", "FIRSTPURCHASE10"],
"shipping": [{
"shippingMethodId": 123,
"shippingPrice": 20
}],
"date": "2019-08-24T14:15:22Z",
"userProfile": { "Customer Type": ["Wholesale"] }
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript
const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
items: [
{
priceList: 100275,
quantity: 5,
lineItemId: 1,
sku: 1111111,
itemId: 1111111,
group: ['5e2cfb9b45570b000863c4b5'],
hierarchy: [
['clothingId1', 'footwear', 'sandalsId1'],
['nike', 'sandalsId2'],
['clothingId2', 'beach']
],
productAttributes: {color: ['red', 'green'], brand: 'Nike', size: '10'},
priceParams: {options: {length: '2', width: '15', blindMotor: true}},
price: {sale: 10, base: 123},
channel: [12, 15],
shippingMethodId: 123,
shippingPrice: 20
}
],
traceId: '394823457',
isLoggedIn: true,
userId: '5e2cfb9b45570b000864c4b5',
promoCodes: ['SUPERCOUPON1', 'FIRSTPURCHASE10'],
shipping: [{shippingMethodId: 123, shippingPrice: 20}],
date: '2019-08-24T14:15:22Z',
userProfile: {'Customer Type': ['Wholesale']}
})
};
fetch('https://live.copilot.fabric.inc/v1/promo/evaluate-promotions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://live.copilot.fabric.inc/v1/promo/evaluate-promotions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'priceList' => 100275,
'quantity' => 5,
'lineItemId' => 1,
'sku' => 1111111,
'itemId' => 1111111,
'group' => [
'5e2cfb9b45570b000863c4b5'
],
'hierarchy' => [
[
'clothingId1',
'footwear',
'sandalsId1'
],
[
'nike',
'sandalsId2'
],
[
'clothingId2',
'beach'
]
],
'productAttributes' => [
'color' => [
'red',
'green'
],
'brand' => 'Nike',
'size' => '10'
],
'priceParams' => [
'options' => [
'length' => '2',
'width' => '15',
'blindMotor' => true
]
],
'price' => [
'sale' => 10,
'base' => 123
],
'channel' => [
12,
15
],
'shippingMethodId' => 123,
'shippingPrice' => 20
]
],
'traceId' => '394823457',
'isLoggedIn' => true,
'userId' => '5e2cfb9b45570b000864c4b5',
'promoCodes' => [
'SUPERCOUPON1',
'FIRSTPURCHASE10'
],
'shipping' => [
[
'shippingMethodId' => 123,
'shippingPrice' => 20
]
],
'date' => '2019-08-24T14:15:22Z',
'userProfile' => [
'Customer Type' => [
'Wholesale'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://live.copilot.fabric.inc/v1/promo/evaluate-promotions"
payload := strings.NewReader(`{
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"hierarchy": [
[
"clothingId1",
"footwear",
"sandalsId1"
],
[
"nike",
"sandalsId2"
],
[
"clothingId2",
"beach"
]
],
"productAttributes": {
"color": [
"red",
"green"
],
"brand": "Nike",
"size": "10"
},
"priceParams": {
"options": {
"length": "2",
"width": "15",
"blindMotor": true
}
},
"price": {
"sale": 10,
"base": 123
},
"channel": [
12,
15
],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": true,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": [
"SUPERCOUPON1",
"FIRSTPURCHASE10"
],
"shipping": [
{
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"date": "2019-08-24T14:15:22Z",
"userProfile": {
"Customer Type": [
"Wholesale"
]
}
}`)
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Unirest
HttpResponse<String> response = Unirest.post("https://live.copilot.fabric.inc/v1/promo/evaluate-promotions")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body(`{
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"hierarchy": [
[
"clothingId1",
"footwear",
"sandalsId1"
],
[
"nike",
"sandalsId2"
],
[
"clothingId2",
"beach"
]
],
"productAttributes": {
"color": [
"red",
"green"
],
"brand": "Nike",
"size": "10"
},
"priceParams": {
"options": {
"length": "2",
"width": "15",
"blindMotor": true
}
},
"price": {
"sale": 10,
"base": 123
},
"channel": [
12,
15
],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": true,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": [
"SUPERCOUPON1",
"FIRSTPURCHASE10"
],
"shipping": [
{
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"date": "2019-08-24T14:15:22Z",
"userProfile": {
"Customer Type": [
"Wholesale"
]
}
}`)
.asString();