381 | * @param Class $client
382 | * @param string $mode
383 | *
384 | */
385 | public function setResultMode($client, $mode)
386 | {
387 |
388 | switch ($mode)
389 | {
390 | case 'vmax' : $this->orderMaxResult = 100; break;
391 | case 'max' : $this->orderMaxResult = 75; break;
392 | case 'min' : $this->orderMaxResult = 30; break;
393 | case 'medium' :
394 | default:
395 | $this->orderMaxResult = 50;
396 | break;
397 | }
398 |
399 | }
400 |
401 | }
402 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 İsmail Satilmis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://packagist.org/packages/ismail0234/n11-php-api)
2 | [](https://packagist.org/packages/ismail0234/n11-php-api)
3 | [](https://packagist.org/packages/ismail0234/n11-php-api)
4 |
5 | # N11 PHP API
6 |
7 | Bu API n11 için yazılmıştır. N11 için yazılmış olan gelişmiş bir php entegrasyon API'si. Ekstra olarak n11 üzerinde mağazanıza gelen siparişleri websitenize aktaracak bir fonksiyonda mevcuttur.
8 |
9 | ## Bağış Yapın
10 |
11 | Yaptığım işlerden memnun iseniz, daha iyi ve daha çok iş çıkartmam için beni destekleyebilirsiniz;
12 |
13 | ## Katkı Çağrısı (Katkıda Bulunanlar)
14 |
15 | Çok fazla vaktim olmadığından N11'in bütün API fonksiyonları tamamlanmamıştır. Eksik fonksiyonları isterseniz tamamlayarak **pull request** gönderebilirsiniz veya istediğiniz fonksiyonun eklenmesi için **issue** açabilirsiniz.
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | ### Change Log
26 | - See [ChangeLog](https://github.com/ismail0234/n11-php-api/blob/master/CHANGELOG.md)
27 |
28 | ### License
29 | - See [ChangeLog](https://github.com/ismail0234/n11-php-api/blob/master/LICENSE)
30 |
31 | ## Hızlı Bakış
32 | * [Kurulum](#kurulum)
33 | * [Kullanım](#kullanım)
34 | * [Şehir Servisleri (CityService)](#şehir-servisleri-cityservice)
35 | * [Kargo Şirketi Servisleri (ShipmentCompanyService)](#kargo-şirketi-servisleri-shipmentcompanyservice)
36 | * [Kategori Servisi (CategoryService)](#kategori-servisi-categoryservice)
37 | * [Ürün Servisi (ProductService)](#ürün-servisi-productservice)
38 | * [Ürün Satış Durumu Servisi (ProductSellingService)](#ürün-satış-durumu-servisi-productsellingservice)
39 | * [Ürün Stok Servisi (ProductStockService)](#ürün-stok-servisi-productstockservice)
40 | * [Sipariş Servisi (Order Service)](#sipariş-servisi-order-service)
41 | * [N11 Sipariş Bildirimi WebHook (N11 Order WebHook Beta)](#n11-sipariş-bildirimi-webhook-n11-order-webhook-beta)
42 |
43 | ## Kurulum
44 |
45 | Kurulum için composer kullanmanız gerekmektedir. Composer'a sahip değilseniz windows için [Buradan](https://getcomposer.org/) indirebilirsiniz.
46 |
47 | ```php
48 |
49 | composer require ismail0234/n11-php-api
50 |
51 | ```
52 |
53 | ## Kullanım
54 |
55 | ```php
56 |
57 | use IS\PazarYeri\N11\N11Client;
58 |
59 | include "vendor/autoload.php";
60 |
61 | $client = new N11Client();
62 | $client->setApiKey('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
63 | $client->setApiPassword('xxxxxxxxxxxxxxxx');
64 | ```
65 |
66 | ### Şehir Servisleri (CityService)
67 |
68 | ```php
69 |
70 | /**
71 | *
72 | * @description N11 Üzerindeki bütün şehirlerin listesini döndürür.
73 | *
74 | */
75 | $client->city->getCities();
76 |
77 | /**
78 | *
79 | * @description Şehir hakkında birkaç bilgi döndürür.
80 | * @param int Şehir Id - Zorunlu
81 | *
82 | */
83 | $client->city->getCity(34);
84 |
85 | /**
86 | *
87 | * @description Plaka kodu verilen şehre ait ilçelerinin listelenmesi için kullanılır.
88 | * @param int Şehir Id - Zorunlu
89 | *
90 | */
91 | $client->city->getDistrict(34);
92 |
93 | /**
94 | *
95 | * @description İlçe kodu verilen semt/mahallelerin listelenmesi için kullanılır.
96 | * @param int İlçe Id - Zorunlu
97 | *
98 | */
99 | $client->city->getNeighborhoods(22569);
100 | ```
101 |
102 | ### Kargo Şirketi Servisleri (ShipmentCompanyService)
103 |
104 | ```php
105 |
106 | /**
107 | *
108 | * @description N11 Üzerinde tanımlı olan tüm kargo şirketlerini listeler
109 | *
110 | */
111 | $client->shipmentcompany->getShipmentCompanies();
112 | ```
113 |
114 | ### Teslimat Şablonu Servisi (ShipmentService)
115 |
116 | ```php
117 |
118 | /**
119 | *
120 | * @description Oluşturulan teslimat şablonu bilgilerini listelemek için kullanılan metoddur.
121 | *
122 | */
123 | $client->shipment->getShipmentTemplateList();
124 |
125 | /**
126 | *
127 | * @description Teslimat şablon ismi ile aratılan şablonun bilgilerini döndürür.
128 | * @param string Şablon Adı - Zorunlu
129 | *
130 | */
131 | $client->shipment->getShipmentTemplate('Ücretsiz Kargo');
132 | ```
133 |
134 | ### Kategori Servisi (CategoryService)
135 |
136 | ```php
137 |
138 | /**
139 | *
140 | * @description N11 üzerinde tanımlanmış tüm üst seviye kategorileri döndürür.
141 | *
142 | */
143 | $client->category->getTopLevelCategories();
144 |
145 | /**
146 | *
147 | * @description İstenilen kategori, üst seviye kategori veya diğer seviye kategorilerden olabilir, bu kategorilere ait olan özelliklerin
148 | * ve bu özelliklere ait değerlerin listelenmesi için kullanılan metottur.
149 | * @param int Kategori Id - Zorunlu
150 | * @param array Sayfalama - İsteğe Bağlı
151 | *
152 | */
153 | $client->category->getCategoryAttributes(1002841, array('currentPage' => 1, 'pageSize' => 20));
154 |
155 | /**
156 | *
157 | * @description İstenilen kategori, üst seviye kategori veya diğer seviye kategorilerden olabilir,
158 | * bu kategorilere ait olan özelliklerin listelenmesi için kullanılan metoddur.
159 | * @param int Kategori Id - Zorunlu
160 | *
161 | */
162 | $client->category->getCategoryAttributesId(1002841);
163 |
164 | /**
165 | *
166 | * @description Özelliğe sistemimizde verilen id bilgisini (category.attributeList.attribute.id) girdi vererek,
167 | * o özelliğe ait değerleri listeler.
168 | * @param int Kategori Id - Zorunlu
169 | * @param array Sayfalama - İsteğe Bağlı
170 | *
171 | */
172 | $client->category->getCategoryAttributeValue(354080997, array('currentPage' => 0, 'pageSize' => 20));
173 |
174 | /**
175 | *
176 | * @description Kodu verilen kategorinin birinci seviye üst kategorilerine ulaşmak için bu metot kullanılmalıdır. İkinci seviye üst
177 | * kategorilere ulaşmak için (Örn. “Deri ayakkabı -> Ayakkabı -> Giysi” kategori ağacında “Giysi “ bilgisi)
178 | * birinci seviye üst kategorinin (Örn. Ayakkabı) kodu verilerek tekrar servis çağırılmalıdır.
179 | *
180 | */
181 | $client->category->getParentCategory(1000717);
182 |
183 | /**
184 | *
185 | * @description Kodu verilen kategorinin birinci seviye alt kategorilerine ulaşmak için bu metot kullanılmalıdır. İkinci seviye alt
186 | * kategorilere ulaşmak için (Örn. “Giysi -> Ayakkabı -> Deri ayakkabı” kategori ağacında “Deri ayakkabı” bilgisi)
187 | * birinci Seviye alt kategorinin (Örn. Ayakkabı) kodu verilerek tekrar servis çağırılmalıdır.
188 | *
189 | */
190 | $client->category->getSubCategories(1002841);
191 | ```
192 |
193 | ### Ürün Servisi (ProductService)
194 |
195 | ```php
196 |
197 | /**
198 | *
199 | * @description N11 ürün ID sini kullanarak sistemde kayıtlı olan ürünün bilgilerini getirir.
200 | *
201 | */
202 | $client->product->getProductByProductId(359620750);
203 |
204 | /**
205 | *
206 | * @description Mağaza ürün kodunu kullanarak sistemde kayıtlı olan ürünün bilgilerini getirir.
207 | *
208 | */
209 | $client->product->getProductBySellerCode('IS-20014');
210 |
211 | /**
212 | *
213 | * @description N11 Üzerindeki ürünleri listelemek için kullanılır.
214 | * @param array Sayfalama - İsteğe Bağlı
215 | *
216 | */
217 | $client->product->getProductList(array('currentPage' => 0, 'pageSize' => 20));
218 |
219 | /**
220 | *
221 | * @description Mağazaya yeni ürün eklemek için kullanılır.
222 | * @param array eklenecek ürün bilgileri - Zorunlu
223 | *
224 | */
225 | $client->product->SaveProduct(
226 | array(
227 | 'productSellerCode' => 'TF23094823',
228 | 'title' => 'Mavi Toparlayıcı Efekt Skinny Pantolon',
229 | 'subtitle' => 'Curabitur blandit consequat libero, ac suscipit leo luctusrfggfgf',
230 | 'description' => 'Curabitur blandit consequat libero, ac suscipit leo luctus eget. Etiam condimentum augue at quam sagittis bibendum. Quisque vitae malesuada urna. Proi',
231 | 'domestic' => 'false',
232 | 'category' => array(
233 | 'id' => '1002201'
234 | ),
235 | 'specialProductInfoList' => array(
236 | 'specialProductInfo' => array(
237 | 'key' => '?',
238 | 'value' => '?',
239 | )
240 | ),
241 | 'price' => '185.00',
242 | 'currencyType' => '1',
243 | 'images' => array(
244 | 'image' => array(
245 | array(
246 | 'url' => 'https://contents.mediadecathlon.com/p1058366/k20d731c11ef86aad6039daa20fb66dc3/1058366_default.jpg',
247 | 'order' => '1',
248 | ),
249 | array(
250 | 'url' => 'https://contents.mediadecathlon.com/p1058366/k20d731c11ef86aad6039daa20fb66dc3/1058366_default.jpg',
251 | 'order' => '2',
252 | ),
253 | array(
254 | 'url' => 'https://contents.mediadecathlon.com/p1058366/k20d731c11ef86aad6039daa20fb66dc3/1058366_default.jpg',
255 | 'order' => '3',
256 | ),
257 | array(
258 | 'url' => 'https://contents.mediadecathlon.com/p1058366/k20d731c11ef86aad6039daa20fb66dc3/1058366_default.jpg',
259 | 'order' => '4',
260 | ),
261 | array(
262 | 'url' => 'https://contents.mediadecathlon.com/p1058366/k20d731c11ef86aad6039daa20fb66dc3/1058366_default.jpg',
263 | 'order' => '5',
264 | ),
265 | array(
266 | 'url' => 'https://contents.mediadecathlon.com/p1058366/k20d731c11ef86aad6039daa20fb66dc3/1058366_default.jpg',
267 | 'order' => '6',
268 | )
269 | )
270 | ),
271 | 'approvalStatus' => '1',
272 | 'attribute' => array(),
273 | 'saleStartDate' => '',
274 | 'saleEndDate' => '',
275 | 'productionDate' => '',
276 | 'expirationDate' => '',
277 | 'productCondition' => 1,
278 | 'preparingDay' => 3,
279 | 'discount' => array(
280 | 'startDate' => '',
281 | 'endDate' => '',
282 | 'type' => '',
283 | 'value' => '',
284 | ),
285 | 'shipmentTemplate' => 'termos',
286 | 'stockItems' => array(
287 | 'stockItem' => array(
288 | array(
289 | 'bundle' => 'false',
290 | 'mpn' => '112',
291 | 'gtin' => '0190198066473',
292 | 'oem' => '',
293 | 'quantity' => '855',
294 | 'n11CatalogId' => '',
295 | 'sellerStockCode' => '112',
296 | 'optionPrice' => '185.00',
297 | 'attributes' => array(
298 | 'attribute' => array(
299 | array(
300 | 'name' => 'Sezon',
301 | 'value' => '2013 Sonbahar-Kış'
302 | ),
303 | array(
304 | 'name' => 'Cinsiyet',
305 | 'value' => 'Erkek',
306 | ),
307 | array(
308 | 'name' => 'Beden',
309 | 'value' => '145',
310 | ),
311 | array(
312 | 'name' => 'Desen',
313 | 'value' => 'Nakışlı',
314 | ),
315 | array(
316 | 'name' => 'Ürün_Detayı',
317 | 'value' => 'Kapüşonlu',
318 | ),
319 | array(
320 | 'name' => 'İçerik',
321 | 'value' => 'Brode,Brokar,İnterlok',
322 | ),
323 | array(
324 | 'name' => 'Marka',
325 | 'value' => 'Esteem',
326 | ),
327 | array(
328 | 'name' => 'Renk',
329 | 'value' => 'Gri',
330 | )
331 | )
332 | )
333 | )
334 | )
335 | ),
336 | 'unitInfo' => array(
337 | 'unitType' => '',
338 | 'unitWeight' => ''
339 | ),
340 | 'maxPurchaseQuantity' => '122',
341 | 'groupAttribute' => '',
342 | 'groupItemCode' => '',
343 | 'itemName' => ''
344 | )
345 | );
346 |
347 | /**
348 | *
349 | * @description Kayıtlı olan bir ürünü N11 Id si kullanarak silmek için kullanılır.
350 | * @param int N11 Ürün Id - Zorunlu
351 | *
352 | */
353 | $client->product->deleteProductById(1234567890);
354 |
355 | /**
356 | *
357 | * @description Kayıtlı olan bir ürünü mağaza ürün kodu kullanılarak silmek için kullanılır.
358 | * @param string N11 Ürünün Mağazadaki Ürün Kodu - Zorunlu
359 | *
360 | */
361 | $client->product->deleteProductBySellerCode(1234567890);
362 | ```
363 |
364 | ### Ürün Satış Durumu Servisi (ProductSellingService)
365 |
366 | ```php
367 |
368 | /**
369 | *
370 | * @description Satışta olan ürünün n11 ürün ID si kullanılarak satışa kapatılması için kullanılır.
371 | * @param int N11 Ürün Id - Zorunlu
372 | *
373 | */
374 | $client->selling->stopSellingProductByProductId(1234567890);
375 |
376 | /**
377 | *
378 | * @description Satışta olmayan bir ürünün N11 ürün ID si kullanılarak satışa başlanması için kullanılır.
379 | * @param string N11 Ürün Mağaza Id - Zorunlu
380 | *
381 | */
382 | $client->selling->startSellingProductBySellerCode('IS-20014');
383 |
384 | /**
385 | *
386 | * @description Satışta olmayan bir ürünün N11 ürün ID si kullanılarak satışa başlanması için kullanılır.
387 | * @param int N11 Ürün Id - Zorunlu
388 | *
389 | */
390 | $client->selling->startSellingProductByProductId(1234567890);
391 |
392 | /**
393 | *
394 | * @description Satışta olan ürünün mağaza ürün kodu kullanılarak satışının durdurulması için kullanılır.
395 | * @param string N11 Ürün Mağaza Id - Zorunlu
396 | *
397 | */
398 | $client->selling->stopSellingProductBySellerCode('IS-20014');
399 | ```
400 |
401 | ### Ürün Stok Servisi (ProductStockService)
402 |
403 | ```php
404 |
405 | /**
406 | *
407 | * @description Sistemde kayıtlı olan ürünün N11 ürün ID si ile ürün stok bilgilerini getiren metottur.
408 | * Cevap içinde stok durumunun “version” bilgisi de vardır, ürün stoklarında değişme olduysa
409 | * bu versiyon bilgisi artacaktır, çağrı yapan taraf versiyon bilgisini kontrol ederek N11 e
410 | * verilen stok bilgilerinde değişim olup olmadığını anlayabilir.
411 | * @param int N11 Ürün Id - Zorunlu
412 | *
413 | */
414 | $client->stock->getProductStockByProductId(1234567890);
415 | ```
416 |
417 | ### Sipariş Servisi (Order Service)
418 |
419 | ```php
420 |
421 | /**
422 | *
423 | * @description Bu metot sipariş ile ilgili özet bilgileri listelemek için kullanılır.
424 | * @note İsteğe bağlı olarak dizideki alanların istenilen bölümleri eklenmeyebilir veya dizi hiç gönderilmeyebilir.
425 | * @param array Arama Sorgusu - İsteğe Bağlı
426 | *
427 | */
428 | $client->order->orderList(
429 | array(
430 | // Ürün ID Numarası
431 | 'productId' => 1234567890,
432 | // Sipariş Durumu => New, Approved, Rejected, Shipped, Delivered, Completed, Claimed, LATE_SHIPMENT
433 | 'status' => 'New',
434 | // Alıcı Adı
435 | 'buyerName' => 'ismail',
436 | // Sipariş Numarası
437 | 'orderNumber' => 1234567890,
438 | // Ürün Mağaza Kodu
439 | 'productSellerCode' => 'IS-20014',
440 | // Teslim alacak kişinin adı
441 | 'recipient' => 'ismail',
442 | // Sipariş oluşturma tarihi başlangıç
443 | 'period' => array(
444 | // Başlangıç Tarihi => d/m/Y H:i:s
445 | 'startDate' => '28/06/2019',
446 | // Bitiş Tarihi => d/m/Y H:i:s
447 | 'endDate' => '01/07/2019'
448 | ),
449 | // Güncellenen Siparişleri Listeler
450 | 'sortForUpdateDate' => false,
451 | // Sayfalama
452 | 'pagingData' => array(
453 | // Şuanki Sayfa
454 | 'currentPage' => 0,
455 | // Gösterilecek nesne
456 | 'pageSize' => 20
457 | )
458 |
459 | )
460 | );
461 |
462 | /**
463 | *
464 | * @description Sipariş N11 ID bilgisi kullanarak sipariş detaylarını almak için kullanılır,
465 | * sipariş N11 ID bilgisine orderList metotlarıyla ulaşılabilir.
466 | * @param int Sipariş ID Numarası - Zorunlu
467 | *
468 | */
469 | $client->order->orderDetail(123456789);
470 | ```
471 |
472 | ### N11 Sipariş Bildirimi WebHook (N11 Order WebHook) BETA
473 |
474 | N11 Tarafından sipariş bildirimleri için bir webhook verilmediği için bu işlemi yapmak isteyenler kişiler için yazılmış olan bir webhook dur. Webhook'u kullanabilmeniz için sunucunuzda **sqlite** pdo driver kurulu olması gerekmektedir.
475 |
476 | **Not:** Oluşturacağınız bu dosyayı linux tarafında arkaplanda sürekli çalışır halde kalması gerekmektedir. Bunu yapmak için **tmux** veya **servis yazarak** kullanabilirsiniz. **Cronjob ile kullanmayınız!**
477 |
478 | _**Bu Webhook'un henüz beta aşamasında olduğunu unutmayın!**_
479 |
480 |
481 |
482 | ```php
483 |
484 | include "vendor/autoload.php";
485 |
486 | use IS\PazarYeri\N11\N11Client;
487 |
488 | $client = new N11Client();
489 | $client->setApiKey('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
490 | $client->setApiPassword('xxxxxxxxxxxxxxxx');
491 |
492 | /**
493 | *
494 | * @description Webhook istek hızı
495 | * @param string
496 | * 'slow' => 300 saniye,
497 | * 'medium' => 180 saniye (default/taviye edilen),
498 | * 'fast' => 60 saniye
499 | * 'vfast' => 30 saniye
500 | *
501 | */
502 | $client->webhook->setRequestMode('medium');
503 |
504 | /**
505 | *
506 | * @description N11 sonuçlarında kaç siparişin getirileceği
507 | * @param string
508 | * 'vmax' => 100 adet,
509 | * 'max' => 75 adet,
510 | * 'medium' => 50 adet (default/taviye edilen),
511 | * 'min' => 30 adet
512 | *
513 | */
514 | $client->webhook->setResultMode('medium');
515 |
516 | /**
517 | *
518 | * @description Sipariş bildirimlerinde geçmiş siparişler kontrol edilsinmi?
519 | * @param bool
520 | * true => Evet (default/Tavsiye edilen),
521 | * false => Hayır,
522 | *
523 | */
524 | // Uyarı! Bu fonksiyon versiyon 1.1.0'dan itibaren kaldırılmıştır.
525 | // $client->webhook->setOldConsumeMode(true);
526 |
527 | /* Anonymous function ile siparişleri almak */
528 | $client->webhook->orderConsume(function($order){
529 |
530 | echo "Sipariş Bilgileri";
531 | echo "";
532 | print_r($order);
533 | echo "
";
534 |
535 | });
536 |
537 | /* Class ile siparişleri almak */
538 |
539 | Class N11Orders
540 | {
541 |
542 | public function consume($order)
543 | {
544 |
545 | echo "Sipariş Bilgileri";
546 | echo "";
547 | print_r($order);
548 | echo "
";
549 |
550 | }
551 |
552 | }
553 |
554 | $client->webhook->orderConsume(array(new N11Orders(), 'consume'));
555 |
556 | ```
557 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
2 | show_downloads: true
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ismail0234/n11-php-api",
3 | "description": "N11 PHP API",
4 | "type": "library",
5 | "keywords": ["n11", "eticaret", "php api", "n11 php api", "pazaryeri"],
6 | "license": "MIT",
7 | "authors": [
8 | {
9 | "name": "İsmail Satilmiş",
10 | "email": "ismaiil_0234@hotmail.com"
11 | }
12 | ],
13 | "autoload": {
14 | "psr-4": {
15 | "IS\\PazarYeri\\N11\\": "IS/PazarYeri/N11"
16 | }
17 | },
18 | "minimum-stability": "stable"
19 | }
20 |
--------------------------------------------------------------------------------