Ürün Gereksinimleri
Ürünün sipariş anında sorduğu alanları, kurallarını, ikonlarını ve kategorilerini yöneten on bir uç.
Genel Bakış
Gereksinim, ürünün sipariş anında müşteriden istediği veri alanıdır: sunucu adı, alan adı, lisans anahtarı, kurulum betiği. Add-on'lardan tek bir şeyle ayrılır: fiyatı yoktur. Add-on satılan bir seçenektir, gereksinim sorulan bir sorudur.
Asıl mesele cevabın nereye gittiğidir. module_co_names eşlemesi, müşterinin verdiği cevabın hangi modülde hangi alana düşeceğini belirler; eşleme yoksa cevap saklanır ama hizmet kurulurken kullanılmaz.
Referans
Gereksinimleri Listeleme
Katalogdaki gereksinim tanımlarını döndürür.
active ya da inactive.curl -G 'https://panel.ornek.com/api/v1/admin/products/requirements' \
-H "Authorization: Bearer $API_KEY" \
-d group=serverconst url = new URL('https://panel.ornek.com/api/v1/admin/products/requirements');
url.searchParams.set('group', 'server');
const res = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });
const body = await res.json();$url = 'https://panel.ornek.com/api/v1/admin/products/requirements?' . http_build_query(['group' => 'server']);
$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()->GetProductRequirements([], ['group' => 'server']);Gereksinim Detayı
Bir gereksinimi tüm kuralları, modül eşlemesi ve her dildeki seçenekleriyle döndürür.
active ya da inactive.text, textarea, select, radio, checkbox ya da file.curl 'https://panel.ornek.com/api/v1/admin/products/requirements/42' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirements/42', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirements/42');
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()->GetProductRequirement(['id' => 42]);
// Bos eslesme, cevabin module ULASMAYACAGI anlamina gelir.
$mapped = ($response['data']['module_co_names']['HetznerCloud'] ?? '') !== '';{
"data": {
"id": 42,
"group": "server",
"category": 297,
"status": "active",
"rank": 0,
"module_co_names": { "HetznerCloud": "user_data" },
"type": "textarea",
"properties": { "compulsory": false },
"langs": {
"en": {
"name": "User Data",
"description": "Cloud-init data run at first boot.",
"options": []
}
}
}
}Gereksinim Oluşturma
Katalogda yeni bir gereksinim tanımı açar.
text, textarea, select, radio, checkbox ya da file. Varsayılan text.active ya da inactive.{name, mkey} nesnesine eşleme. Yalnız seçim tiplerinde; göndermek tüm seti değiştirir.group boş.category boş.curl -X POST 'https://panel.ornek.com/api/v1/admin/products/requirements' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"group":"server","category":4,"type":"text","name":{"en":"Server Hostname"},"compulsory":true}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirements', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
group: 'server',
category: 4,
type: 'text',
name: { en: 'Server Hostname' },
compulsory: true,
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirements');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'group' => 'server',
'category' => 4,
'type' => 'text',
'name' => ['en' => 'Server Hostname'],
'compulsory' => true,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Cevabin modulde bir yere dusmesi icin eslemeyi de verin.
$response = Api::Products()->CreateProductRequirement([
'group' => 'server',
'category' => 4,
'type' => 'text',
'name' => ['en' => 'Server Hostname'],
'module_co_names' => ['HetznerCloud' => 'hostname'],
]);Gereksinimi Güncelleme
Gönderdiğiniz alanları uygular, geri kalanını olduğu gibi bırakır. Seçenekleri gönderirseniz set olduğu gibi değişir.
text, textarea, select, radio, checkbox ya da file. Göndermezseniz kayıtlı tip kalır.active ya da inactive.{name, mkey} nesnesine eşleme. Yalnız seçim tiplerinde; göndermek tüm seti değiştirir.curl -X PATCH 'https://panel.ornek.com/api/v1/admin/products/requirements/7' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"status":"inactive","compulsory":false}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirements/7', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ status: 'inactive', compulsory: false }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirements/7');
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',
'compulsory' => false,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Tek bir secenegi degistirmek icin bile TUM seti gonderin.
$req = Api::Products()->GetProductRequirement(['id' => 7])['data'];
$options = $req['langs']['en']['options'];
// ... $options uzerinde degisiklik ...
Api::Products()->UpdateProductRequirement([
'id' => 7,
'options' => $options,
]);Gereksinimi Silme
Gereksinim tanımını siler. Dil kayıtları da gider.
gate:product.requirement_delete kancası işlemi veto etti.curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/requirements/7' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirements/7', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirements/7');
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()->DeleteProductRequirement(['id' => 7]);Gereksinim İkonu Yükleme
Gereksinim ikonunu yükler. Görsel dosyalar ve SVG kabul edilir.
curl -X POST 'https://panel.ornek.com/api/v1/admin/products/requirements/7/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/requirements/7/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/requirements/7/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()->UploadRequirementIcon([
'id' => 7,
'image' => 'data:image/svg+xml;base64,' . base64_encode($svg),
]);Gereksinim İkonunu Silme
Yüklenmiş ikon görselini kaldırır.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/requirements/7/icon' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirements/7/icon', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirements/7/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()->DeleteProductRequirementIcon(['id' => 7]);Kategorileri Listeleme
Gereksinim kategorilerini döndürür.
curl 'https://panel.ornek.com/api/v1/admin/products/requirement-categories' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirement-categories', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirement-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()->GetRequirementCategories();Kategori Oluşturma
Gereksinim 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/requirement-categories' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title":"Server Info","rank":1}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirement-categories', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'Server Info', rank: 1 }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirement-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' => 'Server Info', 'rank' => 1]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$category = Api::Products()->CreateRequirementCategory(['title' => 'Server Info']);
Api::Products()->CreateProductRequirement([
'group' => 'server',
'category' => $category['data']['id'],
'name' => ['en' => 'Server Hostname'],
]);Kategoriyi Güncelleme
Kategorinin başlığını, üstünü ya da sırasını değiştirir.
curl -X PATCH 'https://panel.ornek.com/api/v1/admin/products/requirement-categories/4' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title":"Server Details"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirement-categories/4', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'Server Details' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirement-categories/4');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['title' => 'Server Details']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->UpdateRequirementCategory([
'id' => 4,
'title' => 'Server Details',
]);Kategoriyi Silme
Gereksinim kategorisini siler.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/requirement-categories/4' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/requirement-categories/4', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/requirement-categories/4');
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()->DeleteRequirementCategory(['id' => 4]);Tuzaklar
Müşteriye soru sormak yetmez. module_co_names içinde o modül için bir alan adı yoksa cevap kayıtta durur ve hizmet kurulurken hiç kullanılmaz. Hata da alınmaz: sunucu yanlış adla kurulur ve sebebi görünmez. Gereksinimi açarken eşlemeyi de verin.
Güncelleme gövdesinde options varsa mevcut seçeneklerin tamamı her dilde silinip yerine gönderdiğiniz set yazılır. Alanı hiç göndermemek seçenekleri korur.
En büyük dosya boyutu ve izinli uzantılar yalnız dosya tipinde, seçenekler yalnız seçim tiplerinde anlam taşır. Yanlış tipe gönderilen bir kural hata vermez; sessizce saklanır ve hiçbir zaman uygulanmaz.
Zorunlu işaretli bir gereksinim boş bırakıldığında sipariş tamamlanmaz. Var olan bir ürüne sonradan zorunlu gereksinim eklemek, o üründen alışverişi o an için durdurur; eklemeden önce vitrinde sorulacak sorunun cevaplanabilir olduğundan emin olun.
İ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.