Add-on Tanımları
Katalogdaki add-on tanımlarını, seçeneklerini, ikonlarını ve kategorilerini yöneten on bir uç.
Genel Bakış
Add-on tanımı, bir ürünün yanında satılan seçeneğin şablonudur: ek disk, otomatik yedekleme, ek lisans. Müşterinin hizmetine eklenmiş olan add-on bundan farklı bir şeydir; burada katalogdaki tanımı yönetirsiniz.
Bir tanımın içinde seçenekler vardır ve asıl fiyat oradadır. Seçenekler dil altında yaşar, çünkü adları çevrilir; fiyat ise para birimi başına ayrı tutulur.
Son dört uç add-on kategorilerini yönetir. Kategori tek başına bir şey yapmaz, add-on kataloğunu düzenler.
Referans
Add-on Tanımlarını Listeleme
Katalogdaki add-on tanımlarını döndürür.
active ya da inactive.font ya da image.curl -G 'https://panel.ornek.com/api/v1/admin/products/addons' \
-H "Authorization: Bearer $API_KEY" \
-d group=hostingconst url = new URL('https://panel.ornek.com/api/v1/admin/products/addons');
url.searchParams.set('group', 'hosting');
const res = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });
const body = await res.json();$url = 'https://panel.ornek.com/api/v1/admin/products/addons?' . http_build_query(['group' => 'hosting']);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->GetProductAddons([], ['group' => 'hosting']);Add-on Detayı
Bir add-on tanımını tüm ayarları, kuralları ve her dildeki seçenekleriyle döndürür.
active ya da inactive.{id, type}.font ya da image.select, quantity, checkbox ya da radio.day, month ya da year.{enabled, amount} nesnesine eşleme. Çok para birimli şekilde gelir.curl 'https://panel.ornek.com/api/v1/admin/products/addons/148' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addons/148', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addons/148');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->GetProductAddon(['id' => 148]);
// Fiyat iki sekilde gelebilir; ikisini de karsilayin.
$option = $response['data']['langs']['en']['options'][0];
$price = $option['pricing']['1']['amount'] ?? $option['amount'] ?? 0;{
"data": {
"id": 148,
"group": "server",
"category": 296,
"status": "active",
"type": "select",
"properties": { "show_by_pp": 1, "multiple_purchases": 0 },
"requirement_ids": [],
"product_link": { "id": 0, "type": "" },
"langs": {
"en": {
"name": "Automated Backups",
"description": "Keeps daily backups.",
"options": [
{
"id": 0,
"name": "I want",
"period": "month",
"period_time": 1,
"amount": 2,
"cid": 5,
"module": {
"HetznerCloud": { "configurable": { "backup": 1 } }
}
}
]
}
}
}
}Add-on Tanımı Oluşturma
Katalogda yeni bir add-on tanımı açar.
active ya da inactive.select, checkbox, radio ya da quantity.font ya da image.201 ile döner. Detay ucuyla aynı şekildedir.group boş.category boş.curl -X POST 'https://panel.ornek.com/api/v1/admin/products/addons' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"group":"hosting","category":12,"type":"select","name":{"en":"Extra Disk"},"options":{"o1":{"name":{"en":"10 GB"},"pricing":{"1":{"enabled":true,"amount":5}},"cycle":"monthly"}}}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addons', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
group: 'hosting',
category: 12,
type: 'select',
name: { en: 'Extra Disk' },
options: {
o1: {
name: { en: '10 GB' },
pricing: { 1: { enabled: true, amount: 5 } },
cycle: 'monthly',
},
},
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addons');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'group' => 'hosting',
'category' => 12,
'type' => 'select',
'name' => ['en' => 'Extra Disk'],
'options' => [
'o1' => [
'name' => ['en' => '10 GB'],
'pricing' => [1 => ['enabled' => true, 'amount' => 5]],
'cycle' => 'monthly',
],
],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->CreateProductAddon([
'group' => 'hosting',
'category' => 12,
'type' => 'select',
'name' => ['en' => 'Extra Disk'],
'options' => [
'o1' => [
'name' => ['en' => '10 GB'],
'pricing' => [1 => ['enabled' => true, 'amount' => 5]],
'cycle' => 'monthly',
],
],
]);Add-on Tanımını Güncelleme
Gönderdiğiniz alanları uygular. Seçenekleri gönderirseniz set olduğu gibi değişir. Tüm gövde alanları opsiyoneldir. Aktif, onay bekleyen ya da askıya alınmış hizmetlerin kullandığı seçenek kilitlidir: gönderdiğiniz set onu aynı ödeme dönemiyle içermelidir.
active ya da inactive.select, checkbox, radio ya da quantity.font ya da image.removed ya da cycle. Hiçbir şey yazılmaz.curl -X PATCH 'https://panel.ornek.com/api/v1/admin/products/addons/131' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"status":"inactive"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addons/131', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ status: 'inactive' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addons/131');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['status' => 'inactive']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Tek bir secenegin fiyatini degistirmek icin bile TUM seti gonderin.
$addon = Api::Products()->GetProductAddon(['id' => 131])['data'];
$options = $addon['langs']['en']['options'];
// ... $options uzerinde degisiklik ...
Api::Products()->UpdateProductAddon([
'id' => 131,
'options' => $options,
]);Add-on Tanımını Silme
Add-on tanımını siler. Dil kayıtları da gider.
gate:product.addon_delete kancası işlemi veto etti.curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/addons/131' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addons/131', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addons/131');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteProductAddon(['id' => 131]);Add-on İkonu Yükleme
Add-on ikonunu yükler. Görsel dosyalar ve SVG kabul edilir.
curl -X POST 'https://panel.ornek.com/api/v1/admin/products/addons/131/icon' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"image":"data:image/png;base64,iVBORw0KGgo..."}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addons/131/icon', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ image: 'data:image/png;base64,iVBORw0KGgo...' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addons/131/icon');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'image' => 'data:image/svg+xml;base64,' . base64_encode($svg),
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->UploadAddonIcon([
'id' => 131,
'image' => 'data:image/svg+xml;base64,' . base64_encode($svg),
]);Add-on İkonunu Silme
Yüklenmiş ikon görselini kaldırır.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/addons/131/icon' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addons/131/icon', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addons/131/icon');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteProductAddonIcon(['id' => 131]);Kategorileri Listeleme
Add-on kategorilerini döndürür.
curl 'https://panel.ornek.com/api/v1/admin/products/addon-categories' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addon-categories', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addon-categories');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->GetAddonCategories();Kategori Oluşturma
Add-on kategorisi açar.
title boş.gate:product.category_save kancası işlemi veto etti.curl -X POST 'https://panel.ornek.com/api/v1/admin/products/addon-categories' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title":"Resources","rank":1}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addon-categories', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'Resources', rank: 1 }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addon-categories');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['title' => 'Resources', 'rank' => 1]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$category = Api::Products()->CreateAddonCategory(['title' => 'Resources']);
Api::Products()->CreateProductAddon([
'group' => 'hosting',
'category' => $category['data']['id'],
'name' => ['en' => 'Extra Disk'],
]);Kategoriyi Güncelleme
Kategorinin başlığını, üstünü ya da sırasını değiştirir.
parent_id.curl -X PATCH 'https://panel.ornek.com/api/v1/admin/products/addon-categories/12' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title":"System Resources","rank":2}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addon-categories/12', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'System Resources', rank: 2 }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addon-categories/12');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['title' => 'System Resources', 'rank' => 2]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Bos govde 'no_changes' ile doner — degisen alan yoksa hic cagirmayin.
$response = Api::Products()->UpdateAddonCategory([
'id' => 12,
'title' => 'System Resources',
]);Kategoriyi Silme
Add-on kategorisini siler.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/addon-categories/12' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/addon-categories/12', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/addon-categories/12');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteAddonCategory(['id' => 12]);Tuzaklar
Güncelleme gövdesinde options varsa mevcut seçeneklerin tamamı her dilde silinip yerine gönderdiğiniz set yazılır. Tek bir seçeneğin fiyatını değiştirmek için önce detayı okuyun, seti bütün olarak geri gönderin. Alanı hiç göndermemek seçenekleri korur.
Bir seçenek ya düz bir tutar ve para birimi kimliği taşır, ya da para birimi başına {enabled, amount} nesnelerinden oluşan bir eşleme. Hangisinin geleceği kaydın nasıl yazıldığına bağlıdır; okuyan kod ikisini de karşılamalıdır.
Seçenekler dil nesnesinin içinde yaşar, yani her dilde ayrı bir kopyası vardır. Bir dile seçenek ekleyip diğerine eklememek, o dili kullanan müşteride seçeneğin görünmemesine yol açar.
Kategori güncellemesi düzenlenebilir hiçbir alan taşımayan bir gövdeyi kabul etmez ve no_changes döndürür. Değişiklik yoksa isteği hiç göndermemek gerekir.
İlgili Makaleler
Geri bildiriminiz için teşekkürler!
Yukarıda bulamadığınız her şey için destek ekibimiz her zaman yanınızda.