Ürün/Hizmet Güncelleme
Mevcut ürün/hizmet kaydını güncelleme.
Endpoint
PUT /kolaybi/v1/products/{product_id}
Parametreler
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
name | string | Evet | Ürün adı |
code | string | Hayır | Ürün kodu |
barcode | string | Hayır | Barkod numarası |
description | string | Hayır | Ürün açıklaması |
product_type | ProductType | Hayır | Varsayılan good |
vat_rate | VATRate | Hayır | Varsayılan 20 |
price | number | Hayır | Satış fiyatı |
price_currency | Currency | Hayır | Satış para birimi |
quantity | number | Hayır | Stok miktarı |
discount_type | string | Hayır | percentage (varsayılan) veya numeric |
discount_value | number | Hayır | İndirim tutarı / yüzdesi |
tags | array | Hayır | Etiket ID listesi (tags[0], tags[1]) |
Örnekler
- cURL
- JavaScript
- PHP
- Python
- C#
# Temel ürün güncelleme
curl -X PUT "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products/1" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "name=Güncellenmiş Ürün Adı"
# Detaylı ürün güncelleme
curl -X PUT "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products/1" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "name=Güncellenmiş Ürün&code=URN001&barcode=1234567890&product_type=good&vat_rate=20&price=150.00&price_currency=try&quantity=75&discount_type=percentage&discount_value=5&tags[0]=12"
async function updateProduct(productId, data) {
const formData = new URLSearchParams(data);
const response = await fetch(
`https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products/${productId}`,
{
method: "PUT",
headers: {
Authorization: `Bearer ${accessToken}`,
Channel: channel,
"Content-Type": "application/x-www-form-urlencoded",
},
body: formData,
}
);
return await response.json();
}
// Temel kullanım
const product = await updateProduct(1, {
name: "Güncellenmiş Ürün Adı",
});
// Detaylı kullanım
const detailedProduct = await updateProduct(1, {
name: "Güncellenmiş Ürün",
code: "URN001",
barcode: "1234567890",
product_type: "good",
vat_rate: 20,
price: 150.0,
price_currency: "try",
quantity: 75,
discount_type: "percentage",
discount_value: 5,
"tags[0]": 12,
});
function updateProduct($productId, $data) {
$url = "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products/{$productId}";
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Channel: ' . $channel,
'Content-Type: application/x-www-form-urlencoded'
],
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Temel kullanım
$product = updateProduct(1, [
'name' => 'Güncellenmiş Ürün Adı'
]);
// Detaylı kullanım
$detailedProduct = updateProduct(1, [
'name' => 'Güncellenmiş Ürün',
'code' => 'URN001',
'barcode' => '1234567890',
'product_type' => 'good',
'vat_rate' => 20,
'price' => 150.00,
'price_currency' => 'try',
'quantity' => 75,
'discount_type' => 'percentage',
'discount_value' => 5,
'tags[0]' => 12
]);
import requests
def update_product(product_id, data):
url = f"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products/{product_id}"
headers = {
"Authorization": f"Bearer {access_token}",
"Channel": channel,
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.put(url, headers=headers, data=data)
return response.json()
# Temel kullanım
product = update_product(1, {
"name": "Güncellenmiş Ürün Adı"
})
# Detaylı kullanım
detailed_product = update_product(1, {
"name": "Güncellenmiş Ürün",
"code": "URN001",
"barcode": "1234567890",
"product_type": "good",
"vat_rate": 20,
"price": 150.00,
"price_currency": "try",
"quantity": 75,
"discount_type": "percentage",
"discount_value": 5,
"tags[0]": 12
})
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
async Task<dynamic> UpdateProductAsync(int productId, Dictionary<string, string> data)
{
using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put,
$"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products/{productId}")
{
Content = new FormUrlEncodedContent(data)
};
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
request.Headers.Add("Channel", channel);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<dynamic>(content);
}
// Temel kullanım
var product = await UpdateProductAsync(1, new Dictionary<string, string>
{
{ "name", "Güncellenmiş Ürün Adı" }
});
// Detaylı kullanım
var detailedProduct = await UpdateProductAsync(1, new Dictionary<string, string>
{
{ "name", "Güncellenmiş Ürün" },
{ "code", "URN001" },
{ "barcode", "1234567890" },
{ "product_type", "good" },
{ "vat_rate", "20" },
{ "price", "150.00" },
{ "price_currency", "try" },
{ "quantity", "75" },
{ "discount_type", "percentage" },
{ "discount_value", "5" },
{ "tags[0]", "12" }
});
Yanıt Formatı
{
"data": {
"id": 1,
"product_type": "good",
"name": "Güncellenmiş Ürün",
"code": "URN001",
"vat_type": "PERCENTAGE",
"vat_value": 20,
"barcode": "1234567890",
"description": "Ürün açıklaması",
"discount_type": "PERCENTAGE",
"discount_value": 5,
"stock_unit": 1,
"stock_multiplier": 1,
"purchase_unit": 1,
"purchase_stock_multiplier": 1,
"purchase_unit_description": "kutu",
"purchase_price": 90,
"purchase_currency": "try",
"sale_unit": 1,
"sale_stock_multiplier": 1,
"sale_unit_description": "adet",
"sale_price": 150,
"sale_currency": "try",
"total_stock_quantity": 75,
"tags": [
{
"id": 12,
"name": "e-ticaret"
}
]
}
}
Yanıt Alanları
| Alan | Tip | Açıklama |
|---|---|---|
id | integer | Ürün ID |
product_type | string | good / service |
name | string | Ürün adı |
code | string | Ürün kodu |
vat_type | string | KDV tipi (PERCENTAGE, NUMERIC) |
vat_value | number | KDV oranı |
barcode | string | Barkod |
description | string | Ürün açıklaması |
discount_type | string | İndirim tipi |
discount_value | number | İndirim değeri |
stock_unit | number | Stok birimi |
stock_multiplier | number | Stok birim çarpanı |
purchase_unit | number | Alış birimi |
purchase_stock_multiplier | number | Alış birim çarpanı |
purchase_unit_description | number | Alış birim açıklaması |
purchase_price | number | Alış fiyatı |
purchase_currency | number | Alış para birimi |
sale_unit | number | Satış birimi |
sale_stock_multiplier | number | Satış birim çarpanı |
sale_unit_description | number | Satış birim açıklaması |
sale_price | number | Satış fiyatı |
sale_currency | number | Satış para birimi |
total_stock_quantity | number | Güncel stok miktarı |
tags | array | Ürüne bağlı etiketler |
Etiket Alanları (tags)
| Alan | Tip | Açıklama |
|---|---|---|
id | integer | Etiket ID değeri |
name | string | Etiket adı |
description | string | Etiket açıklaması (varsa) |