├── .all-contributorsrc ├── .github ├── CONTRIBUTING.md └── FUNDING.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── IS └── PazarYeri │ └── N11 │ ├── Helper │ ├── BaseCall.php │ ├── Database.php │ ├── Gateway.php │ ├── N11Exception.php │ └── Request.php │ ├── N11Client.php │ └── Services │ ├── CategoryService.php │ ├── CityService.php │ ├── OrderService.php │ ├── ProductSellingService.php │ ├── ProductService.php │ ├── ProductStockService.php │ ├── ShipmentCompanyService.php │ ├── ShipmentService.php │ └── WebHookService.php ├── LICENSE ├── README.md ├── _config.yml └── composer.json /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "projectName": "n11-php-api", 6 | "projectOwner": "ismail0234", 7 | "repoType": "github", 8 | "repoHost": "https://github.com", 9 | "commit": false, 10 | "imageSize": 100, 11 | "contributorsPerLine": 7, 12 | "contributorsSortAlphabetically": false, 13 | "badgeTemplate": "[![All Contributors](https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg?style=flat-square)](#contributors)", 14 | "contributorTemplate": "\">\" width=\"<%= options.imageSize %>px;\" alt=\"\"/>
<%= contributor.name %>
", 15 | "types": { 16 | "custom": { 17 | "symbol": "🔭", 18 | "description": "A custom contribution type.", 19 | "link": "[<%= symbol %>](<%= url %> \"<%= description %>\")," 20 | } 21 | }, 22 | "skipCi": false, 23 | "contributors": [ 24 | { 25 | "login": "ahmetcadirci25", 26 | "name": "Ahmet Çadırcı", 27 | "avatar_url": "https://avatars2.githubusercontent.com/u/9280397?v=4", 28 | "profile": "https://ahmetcadirci.com.tr", 29 | "contributions": [ 30 | "code", 31 | "bug" 32 | ] 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ##### Listeye ekleme yaparken 2 | 3 | - Doğru konu başlığı eklemeye 4 | - Konu başlığının en sonuna eklemeye 5 | - Listede halihazırda yer almamasına 6 | 7 | dikkat ediniz. 8 | 9 | - Pull Request açmak için aşağıdakilerden birini yapabilirsiniz: 10 | - Repository'yi fork'layıp, kendi repository'nizde değişiklikleri yapıp, Pull Request açabilirsiniz. 11 | - [README.md](https://github.com/ahmetcadirci25/sublime-text-3/blob/master/README.md) dosyasını açıp, sağ üstteki kalem ikonuna tıklayıp, istediğiniz değişikliği yapıp, commit yapabilirsiniz. Bu yöntemde GitHub sizin için bir patch branch'i oluşturup Pull Request açmanıza izin verecektir. 12 | 13 | - Fork'ladığınız repository güncel mi? 14 |
15 | Lütfen kendi repositorynizi en son değişikliklerle güncelleyiniz. 16 | 17 | - Conflict var mı? 18 |
19 | Eğer *"Can’t automatically merge"* yazısıyla karşılaşırsanız bir conflict var demektir. Lütfen değişikliklerinizi kontrol edip, var olan conflict'leri çözünüz. 20 | 21 | Eğer katkıda bulunmak istiyor ama nereden ve nasıl başlayacağınızı bilmiyorsanız [bu makaleyi](https://medium.com/@cengizhanc/github-ile-a%C3%A7%C4%B1k-kaynak-projelere-katk%C4%B1da-bulunmak-8a0d79090546) okuyabilirsiniz. 22 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: botbenson 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | #### Version 1.1.3 2 | * SOAP istekleri ve ürün ekleme ile ilgili sorunlar giderildi 3 | 4 | #### Version 1.1.2 5 | * Webhook sqlite şişme sorunu düzeltildi. 6 | * Helper namespace webhookservice dosyasında düzenlendi. 7 | 8 | #### Version 1.1.0 9 | * Webhook için yapılacaklar tamamlandı [burada](https://github.com/ismail0234/n11-php-api/issues/1). 10 | * setOldConsumeMode artık gerekli olmadığından kaldırıldı. 11 | 12 | #### Version 1.0.6 13 | * Webhook servisinde çalışmayan 3 fonksiyon için hatalı parametreleri düzeltildi. 14 | 15 | #### Version 1.0.5 16 | * WebHookService için BETA Sürüm Eklendi. 17 | * Tarih yazım hatası düzeltildi. 18 | 19 | #### Version 1.0.4 20 | * OrderService ve ProductStockService Eklendi. 21 | * Api password ve username değişken tipi değiştirildi. 22 | * Hatalı açıklamalar düzeltildi. 23 | 24 | #### Version 1.0.3 25 | * Yeni Servis Eklendi (ProductSellingService) 26 | * SOAP wSDL Cache kapatıldı 27 | * SOAP İstek n11exception eklendi 28 | 29 | #### Version 1.0.2 30 | * DeleteProductById ve deleteProductBySellerCode eklendi 31 | 32 | #### Version 1.0.1 33 | * Composer sorunu düzeltildi. 34 | 35 | #### Version 1.0.0 36 | * İlk Sürüm Yayınlandı. 37 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Helper/BaseCall.php: -------------------------------------------------------------------------------- 1 | service = new $soapServiceName(); 42 | $this->request = new Request($this->service->url , $apiKey, $apiPassword); 43 | 44 | } 45 | 46 | /** 47 | * 48 | * @description Gelen Tüm fonksiyon isteklerini ilgili servislere iletme 49 | * @param string 50 | * @param array 51 | * @return string 52 | * 53 | */ 54 | public function __call($methodName, $arguments) 55 | { 56 | 57 | if(!$this->clientStatus) { 58 | $this->clientStatus = $this->request->connectSoap(); 59 | } 60 | 61 | if (!method_exists($this->service, $methodName)) { 62 | throw new N11Exception("Method Bulunamadı"); 63 | } 64 | 65 | return call_user_func_array(array($this->service, $methodName), array_merge(array($this->request), $arguments)); 66 | 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Helper/Database.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | */ 15 | protected $db = null; 16 | 17 | /** 18 | * 19 | * SQLite Veritabanı Sınıfı Oluşturucu 20 | * 21 | * @author Ismail Satilmis 22 | * 23 | */ 24 | public function __construct() 25 | { 26 | 27 | $this->checkSQLiteAndPDODriver(); 28 | 29 | $SQLitePath = __DIR__ . '/../Data/'; 30 | if (!file_exists($SQLitePath)) { 31 | mkdir($SQLitePath, 0777); 32 | } 33 | 34 | $this->db = new \PDO("sqlite:" . $SQLitePath . 'n11.sqlite'); 35 | $this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); 36 | $this->checkAndCreateTables(); 37 | 38 | } 39 | 40 | /** 41 | * 42 | * SQLite ve PDO sürücülerini kontrol etme 43 | * 44 | * @author Ismail Satilmis 45 | * 46 | */ 47 | protected function checkSQLiteAndPDODriver() 48 | { 49 | 50 | $response = \PDO::getAvailableDrivers(); 51 | if (count($response) <= 0 || empty($response)) { 52 | throw new N11Exception("Sunucunuzda PDO Aktif Olmalıdır."); 53 | } 54 | 55 | if (!in_array('sqlite', $response)) { 56 | throw new N11Exception("Sunucunuzda SQLite PDO Sürücüsü Aktif Olmalıdır."); 57 | } 58 | 59 | } 60 | 61 | /** 62 | * 63 | * SQLite Veritabanı tablolarını kontrol etme ve oluşturma 64 | * 65 | * @author Ismail Satilmis 66 | * 67 | */ 68 | public function checkAndCreateTables() 69 | { 70 | 71 | $sqlQuerys = array( 72 | 'CREATE TABLE IF NOT EXISTS `orders` ( 73 | `orderid` INTEGER NOT NULL , 74 | `status` TINYINT NOT NULL DEFAULT \'0\' , 75 | `date` INTEGER NOT NULL , 76 | PRIMARY KEY (`orderid`) 77 | );', 78 | 'CREATE TABLE IF NOT EXISTS `settings` ( 79 | `lastOrderId` INTEGER NOT NULL DEFAULT \'0\', 80 | `pageId` INTEGER NOT NULL DEFAULT \'0\' 81 | );', 82 | ); 83 | 84 | foreach ($sqlQuerys as $sql) { 85 | $this->db->query($sql); 86 | } 87 | 88 | $settings = $this->selectSettings(); 89 | if (!isset($settings->lastOrderId)) { 90 | $this->db->query('INSERT INTO settings (lastOrderId, pageId) VALUES(0,0);'); 91 | } 92 | 93 | } 94 | 95 | /** 96 | * 97 | * Siparişleri SQLite üzerinde tutma 98 | * 99 | * @author Ismail Satilmis 100 | * @param int $orderId 101 | * @return int 102 | * 103 | */ 104 | public function addOrder($orderId) 105 | { 106 | 107 | $prepare = $this->db->prepare('INSERT INTO `orders` (orderid, status, date) VALUES(?, ?, ?)'); 108 | $prepare->execute(array($orderId, 0 , time())); 109 | return $this->db->lastInsertId(); 110 | 111 | } 112 | 113 | /** 114 | * 115 | * Siparişleri SQLite üzerinde kontrol etme 116 | * 117 | * @author Ismail Satilmis 118 | * @param int $orderId 119 | * @return object 120 | * 121 | */ 122 | public function selectOrder($orderId) 123 | { 124 | 125 | $prepare = $this->db->prepare('SELECT * FROM `orders` WHERE orderid = ?'); 126 | $prepare->execute(array($orderId)); 127 | return $prepare->fetch(\PDO::FETCH_OBJ); 128 | } 129 | 130 | /** 131 | * 132 | * Siparişleri SQLite üzerinde tamamlandı olarak işaretleme 133 | * 134 | * @author Ismail Satilmis 135 | * @param int $orderId 136 | * @return bool 137 | * 138 | */ 139 | public function finishOrder($orderId) 140 | { 141 | 142 | $prepare = $this->db->prepare('UPDATE `orders` SET status = ? WHERE orderid = ?'); 143 | return $prepare->execute(array(1 , $orderId)); 144 | } 145 | 146 | /** 147 | * 148 | * WebHookService Ayarlarını getirir. 149 | * 150 | * @author Ismail Satilmis 151 | * @return object 152 | * 153 | */ 154 | public function selectSettings() 155 | { 156 | 157 | $prepare = $this->db->prepare('SELECT * FROM `settings`'); 158 | $prepare->execute(); 159 | return $prepare->fetch(\PDO::FETCH_OBJ); 160 | } 161 | 162 | /** 163 | * 164 | * Ayarlar tablosunda lastOrderId değerini günceller. 165 | * 166 | * @author Ismail Satilmis 167 | * @param int $lastOrderId 168 | * @return object 169 | * 170 | */ 171 | public function updateOrder($lastOrderId) 172 | { 173 | 174 | $prepare = $this->db->prepare('UPDATE `settings` SET lastOrderId = ?'); 175 | return $prepare->execute(array($lastOrderId)); 176 | 177 | } 178 | 179 | /** 180 | * 181 | * Ayarlar tablosunda pageId değerini günceller. 182 | * 183 | * @author Ismail Satilmis 184 | * @param int $pageId 185 | * @return string 186 | * 187 | */ 188 | public function updatePageId($pageId) 189 | { 190 | 191 | $prepare = $this->db->prepare('UPDATE `settings` SET pageId = ?'); 192 | return $prepare->execute(array($pageId)); 193 | } 194 | 195 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Helper/Gateway.php: -------------------------------------------------------------------------------- 1 | 'CityService', 31 | 'shipmentcompany' => 'ShipmentCompanyService', 32 | 'shipment' => 'ShipmentService', 33 | 'category' => 'CategoryService', 34 | 'product' => 'ProductService', 35 | 'selling' => 'ProductSellingService', 36 | 'stock' => 'ProductStockService', 37 | 'order' => 'OrderService', 38 | 'webhook' => 'WebHookService', 39 | ); 40 | 41 | /** 42 | * 43 | * @description SOAP Api servislerinin ilk çağırma için hazırlanması 44 | * @param string 45 | * @return service 46 | * 47 | */ 48 | public function __get($name) 49 | { 50 | 51 | if (!isset($this->allowedServices[$name])) { 52 | throw new N11Exception("Geçersiz Yordam!"); 53 | } 54 | 55 | if (isset($this->$name)) { 56 | return $this->$name; 57 | } 58 | 59 | $this->$name = new BaseCall($this->allowedServices[$name], $this->apiKey, $this->apiPassword); 60 | return $this->$name; 61 | 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Helper/N11Exception.php: -------------------------------------------------------------------------------- 1 | apiKey = $apiKey; 46 | $this->apiPassword = $apiPassword; 47 | $this->serviceUrl = $serviceUrl; 48 | 49 | } 50 | 51 | /** 52 | * 53 | * @description SOAP Oturumunu Başlatma 54 | * @param string 55 | * @return SoapClient 56 | * 57 | */ 58 | public function connectSoap() 59 | { 60 | 61 | try { 62 | $this->client = new \SoapClient($this->serviceUrl, array("trace" => 1, "exception" => false, 'cache_wsdl' => WSDL_CACHE_NONE)); 63 | return true; 64 | } catch (\Exception $e) { 65 | throw new N11Exception("SOAP Oturumu Başarısız"); 66 | } 67 | 68 | } 69 | 70 | /** 71 | * 72 | * @description SOAP İstek Gönderme 73 | * @param string 74 | * @return SoapClient 75 | * 76 | */ 77 | public function sendRequest($method, $data = array()) 78 | { 79 | 80 | if (isset($data['auth'])) { 81 | unset($data['auth']); 82 | } 83 | 84 | try { 85 | return $this->client->$method(array_merge(array('auth' => array('appKey' => $this->apiKey, 'appSecret' => $this->apiPassword)), $data)); 86 | } catch (\Exception $e) { 87 | throw new N11Exception($e->getMessage()); 88 | 89 | } 90 | 91 | } 92 | 93 | 94 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/N11Client.php: -------------------------------------------------------------------------------- 1 | apiKey = $apiKey; 21 | 22 | } 23 | 24 | /** 25 | * 26 | * @description N11 Api Şifre 27 | * @param string $apiPassword 28 | * 29 | */ 30 | public function setApiPassword($apiPassword) 31 | { 32 | 33 | $this->apiPassword = $apiPassword; 34 | 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/CategoryService.php: -------------------------------------------------------------------------------- 1 | sendRequest('GetTopLevelCategories'); 24 | 25 | } 26 | 27 | /** 28 | * 29 | * @description İstenilen kategori, üst seviye kategori veya diğer seviye kategorilerden olabilir, bu kategorilere ait olan özelliklerin 30 | * ve bu özelliklere ait değerlerin listelenmesi için kullanılan metottur. 31 | * 32 | */ 33 | public function GetCategoryAttributes($client, $categoryId, $pagination = array()) 34 | { 35 | 36 | return $client->sendRequest('GetCategoryAttributes', array('categoryId' => $categoryId, 'pagingData' => $pagination)); 37 | 38 | } 39 | 40 | /** 41 | * 42 | * @description İstenilen kategori, üst seviye kategori veya diğer seviye kategorilerden olabilir, 43 | * bu kategorilere ait olan özelliklerin listelenmesi için kullanılan metoddur. 44 | * 45 | */ 46 | public function GetCategoryAttributesId($client, $categoryId) 47 | { 48 | 49 | return $client->sendRequest('GetCategoryAttributesId', array('categoryId' => $categoryId)); 50 | 51 | } 52 | 53 | /** 54 | * 55 | * @description Özelliğe sistemimizde verilen id bilgisini (category.attributeList.attribute.id) girdi vererek, 56 | * o özelliğe ait değerleri listeler. 57 | * 58 | */ 59 | public function GetCategoryAttributeValue($client, $attributeId, $categoryId, $pagination = array()) 60 | { 61 | 62 | return $client->sendRequest('GetCategoryAttributeValue', array('categoryProductAttributeId' => $attributeId, 'categoryId' => $categoryId, 'pagingData' => $pagination)); 63 | 64 | } 65 | 66 | /** 67 | * 68 | * @description Kodu verilen kategorinin birinci seviye üst kategorilerine ulaşmak için bu metot kullanılmalıdır. İkinci seviye üst 69 | * kategorilere ulaşmak için (Örn. “Deri ayakkabı -> Ayakkabı -> Giysi” kategori ağacında “Giysi “ bilgisi) 70 | * birinci seviye üst kategorinin (Örn. Ayakkabı) kodu verilerek tekrar servis çağırılmalıdır. 71 | * 72 | */ 73 | public function getParentCategory($client, $categoryId) 74 | { 75 | 76 | return $client->sendRequest('GetParentCategory', array('categoryId' => $categoryId)); 77 | 78 | } 79 | 80 | /** 81 | * 82 | * @description Kodu verilen kategorinin birinci seviye alt kategorilerine ulaşmak için bu metot kullanılmalıdır. İkinci seviye alt 83 | * kategorilere ulaşmak için (Örn. “Giysi -> Ayakkabı -> Deri ayakkabı” kategori ağacında “Deri ayakkabı” bilgisi) 84 | * birinci Seviye alt kategorinin (Örn. Ayakkabı) kodu verilerek tekrar servis çağırılmalıdır. 85 | * 86 | */ 87 | public function getSubCategories($client, $categoryId, $lastModifiedDate) 88 | { 89 | 90 | return $client->sendRequest('GetSubCategories', array('categoryId' => $categoryId, 'lastModifiedDate' => $lastModifiedDate)); 91 | 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/CityService.php: -------------------------------------------------------------------------------- 1 | sendRequest('GetCities'); 24 | 25 | } 26 | 27 | /** 28 | * 29 | * @description Şehir hakkında birkaç bilgi döndürür. 30 | * @param int Şehir Id 31 | * 32 | */ 33 | public function getCity($client, $cityId) 34 | { 35 | 36 | return $client->sendRequest('GetCity', array('cityCode' => $cityId)); 37 | 38 | } 39 | 40 | /** 41 | * 42 | * @description Plaka kodu verilen şehre ait ilçelerinin listelenmesi için kullanılır. 43 | * @param int Şehir Id 44 | * 45 | */ 46 | public function getDistrict($client, $cityId) 47 | { 48 | 49 | return $client->sendRequest('GetDistrict', array('cityCode' => $cityId)); 50 | 51 | } 52 | 53 | /** 54 | * 55 | * @description İlçe kodu verilen semt/mahallelerin listelenmesi için kullanılır. 56 | * @param int İlçe Id 57 | * 58 | */ 59 | public function getNeighborhoods($client, $districtId) 60 | { 61 | 62 | return $client->sendRequest('GetNeighborhoods', array('districtId' => $districtId)); 63 | 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/OrderService.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'productId' => '', 26 | 'status' => '', 27 | 'buyerName' => '', 28 | 'orderNumber' => '', 29 | 'productSellerCode' => '', 30 | 'recipient' => '', 31 | 'period' => '', 32 | 'sortForUpdateDate' => '', 33 | ) 34 | ); 35 | if (isset($data['productId'])) { 36 | $query['searchData']['productId'] = $data['productId']; 37 | } 38 | 39 | if (isset($data['status']) && in_array($data['status'], array('New', 'Approved', 'Rejected', 'Shipped', 'Delivered', 'Completed', 'Claimed', 'LATE_SHIPMENT'))) { 40 | $query['searchData']['status'] = $data['status']; 41 | } 42 | 43 | if (isset($data['buyerName'])) { 44 | $query['searchData']['buyerName'] = $data['buyerName']; 45 | } 46 | 47 | if (isset($data['orderNumber'])) { 48 | $query['searchData']['orderNumber'] = $data['orderNumber']; 49 | } 50 | 51 | if (isset($data['productSellerCode'])) { 52 | $query['searchData']['productSellerCode'] = $data['productSellerCode']; 53 | } 54 | 55 | if (isset($data['recipient'])) { 56 | $query['searchData']['recipient'] = $data['recipient']; 57 | } 58 | 59 | if (isset($data['period'])) { 60 | $query['searchData']['period'] = $data['period']; 61 | } 62 | 63 | if (isset($data['sortForUpdateDate'])) { 64 | $query['searchData']['sortForUpdateDate'] = $data['sortForUpdateDate']; 65 | } 66 | 67 | if (isset($data['pagingData'])) { 68 | $query['pagingData'] = $data['pagingData']; 69 | } 70 | 71 | return $client->sendRequest('OrderList', $query); 72 | 73 | } 74 | 75 | /** 76 | * 77 | * @description Sipariş N11 ID bilgisi kullanarak sipariş detaylarını almak için kullanılır, 78 | * sipariş N11 ID bilgisine orderList metotlarıyla ulaşılabilir. 79 | * 80 | */ 81 | public function orderDetail($client, $Id) 82 | { 83 | 84 | return $client->sendRequest('OrderDetail', array('orderRequest' => array('id' => $Id))); 85 | 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/ProductSellingService.php: -------------------------------------------------------------------------------- 1 | sendRequest('StopSellingProductByProductId', array('productId' => $productId)); 24 | 25 | } 26 | 27 | /** 28 | * 29 | * @description Satışta olmayan bir ürünün N11 ürün ID si kullanılarak satışa başlanması için kullanılır. 30 | * 31 | */ 32 | public function startSellingProductBySellerCode($client, $productSellerCode) 33 | { 34 | 35 | return $client->sendRequest('StartSellingProductBySellerCode', array('productSellerCode' => $productSellerCode)); 36 | 37 | } 38 | 39 | /** 40 | * 41 | * @description Satışta olmayan bir ürünün N11 ürün ID si kullanılarak satışa başlanması için kullanılır. 42 | * 43 | */ 44 | public function startSellingProductByProductId($client, $productId) 45 | { 46 | 47 | return $client->sendRequest('StartSellingProductByProductId', array('productId' => $productId)); 48 | 49 | } 50 | 51 | /** 52 | * 53 | * @description Satışta olan ürünün mağaza ürün kodu kullanılarak satışının durdurulması için kullanılır. 54 | * 55 | */ 56 | public function stopSellingProductBySellerCode($client, $productSellerCode) 57 | { 58 | 59 | return $client->sendRequest('StopSellingProductBySellerCode', array('productSellerCode' => $productSellerCode)); 60 | 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/ProductService.php: -------------------------------------------------------------------------------- 1 | sendRequest('GetProductByProductId', array('productId' => $productId)); 24 | 25 | } 26 | 27 | /** 28 | * 29 | * @description Mağaza ürün kodunu kullanarak sistemde kayıtlı olan ürünün bilgilerini getirir. 30 | * 31 | */ 32 | public function getProductBySellerCode($client, $sellerCode) 33 | { 34 | 35 | return $client->sendRequest('GetProductBySellerCode', array('sellerCode' => $sellerCode)); 36 | 37 | } 38 | 39 | /** 40 | * 41 | * @description N11 Üzerindeki ürünleri listelemek için kullanılır. 42 | * 43 | */ 44 | public function getProductList($client, $pagination = array()) 45 | { 46 | 47 | return $client->sendRequest('GetProductList', array('pagingData' => $pagination)); 48 | 49 | } 50 | 51 | /** 52 | * 53 | * @description Mağaza'ya yeni ürün eklemek için kullanılır 54 | * 55 | */ 56 | 57 | public function SaveProduct($client, $product = array()) { 58 | return $client->sendRequest('SaveProduct', array('product' => $product)); 59 | 60 | } 61 | 62 | 63 | /** 64 | * 65 | * @description Kayıtlı olan bir ürünü N11 Id si kullanarak silmek için kullanılır. 66 | * 67 | */ 68 | public function deleteProductById($client, $productId) 69 | { 70 | 71 | return $client->sendRequest('DeleteProductById', array('productId' => $productId)); 72 | 73 | } 74 | 75 | /** 76 | * 77 | * @description Kayıtlı olan bir ürünü mağaza ürün kodu kullanılarak silmek için kullanılır. 78 | * 79 | */ 80 | public function deleteProductBySellerCode($client, $productSellerCode) 81 | { 82 | 83 | return $client->sendRequest('DeleteProductBySellerCode', array('productSellerCode' => $productSellerCode)); 84 | 85 | } 86 | 87 | /** 88 | * 89 | * @description Kayıtlı olan bir ürünü mağaza ürün kodu kullanılarak silmek için kullanılır. 90 | * @note Henüz tamamlanmadı 91 | * 92 | */ 93 | /*public function productApprovalStatus($client) 94 | { 95 | 96 | return $client->sendRequest('productApprovalStatus'); 97 | 98 | }*/ 99 | 100 | /** 101 | * 102 | * @description Mağaza ürünlerini aramak için kullanılır. 103 | * @note Henüz tamamlanmadı 104 | * 105 | */ 106 | /*public function searchProducts($client, $data = array()) 107 | { 108 | 109 | $searchData = array(); 110 | if (isset($data['pagingData'])) { 111 | $searchData['pagingData'] = $data['pagingData']; 112 | } 113 | 114 | if (isset($data['productSearch'])) { 115 | $searchData['productSearch'] = $data['productSearch']; 116 | } 117 | 118 | if (isset($data['approvalStatus'])) { 119 | $searchData['approvalStatus'] = $data['approvalStatus']; 120 | } 121 | 122 | return $client->sendRequest('searchProducts', $searchData); 123 | 124 | }*/ 125 | 126 | } 127 | -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/ProductStockService.php: -------------------------------------------------------------------------------- 1 | sendRequest('GetProductStockByProductId', array('productId' => $productId)); 27 | 28 | } 29 | 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/ShipmentCompanyService.php: -------------------------------------------------------------------------------- 1 | sendRequest('GetShipmentCompanies'); 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/ShipmentService.php: -------------------------------------------------------------------------------- 1 | sendRequest('GetShipmentTemplateList'); 24 | 25 | } 26 | 27 | /** 28 | * 29 | * @description Teslimat şablon ismi ile aratılan şablonun bilgilerini döndürür. 30 | * 31 | */ 32 | public function getShipmentTemplate($client, $name) 33 | { 34 | 35 | return $client->sendRequest('GetShipmentTemplate', array('name' => $name)); 36 | 37 | } 38 | 39 | /** 40 | * 41 | * @description Teslimat şablonu kargonun nasıl gideceğine dair oluşturulan bir şablondur. 42 | * Siparişlerde kullanılacak olan teslimat şablonu özellikleriyle birlikte bu servis aracılığı ile oluşturulur. 43 | * 44 | */ 45 | public function createOrUpdateShipmentTemplate($client, $data) 46 | { 47 | 48 | return array();//$client->sendRequest('createOrUpdateShipmentTemplate', array('shipment' => $data)); 49 | 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /IS/PazarYeri/N11/Services/WebHookService.php: -------------------------------------------------------------------------------- 1 | 16 | * @var string 17 | * 18 | */ 19 | public $url = 'https://api.n11.com/ws/OrderService.wsdl'; 20 | 21 | /** 22 | * 23 | * N11 Üzerinde yeni siparişlerin sorgulanacağı aralık (saniye) 24 | * 25 | * @author Ismail Satilmis 26 | * @var int 27 | * 28 | */ 29 | protected $requestTime = 180; 30 | 31 | /** 32 | * 33 | * Son yapılan istek zamanı 34 | * 35 | * @author Ismail Satilmis 36 | * @var int 37 | * 38 | */ 39 | protected $requestEndTime; 40 | 41 | /** 42 | * 43 | * İlk başlama zamanı 44 | * 45 | * @author Ismail Satilmis 46 | * @var int 47 | * 48 | */ 49 | protected $startedTime; 50 | 51 | /** 52 | * 53 | * Sipariş listesinden kaç adet sipariş getirileceği. 54 | * 55 | * @author Ismail Satilmis 56 | * @var bool 57 | * 58 | */ 59 | protected $orderMaxResult = 50; 60 | 61 | /** 62 | * 63 | * OrderService sınıfının bir örneği 64 | * 65 | * @author Ismail Satilmis 66 | * @var class 67 | * 68 | */ 69 | protected $order; 70 | 71 | /** 72 | * 73 | * N11 sipariş ayarları tutulur. 74 | * 75 | * @author Ismail Satilmis 76 | * @var object $setting 77 | * 78 | */ 79 | protected $setting; 80 | 81 | /** 82 | * 83 | * Son sipariş id numarası 84 | * 85 | * @author Ismail Satilmis 86 | * @var int 87 | * 88 | */ 89 | protected $lastOrderId; 90 | 91 | /** 92 | * 93 | * Mevcut geçerli sayfa numarası 94 | * 95 | * @author Ismail Satilmis 96 | * @var int 97 | * 98 | */ 99 | protected $pageId; 100 | 101 | /** 102 | * 103 | * WebHookService Sınıfını Başlatma 104 | * 105 | * @author Ismail Satilmis 106 | * 107 | */ 108 | public function __construct() 109 | { 110 | 111 | $this->startedTime = time(); 112 | $this->requestEndTime = time(); 113 | $this->order = new OrderService(); 114 | parent::__construct(); 115 | 116 | } 117 | 118 | /** 119 | * 120 | * N11 Üzerindeki Yeni Siparişleri Tüketme 121 | * 122 | * @author Ismail Satilmis 123 | * @param class $client 124 | * @param function $work 125 | * 126 | */ 127 | public function orderConsume($client, $work) 128 | { 129 | 130 | while (true) 131 | { 132 | 133 | if (time() >= $this->requestEndTime) { 134 | $this->requestEndTime = time() + $this->requestTime; 135 | $this->setting = $this->selectSettings(); 136 | 137 | foreach ($this->getPagination($client) as $pageId) { 138 | 139 | foreach ($this->getOrderList($client, $pageId) as $order) { 140 | 141 | $dborder = $this->selectOrder($order->id); 142 | if (isset($dborder->orderid)) { 143 | continue; 144 | } 145 | 146 | $this->addOrder($order->id); 147 | 148 | if (is_array($work)) { 149 | call_user_func_array(array($work[0], $work[1]), array($this->order->orderDetail($client, $order->id))); 150 | }else{ 151 | $work($this->order->orderDetail($client, $order->id)); 152 | } 153 | 154 | $this->finishOrder($order->id); 155 | $this->updateOrder($order->id); 156 | } 157 | 158 | $this->updatePageId($pageId); 159 | } 160 | 161 | } 162 | 163 | sleep(1); 164 | } 165 | 166 | } 167 | 168 | /** 169 | * 170 | * Geçerli taranacak sayfaların listesini döndürür. 171 | * 172 | * @author Ismail Satilmis 173 | * @param int $pageId 174 | * @param object $orders 175 | * @param object $orderList 176 | * @return array 177 | * 178 | */ 179 | protected function getPageData($pageId, $orders, $orderList) 180 | { 181 | 182 | // max sayfa eklenecek 1'den 5'e kadar gibi 183 | $limit = $orders->pagingData->pageCount - 1 - $pageId; 184 | if ($limit <= 0) { 185 | $limit = 0; 186 | } 187 | 188 | $limit += $pageId; 189 | 190 | $pages = array(); 191 | for ($i = $pageId; $i <= $limit; $i++) { 192 | array_push($pages, $i); 193 | } 194 | 195 | return $pages; 196 | } 197 | 198 | /** 199 | * 200 | * N11 Siparişlerinin gerçek sayfalanma numarasını alır. 201 | * 202 | * @author Ismail Satilmis 203 | * @param object $orders 204 | * @param int $pageId 205 | * @param int $productId 206 | * @return array 207 | * 208 | */ 209 | protected function getRealPageId($client, $orders, $pageId, $productId) 210 | { 211 | 212 | /* seçilen sayfa içinde var ise */ 213 | $list = $this->getOrderFormat($orders); 214 | if (in_array($productId, $list)) { 215 | return $this->getPageData($pageId, $orders, $list); 216 | } 217 | 218 | /* seçilen sayfanın içindeki iki değer içinde */ 219 | $maxOrder = count($list) - 1; 220 | for ($i = 0; $i < $maxOrder; $i++) { 221 | if ($productId > $list[$i] && $productId < $list[$i + 1]) { 222 | return $this->getPageData($pageId, $orders, $list); 223 | } 224 | } 225 | 226 | $first = current($list); 227 | $last = end($list); 228 | 229 | /* ürün id 2 sayfa arasında ise (20 ve 21 arası gibi) */ 230 | if ($this->lastOrderId != null && $productId > $this->lastOrderId && $productId < $first) { 231 | return $this->getPageData($pageId, $orders, $list); 232 | } 233 | 234 | /* seçilen sayfanın ilk değeri yok ise veya ürün idsi son değerden küçük ise önceki sayfayı tara */ 235 | if (!$first || $productId < $first) { 236 | $pageId--; 237 | } 238 | 239 | /* seçilen sayfanın son değeri var ve ürün idsi son değerden büyük ise sonraki sayfayı tara */ 240 | if ($last && $productId > $last){ 241 | $pageId++; 242 | } 243 | 244 | $this->lastOrderId = $last; 245 | 246 | /* sayfa 0'dan küçük ise */ 247 | if ($pageId < 0) { 248 | return $this->getPageData(0, $orders, $list); 249 | } 250 | 251 | /* seçilen sayfanın ilk değeri var ise ve şuanki sayfa max sayfadan büyük ve eşit ise */ 252 | if ($first && $pageId >= $orders->pagingData->pageCount) { 253 | return $this->getPageData($orders->pagingData->pageCount <= 0 ? 0 : $orders->pagingData->pageCount - 1, $orders, $list); 254 | } 255 | 256 | return $this->getRealPageId($client, $this->order->orderList($client, $this->getOrderSettings($pageId)), $pageId, $this->setting->lastOrderId); 257 | } 258 | 259 | /** 260 | * 261 | * Siparişleri sadece id olarak bir diziye atar 262 | * 263 | * @author Ismail Satilmis 264 | * @param array $orders 265 | * @return array 266 | * 267 | */ 268 | protected function getOrderFormat($orders) 269 | { 270 | 271 | if (!isset($orders->orderList->order)) { 272 | return array(); 273 | } 274 | 275 | $orderList = array($orders->orderList->order); 276 | if (is_array($orders->orderList->order)) { 277 | $orderList = $orders->orderList->order; 278 | } 279 | 280 | return array_column($orderList , 'id', NULL); 281 | } 282 | 283 | /** 284 | * 285 | * N11 Üzerindeki siparişlerin kriterlere göre getirilmesi 286 | * 287 | * @author Ismail Satilmis 288 | * @param Class $client 289 | * @return array 290 | * 291 | */ 292 | protected function getOrderList($client, $pageId) 293 | { 294 | 295 | $orders = $this->order->orderList($client, $this->getOrderSettings($pageId)); 296 | if (!isset($orders->result)) { 297 | throw new N11Exception("Sipariş Listesi Alınamadı."); 298 | } 299 | 300 | if ($orders->result->status != "success") { 301 | throw new N11Exception("Sipariş Listesi Alınamadı. Hata => " . $orders->result->errorMessage); 302 | } 303 | 304 | $orderList = $orders->orderList->order; 305 | if (is_object($orders->orderList->order)) { 306 | $orderList = array($orders->orderList->order); 307 | } 308 | 309 | return $orderList; 310 | } 311 | 312 | /** 313 | * 314 | * N11 Siparişlerinin alınacağı sayfaların listesi 315 | * 316 | * @author Ismail Satilmis 317 | * @param Class $client 318 | * @return array 319 | * 320 | */ 321 | protected function getPagination($client) 322 | { 323 | 324 | $this->lastOrderId = null; 325 | return $this->getRealPageId($client, $this->order->orderList($client, $this->getOrderSettings($this->setting->pageId)), $this->setting->pageId, $this->setting->lastOrderId); 326 | 327 | } 328 | 329 | /** 330 | * 331 | * Sipariş listesi kriterleri 332 | * 333 | * @author Ismail Satilmis 334 | * @param int $pageId 335 | * @return array 336 | * 337 | */ 338 | protected function getOrderSettings($pageId) 339 | { 340 | 341 | return array( 342 | 'period' => array(), 343 | 'pagingData' => array( 344 | 'currentPage' => $pageId, 345 | 'pageSize' => $this->orderMaxResult 346 | ) 347 | ); 348 | 349 | } 350 | 351 | /** 352 | * 353 | * N11 Siparişlerinin en kadar hızlı tüketileceği. 354 | * 355 | * @author Ismail Satilmis 356 | * @param Class $client 357 | * @param string $mode 358 | * 359 | */ 360 | public function setRequestMode($client, $mode) 361 | { 362 | 363 | switch ($mode) 364 | { 365 | case 'slow' : $this->requestTime = 300; break; 366 | case 'fast' : $this->requestTime = 60; break; 367 | case 'vfast' : $this->requestTime = 30; break; 368 | case 'medium': 369 | default: 370 | $this->requestTime = 180; 371 | break; 372 | } 373 | 374 | } 375 | 376 | /** 377 | * 378 | * N11 Sipariş listesinde kaç adet siparişin getirileceği 379 | * 380 | * @author Ismail Satilmis 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 | [![Latest Stable Version](https://poser.pugx.org/ismail0234/n11-php-api/v/stable)](https://packagist.org/packages/ismail0234/n11-php-api) 2 | [![Total Downloads](https://poser.pugx.org/ismail0234/n11-php-api/downloads)](https://packagist.org/packages/ismail0234/n11-php-api) 3 | [![License](https://poser.pugx.org/ismail0234/n11-php-api/license)](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 | --------------------------------------------------------------------------------