curl -X PUT "https://api.playground.try.be/shop/discount-types/00000000-0000-0000-0000-000000000000" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"applicable_for": "app_and_booking_engine",
"code": "SUMMER23",
"description": "For 15% off any order placed from Jun-Aug 2023",
"amount_type": "percentage",
"discount_amount": 15,
"is_custom_amount": false,
"valid_from": "2023-06-01",
"valid_to": "2023-09-01",
"item_date_from": "2023-09-01",
"item_date_to": "2023-09-30",
"item_date_weekdays": [
"monday"
],
"item_time_from": "10:00",
"item_time_to": "14:00",
"valid_offerings": [
{
"offering_type": "appointment",
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8"
}
],
"max_uses": 100000,
"has_been_redeemed": false,
"site_id": "00000000-0000-0000-0000-000000000000"
}'
const response = await fetch('https://api.playground.try.be/shop/discount-types/00000000-0000-0000-0000-000000000000', {
method: 'PUT',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
"applicable_for": "app_and_booking_engine",
"code": "SUMMER23",
"description": "For 15% off any order placed from Jun-Aug 2023",
"amount_type": "percentage",
"discount_amount": 15,
"is_custom_amount": false,
"valid_from": "2023-06-01",
"valid_to": "2023-09-01",
"item_date_from": "2023-09-01",
"item_date_to": "2023-09-30",
"item_date_weekdays": [
"monday"
],
"item_time_from": "10:00",
"item_time_to": "14:00",
"valid_offerings": [
{
"offering_type": "appointment",
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8"
}
],
"max_uses": 100000,
"has_been_redeemed": false,
"site_id": "00000000-0000-0000-0000-000000000000"
}),
})
if (!response.ok) {
throw new Error(`Trybe API ${response.status}: ${await response.text()}`)
}
const data = await response.json()
import httpx
response = httpx.put(
"https://api.playground.try.be/shop/discount-types/00000000-0000-0000-0000-000000000000",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
},
json={
"applicable_for": "app_and_booking_engine",
"code": "SUMMER23",
"description": "For 15% off any order placed from Jun-Aug 2023",
"amount_type": "percentage",
"discount_amount": 15,
"is_custom_amount": False,
"valid_from": "2023-06-01",
"valid_to": "2023-09-01",
"item_date_from": "2023-09-01",
"item_date_to": "2023-09-30",
"item_date_weekdays": [
"monday"
],
"item_time_from": "10:00",
"item_time_to": "14:00",
"valid_offerings": [
{
"offering_type": "appointment",
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8"
}
],
"max_uses": 100000,
"has_been_redeemed": False,
"site_id": "00000000-0000-0000-0000-000000000000"
},
)
response.raise_for_status()
data = response.json()
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('PUT', 'https://api.playground.try.be/shop/discount-types/00000000-0000-0000-0000-000000000000', [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY',
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'json' => [
'applicable_for' => 'app_and_booking_engine',
'code' => 'SUMMER23',
'description' => 'For 15% off any order placed from Jun-Aug 2023',
'amount_type' => 'percentage',
'discount_amount' => 15,
'is_custom_amount' => false,
'valid_from' => '2023-06-01',
'valid_to' => '2023-09-01',
'item_date_from' => '2023-09-01',
'item_date_to' => '2023-09-30',
'item_date_weekdays' => [
'monday'
],
'item_time_from' => '10:00',
'item_time_to' => '14:00',
'valid_offerings' => [
[
'offering_type' => 'appointment',
'offering_id' => '64a9f3b2c3d8e1f4a5b6c7d8'
]
],
'max_uses' => 100000,
'has_been_redeemed' => false,
'site_id' => '00000000-0000-0000-0000-000000000000'
],
]);
$data = json_decode($response->getBody(), true);
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload, _ := json.Marshal(map[string]interface{}{
"applicable_for": "app_and_booking_engine",
"code": "SUMMER23",
"description": "For 15% off any order placed from Jun-Aug 2023",
"amount_type": "percentage",
"discount_amount": 15,
"is_custom_amount": false,
"valid_from": "2023-06-01",
"valid_to": "2023-09-01",
"item_date_from": "2023-09-01",
"item_date_to": "2023-09-30",
"item_date_weekdays": []interface{}{
"monday",
},
"item_time_from": "10:00",
"item_time_to": "14:00",
"valid_offerings": []interface{}{
map[string]interface{}{
"offering_type": "appointment",
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
},
},
"max_uses": 100000,
"has_been_redeemed": false,
"site_id": "00000000-0000-0000-0000-000000000000",
})
req, _ := http.NewRequest("PUT", "https://api.playground.try.be/shop/discount-types/00000000-0000-0000-0000-000000000000", bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
}