Ü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 | Ürün tipi |
vat_rate | VATRate | Hayır | KDV oranı |
price | number | Hayır | Satış fiyatı |
price_currency | Currency | Hayır | Para birimi |
quantity | number | Hayır | Stok miktarı |
Ö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"
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,
});
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
]);
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
})
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" }
});
Yanıt Formatı
{
"success": true,
"data": {
"id": 1,
"name": "Güncellenmiş Ürün",
"code": "URN001",
"barcode": "1234567890",
"description": "Ürün açıklaması",
"product_type": "good",
"price": 150.0,
"price_currency": "TRY",
"vat_rate": 20,
"quantity": 75,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
}
Yanıt Alanları
Alan | Tip | Açıklama |
---|---|---|
id | integer | Ürün ID |
name | string | Ürün adı |
code | string | Ürün kodu |
barcode | string | Barkod numarası |
description | string | Ürün açıklaması |
product_type | string | Ürün tipi |
price | number | Satış fiyatı |
price_currency | string | Para birimi |
vat_rate | integer | KDV oranı |
quantity | number | Stok miktarı |
created_at | string | Oluşturulma tarihi |
updated_at | string | Güncellenme tarihi |
Kurallar
Önemli
- Ürün ID: Güncellenecek ürünün ID'si URL'de belirtilmeli
- En az 1 alan: En az 1 alan güncellenmelidir
- Mevcut ürün: Ürün sistemde mevcut olmalı
- Veri tipleri: Parametreler doğru veri tipinde olmalı