Skip to content

Commit

Permalink
Merge pull request #3 from mafikes/version2
Browse files Browse the repository at this point in the history
New Version of Api
  • Loading branch information
mafikes authored Jun 2, 2021
2 parents f4d511e + 5813217 commit 988fcb7
Show file tree
Hide file tree
Showing 20 changed files with 1,059 additions and 356 deletions.
197 changes: 112 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
About
Library mafikes/dropshipping-cz
------------
Library in php for communication with [Dropshipping.cz API](https://client.api.dropshipping.cz/).
PHP Client for communication with [Dropshipping.cz API](https://client.api.dropshipping.cz/).

Install
------------
Expand All @@ -10,121 +10,148 @@ composer require mafikes/dropshipping-cz

Example
------------
All examples is in example/api.php
Examples could be found in examples folder.

#### Init Client
#### Create client
```php
$client = new \Mafikes\DropshippingCz\Client('Your token here');
$client = new Mafikes\DropshippingCz\Client('Your shop ID', 'Your API token');
```

#### Categories
```php
$client->fetchProductsCategories(['eshop_id' => 'your shop id', 'limit' => 100, 'offset' => 0]);
```
### How get data from API
Functions in client are similar to original functions from API.
More [Dropshipping.cz API](https://client.api.dropshipping.cz/)

print all categories
#### Get my profile
```php
$limit = 100;
$offset = 0;
do {
$categories = $client->fetchProductsCategories(['eshop_id' => 'your shop id', 'limit' => $limit, 'offset' => $offset]);

foreach ($categories->data as $category) {
// update, insert to DB
var_dump($category);
}

$offset += 100;
} while (count($categories->data) !== 0);
$client->profile->getMe();
```

#### Manufacturers
#### Fetch all my avaialble eshops
```php
$client->fetchProductsManufacturers(['eshop_id' => 'your shop id', 'limit' => 100, 'offset' => 0]);
$client->fetchAllEshops();
```

#### Products Parameters
#### Product, categories, inventory etc.
```php
$client->fetchProductsParameters(['eshop_id' => 'your shop id', 'limit' => 100, 'offset' => 0]);
```
// Fetch one detail product
$client->products->fetch(1715227); // Return detail product data

#### Products
```php
$client->fetchProducts(['eshop_id' => 'your shop id', 'limit' => 100, 'offset' => 0]);
```
// Fetch products
$client->products->fetchAll(array('limit' => 100, 'offset' => 0)); // Return with custom pagination
$client->products->fetchAll(); // Return all manufacturers

#### Payments
```php
$client->fetchAllPayments(['eshop_id' => 'your shop id']);
```
// Fetch product inventory
$client->products->fetchInventory(array(1715227, 1715228));

#### Deliveries
```php
$client->fetchAllDeliveries(['eshop_id' => 'your shop id']);
// Fetch product categories
$client->products->fetchCategories(array('limit' => 100, 'offset' => 0)); // Return with custom pagination
$client->products->fetchCategories(); // Return all manufacturers

// Fetch product manufacturers
$client->products->fetchManufacturers(array('limit' => 100, 'offset' => 0)); // Return with custom pagination
$client->products->fetchManufacturers(); // Return all manufacturers

// Fetch product parameters
$client->products->fetchParameters(array('limit' => 100, 'offset' => 0)); // Return with custom pagination
$client->products->fetchParameters(); // Return all manufacturers

// Fetch XML Collection
$client->products->fetchXmlCollection();
```

#### Delivery places
#### Payment
```php
$client->fetchAllDeliveryPlaces(['delivery_id' => 'delivery id', 'limit' => 100, 'offset' => 0]);
$client->payments->fetchAll(); // Return all payment methods
$client->payments->fetchAll('partnerId'); // or get all by partnerId
```

#### Deliveries
#### Delivery
```php
$client->fetchAllDeliveries(['eshop_id' => 'your shop id']);
// Fetch all deliveries methods
$client->deliveries->fetchAll(); // Return all delivery methods
$client->deliveries->fetchAll('partnerId'); // or get all by partnerId;
$client->deliveries->fetchAllPlaces(10); // Fetch all delivery places by delivery methodId
```

#### New order
#### Orders
```php
$order = $client->postNewOrder([
'remote_id' => '123456789', // Unikátní identifikátor z Vašeho systému. Např. číslo objednávky. Použitím tohoto paremetru zamezíte vzniku duplicitních objednávek.
'eshop_id' => $shopId, // ID vašeho obchodu
// Get all orders
$client->orders->fetchAll();

// Get all orders filtered by parameters
/**
* eshop_id => ID obchodu (pro zobrazení objednávek konkrétního obchodu)
* serial_number => Číslo objednávky
* sort => Řazení záznámů. Směr řazení se určuje znakem "-" před názvem proměnné ("sort=created" = "created ASC"; "sort=-created" = "created DESC"). Defaultní řazení je "id ASC".
* created_from => Určuje datum, od kterého se mají objednávky vyhledat. Formát yyyy-mm-dd (např. 2017-01-01).
* created_to => Určuje datum, do kterého se mají objednávky vyhledat. Formát yyyy-mm-dd (např. 2017-01-01).
* remote_id => ID objednávky z Vašeho systému
**/
$client->orders->fetchAll(array(
'created_from' => '2021-01-01'
));

// Update order data
$client->orders->edit(411737, array(
'email' => 'jan.novak@gmail.com',
'invoice_ico' => '123456',
'invoice_dic' => '654321',
'invoice_company' => 'Jan Novak s.r.o',
));

// Change order status
$client->orders->editStatus(411737, 1); // orderId, orderStatusId from fetchAllStatuses

// Cancel order
$client->orders->cancel(411737); // required parameter orderId

// Return detail information about order
$client->orders->fetch(411737); // required parameter orderId


// Return all available statuses of orders
$client->orders->fetchAllStatuses();

// Create new order
$this->client->orders->create(array(
'remote_id' => '1234', // Unikátní identifikátor z Vašeho systému. Např. číslo objednávky. Použitím tohoto paremetru zamezíte vzniku duplicitních objednávek.
'auto_resend' => 0, // Má se objednávka poslat dále ke zpracování nebo má čekat na Vaše potvrzení? Pokud nebude parametr uveden, objednávka bude vždy automaticky poslána ke zpracování. (0 = NE; 1 = ANO)
'email' => 'jan.novak@gmail.com', // E-mail zákazníka
'phone' => '777 777 777', // Telefon zákazníka
'invoice_firstname' => 'Jan', // Fakturační jméno zákazníka
'invoice_surname' => 'Novák', // Fakturační příjmení zákazníka
'invoice_ico' => '123456', // Fakturační IČO zákazníka
'invoice_dic' => '654321', // Fakturační DIČ zákazníka
'invoice_company' => 'Jan Novak', // Fakturační společnost zákazníka
'invoice_street' => 'Korunní 21', // Fakturační ulice zákazníka
'invoice_city' => 'Praha 2', // Fakturační město zákazníka
'invoice_zipcode' => '128 00', // Fakturační PSČ zákazníka
// Fakturacni udaje
'invoice_firstname' => 'Jan',
'invoice_surname' => 'Novak',
'invoice_ico' => '123456',
'invoice_dic' => '654321',
'invoice_company' => 'Jan Novak s.r.o',
'invoice_street' => 'Koruni 21',
'invoice_city' => 'Praha 2',
'invoice_zipcode' => '12800',
'contact_like_invoice' => 0, // Doručovací adresa stejná jako fakturační (0 = NE; 1 = ANO)
'contact_company' => 'Jan Novak', // Doručovací společnost zákazníka
'contact_firstname' => 'Jana', // Doručovací jméno zákazníka
'contact_surname' => 'Nováková', // Doručovací příjmení zákazníka
'contact_street' => 'Vinohradská 47', // Doručovací ulice zákazníka
'contact_city' => 'Praha 2"', // Doručovací město zákazníka
'contact_zipcode' => '128 00', // Doručovací PSČ zákazníka
'contact_ico' => '123456', // Doručovací IČO zákazníka
'contact_dic' => '654321', // Doručovací DIČ zákazníka
// Kontaktni informace / dorucovani adresa
'contact_firstname' => 'Jan',
'contact_surname' => 'Novak',
'contact_ico' => '123456',
'contact_dic' => '654321',
'contact_company' => 'Jan Novak s.r.o',
'contact_street' => 'Koruni 21',
'contact_city' => 'Praha 2',
'contact_zipcode' => '12800',
'zpl_note' => '', // Poznámka na balik
'note' => '', // Poznámka k objednávce
'payment_id' => '', // ID aktivní platební metody partnera
'payment_price_vat' => '', // Cena platební metody s DPH
'delivery_id' => '', // ID aktivní doručovací metody partnera
'delivery_place_id' => '', // ID odběrného místa (ze systému dropshipping.cz). Viz Doručovací metody - odběrné místa
'delivery_place_id' => '1', // ID odběrného místa (ze systému dropshipping.cz). Viz Doručovací metody - odběrné místa
'delivery_place_ext_id' => null, // ID odběrného místa (z externí služby, například zasilkovna.cz).
'delivery_price_vat' => '', // Cena doručovací metody s DPH
'basket' => [
[ // pole produktů v košíku
'id' => 1, // ID aktivního produktu dodavatele. Nepovinné, pokud je uveden kód produktu
'code' => 'DS12345678', // Kód aktivního produktu dodavatele. Nepovinné, pokud je uvedeno ID produktu
'price_retail_vat' => 123.00, // Cena produktu s DPH
'quantity' => 3, // Počet kusů produktu
]
],
'test' => 1 // Testovací objednávka. V případě označení objednávky jako testovací ("test": "1"), nebude objednávka předána dodavateli.
]);
```

#### Orders status
```php
$client->fetchAllOrdersStatuses();
'basket' => array(
array( // pole produktů v košíku
'code' => 'DS54535757', // Kód aktivního produktu dodavatele. Nepovinné, pokud je uvedeno ID produktu
'price_retail_vat' => 123.00, // Cena produktu s DPH
'quantity' => 3, // Počet kusů produktu
)
)
), true); // true/false if it testing order
```

#### Fetch detail orders or by sorting
```php
$client->fetchOrders(['eshop_id' => 'your shop id', 'limit' => 100, 'offset' => 0]); // you can add id order, sort, created_from, created_to
```

I hope this package help you.

5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mafikes/dropshipping-cz",
"description": "Dropshipping.cz - API client",
"description": "API client for Dropshipping.cz",
"type": "library",
"require": {
"php": ">=5.4.0",
Expand All @@ -18,5 +18,8 @@
"psr-4": {
"Mafikes\\DropshippingCz\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^9.5"
}
}
Loading

0 comments on commit 988fcb7

Please sign in to comment.