Adres Defteri
Hesabın fatura profillerini yöneten altı uç.
Genel Bakış
Adres defteri hesabın fatura profillerini tutar. Her kayıt bir kişiyi, bir adresi ve o adrese düşen vergi oranını taşır; faturalar buradan kesilir.
Bir profil her zaman varsayılan olur ve hesap asla varsayılansız kalmaz: ilk eklenen kendiliğinden varsayılan olur, varsayılan silinirse sıradaki terfi eder.
Konum alanları başvuru zincirinden doldurulur: ülke kodu, il numarası, şehir numarası. Platformda veri bulunmayan yerde aynı alanlara serbest metin yazılır.
Referans
Adresleri Listeleme
Hesabın fatura profillerini döndürür.
curl 'https://panel.ornek.com/api/v1/client/addresses' \
-H "Authorization: Bearer $CLIENT_KEY"const res = await fetch('https://panel.ornek.com/api/v1/client/addresses', {
headers: { Authorization: `Bearer ${clientKey}` },
});
const { data } = await res.json();
const billing = data.find((a) => a.is_default);$ch = curl_init('https://panel.ornek.com/api/v1/client/addresses');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $clientKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Varsayilan kisi HER ZAMAN ilk siradadir; ayrica aramak yerine ilk kaydi alabilirsiniz.
$rows = Kernel::internal('client:Addresses/GetAddresses', ['owner_id' => $uid])['data'];
$default = $rows[0] ?? null;Tek Adresi Okuma
Hesabın adreslerinden birini döndürür.
curl 'https://panel.ornek.com/api/v1/client/addresses/12' \
-H "Authorization: Bearer $CLIENT_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/client/addresses/${id}`, {
headers: { Authorization: `Bearer ${clientKey}` },
});
if (res.status === 404) return notYours();
const { data } = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/client/addresses/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $clientKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Baskasinin adresi de BULUNAMADI doner: var olup olmadigini bu uctan ogrenemezsiniz.
$a = Kernel::internal('client:Addresses/GetAddress', ['owner_id' => $uid, 'id' => $id]);Adres Ekleme
Hesaba yeni bir fatura profili ekler.
curl -X POST 'https://panel.ornek.com/api/v1/client/addresses' \
-H "Authorization: Bearer $CLIENT_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Jane","surname":"Cooper","email":"[email protected]","country":"TR","state":"34","city":"1441","address":"Sample St 42","zipcode":"34710"}'const res = await fetch('https://panel.ornek.com/api/v1/client/addresses', {
method: 'POST',
headers: {
Authorization: `Bearer ${clientKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Jane', surname: 'Cooper', email: '[email protected]',
country: 'TR', state: String(stateId), city: String(cityId),
address: 'Sample St 42', zipcode: '34710',
}),
});
const { data } = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/client/addresses');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $clientKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($contact),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// ILK adres kendiliginden VARSAYILAN olur; bayrak gondermeseniz de hesap profilsiz kalmaz.
$a = Kernel::internal('client:Addresses/CreateAddress', ['owner_id' => $uid] + $contact)['data'];
$isFirst = $a['is_default'];Adresi Güncelleme
Adresin tamamını yeniden yazar.
curl -X PUT 'https://panel.ornek.com/api/v1/client/addresses/12' \
-H "Authorization: Bearer $CLIENT_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Jane","surname":"Cooper","email":"[email protected]","country":"TR","state":"34","city":"1441","address":"New St 7","zipcode":"34710"}'const cur = await fetch(`https://panel.ornek.com/api/v1/client/addresses/${id}`, {
headers: { Authorization: `Bearer ${clientKey}` },
}).then((r) => r.json());
const body = {
...cur.data,
state: String(cur.data.state.id || cur.data.state.name),
city: String(cur.data.city.id || cur.data.city.name),
address: 'New St 7',
};
await fetch(`https://panel.ornek.com/api/v1/client/addresses/${id}`, {
method: 'PUT',
headers: {
Authorization: `Bearer ${clientKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});$ch = curl_init('https://panel.ornek.com/api/v1/client/addresses/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $clientKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($contact),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Okunan il/sehir NESNEDIR, gonderilen ise DUZ DEGER: geri yazmadan once numarayi cikarin.
$a = Kernel::internal('client:Addresses/GetAddress', ['owner_id' => $uid, 'id' => $id])['data'];
$a['state'] = (string) ($a['state']['id'] ?: $a['state']['name']);
$a['city'] = (string) ($a['city']['id'] ?: $a['city']['name']);
Kernel::internal('client:Addresses/UpdateAddress', ['owner_id' => $uid, 'id' => $id] + $a);Varsayılanı Taşıma
Bu adresi varsayılan fatura profili yapar.
curl -X POST 'https://panel.ornek.com/api/v1/client/addresses/12/default' \
-H "Authorization: Bearer $CLIENT_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/client/addresses/${id}/default`, {
method: 'POST',
headers: { Authorization: `Bearer ${clientKey}` },
});
const { data } = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/client/addresses/' . $id . '/default');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $clientKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Varsayilani DUSURMEK diye bir islem yok: baska bir adresi varsayilan yapmak tek yoldur.
Kernel::internal('client:Addresses/SetDefaultAddress', ['owner_id' => $uid, 'id' => $other]);Adresi Silme
Adresi siler ve gerekiyorsa varsayılanı devreder.
curl -X DELETE 'https://panel.ornek.com/api/v1/client/addresses/12' \
-H "Authorization: Bearer $CLIENT_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/client/addresses/${id}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${clientKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/client/addresses/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $clientKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Varsayilani silmek yasak DEGIL: siradaki adres kendiliginden varsayilana terfi eder.
Kernel::internal('client:Addresses/DeleteAddress', ['owner_id' => $uid, 'id' => $id]);
$now = Kernel::internal('client:Addresses/GetAddresses', ['owner_id' => $uid])['data'][0] ?? null;Tuzaklar
Okuma uçları il ve şehri numara ve ad taşıyan bir nesne olarak döndürür; yazma uçları ise düz bir değer bekler. Okuduğunuz kaydı doğrudan geri göndermek bu iki alanda doğrulama hatası verir. Yazmadan önce numarayı çıkarın, numara sıfırsa adı gönderin.
Güncelleme gövdesi adresin tamamını ister: oluşturmadaki zorunlu alanlar burada da geçerli. Yalnız posta kodunu değiştirmek için bile tam kaydı göndermelisiniz. Tek kolaylık bildirim matrisinde: gönderilmezse kayıtlı değerini korur.
Bir adresi varsayılan yapmak hesabın ülkesini o adresin ülkesine çeker. Ülke ise vergi oranını ve bazı ürünlerin görünürlüğünü belirler, yani basit görünen bu işlem fiyatları etkileyebilir. Farklı ülkedeki bir profili varsayılan yapmadan önce sonucu düşünün.
Yeni bir adres eklerken açık faturaların bu adrese taşınmasını isteyebilirsiniz. İstemezseniz eski adresle kesilmiş faturalar öyle kalır ve müşteri iki farklı adres görür. Vergi numarası değişikliği gibi durumlarda bu bayrağı düşünün.
Başka bir müşterinin adres numarasını sormak 404 döndürür, yetki hatası değil. Bu bilinçli bir seçim; yanıt o numaranın var olup olmadığını da açığa vurmaz. Bulunamadı yanıtını "silinmiş" diye yorumlamayın.
Bildirim tercihleri hem hesap düzeyinde hem kişi düzeyinde tutulur: faturalar bir kişiye, destek başka birine gidebilir. Adres yazarken matris gönderilmezse oluşturmada hepsi açılır, güncellemede ise kayıtlı hâli korunur.
İ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.