HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

Update Gift Quantity

Function

To update quantity of gifts with open API
透過open API 更新贈品數量

URL

PUT <<api_domain>>/v1/gifts/:id/update_quantity

Request parameters

ParameterValueDescriptionExample
idStringGift's ID
贈品ID
quantityNumberQuantity
(新增/減少)贈品數量
-
*if replace sets as false, allows quantity to be negative number
如果 replace 為 false,准許 quantity 為負數
ruby "quantity"=10
replaceBooleanWhether replacing the original quantity
是否取代原本數量
-
true: replace the quantity with the number you provided
取代原本數量

false: increase/decrease the quantity with the number you provided
增加/減少數量

*Default: true
Default value is true.
ruby "replace":false

Response fields

FieldColumn TypeDescriptionExample
idStringGift's ID
贈品ID
5a8165efe38809548f0000f8
skuStringStock Keeping Unit
贈品貨號
FRU008
quantityNumberGift's Current Quantity
贈品目前庫存
21
updated_atDateTimeLast Updated Time
贈品上次更新時間
2018-02-23T04:17:15.544+00:00

Response Example

{
    "id": "5d8b0a6552910502640e8a76",
    "sku": "GIFT-SKU-0002",
    "quantity": 10,
    "updated_at": "2021-06-25T10:55:07.159+00:00"
}

Sample Request

Update Gift quantity with 10

curl --location --request PUT '<<api_domain>>/v1/gifts/5d8b0a6552910502640e8a76/update_quantity' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ${token}' \
--header 'User-Agent: shopline-test' \
--header 'Content-Type: application/json' \
--data-raw '{
	"quantity": 10,
  "replace": true
}'

increase 3 gift quantity

curl --location --request PUT '<<api_domain>>/v1/gifts/5d8b0a6552910502640e8a76/update_quantity' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ${token}' \
--header 'User-Agent: shopline-test' \
--header 'Content-Type: application/json' \
--data-raw '{
	"quantity": 3,
  "replace": false
}'

decrease 4 gift quantity

curl --location --request PUT 'https://open.shoplineapp.com/v1/gifts/5d8b0a6552910502640e8a76/update_quantity' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ${token}' \
--header 'User-Agent: shopline-test' \
--header 'Content-Type: application/json' \
--data-raw '{
	"quantity": -4,
  "replace": false
}'