Skip to content

Commit

Permalink
Merge pull request #4 from maksym-k-p/order-create-update
Browse files Browse the repository at this point in the history
Updated client using latest spec
  • Loading branch information
alexanderzaiets-paysera authored Sep 10, 2024
2 parents 5e391f9 + 7dffaa9 commit f8faee9
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

##1.1.0 - 2024-09-10

- Library refreshed according latest documentation.
- Added support for a `orders-prepaid` API method.
- Added possibility to create `prepaid` orders.

##1.0.0 - 2024-01-26

- Library refreshed according latest documentation.
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,21 @@ $result = $merchantClient->createOrdersConfirm($orderIdsList);
```
---


Prepaid orders


```php
use Paysera\DeliveryApi\MerchantClient\Entity as Entities;

$orderIdsList = new Entities\OrderIdsList();

$orderIdsList->setOrderIds($orderIds);

$result = $merchantClient->createOrdersPrepaid($orderIdsList);
```
---


Generate manifest and call courier for "label_generated" order

Expand Down Expand Up @@ -585,6 +600,7 @@ $orderCreate->setNotes($notes);
$orderCreate->setEshopOrderId($eshopOrderId);
$orderCreate->setOrderCreationType($orderCreationType);
$orderCreate->setOrderNotification($orderNotification);
$orderCreate->setOrderInitialStatus(Entities\OrderCreate::ORDER_INITIAL_STATUS_PREPAID);

$result = $merchantClient->createOrder($orderCreate);
```
Expand Down
23 changes: 18 additions & 5 deletions src/Entity/OrderCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ class OrderCreate extends Entity
{
const ORDER_CREATION_TYPE_ESHOP = 'eshop';
const ORDER_CREATION_TYPE_MANUALLY = 'manually';

public function __construct(array $data = [])
{
parent::__construct($data);
}
const ORDER_INITIAL_STATUS_DRAFT = 'draft';
const ORDER_INITIAL_STATUS_PREPAID = 'prepaid';

/**
* @return string
Expand Down Expand Up @@ -229,4 +226,20 @@ public function setOrderNotification(OrderNotificationCreate $orderNotification)
$this->setByReference('order_notification', $orderNotification->getDataByReference());
return $this;
}
/**
* @return string|null
*/
public function getOrderInitialStatus()
{
return $this->get('order_initial_status');
}
/**
* @param string $orderInitialStatus
* @return $this
*/
public function setOrderInitialStatus($orderInitialStatus)
{
$this->set('order_initial_status', $orderInitialStatus);
return $this;
}
}
25 changes: 21 additions & 4 deletions src/MerchantClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function deleteShipmentPoint($id)
sprintf('shipment-points/%s', rawurlencode($id)),
null
);
$data = $this->apiClient->makeRequest($request);
$this->apiClient->makeRequest($request);

return null;
}
Expand Down Expand Up @@ -363,7 +363,7 @@ public function deleteProjectDefaultPackageSize($projectId)
sprintf('projects/%s/default-package-size', rawurlencode($projectId)),
null
);
$data = $this->apiClient->makeRequest($request);
$this->apiClient->makeRequest($request);

return null;
}
Expand Down Expand Up @@ -547,6 +547,23 @@ public function createOrdersConfirm(Entities\OrderIdsList $orderIdsList)
return new Entities\OrderCollection($data);
}

/**
* Prepaid orders
* Only orders with initial statuses will be processed
* POST /orders-prepaid
*
* @param Entities\OrderIdsList $orderIdsList
*/
public function createOrdersPrepaid(Entities\OrderIdsList $orderIdsList)
{
$request = $this->apiClient->createRequest(
RequestMethodInterface::METHOD_POST,
'orders-prepaid',
$orderIdsList
);
$this->apiClient->makeRequest($request);
}

/**
* Generate manifest and call courier for "label_generated" order
* POST /orders/{id}/manifest
Expand Down Expand Up @@ -695,7 +712,7 @@ public function deleteOrder($id)
sprintf('orders/%s', rawurlencode($id)),
null
);
$data = $this->apiClient->makeRequest($request);
$this->apiClient->makeRequest($request);

return null;
}
Expand Down Expand Up @@ -905,7 +922,7 @@ public function deleteCourierApiCredential($id)
sprintf('courier-api-credentials/%s', rawurlencode($id)),
null
);
$data = $this->apiClient->makeRequest($request);
$this->apiClient->makeRequest($request);

return null;
}
Expand Down

0 comments on commit f8faee9

Please sign in to comment.