for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Pagantis\OrdersApiClient\Method;
use Httpful\Http;
use Httpful\Request;
use Httpful\Response;
use Pagantis\OrdersApiClient\Exception\ClientException;
use Pagantis\OrdersApiClient\Model\Order;
/**
* Class ConfirmOrderMethod
*
* @package Pagantis\OrdersApiClient\Method
*/
class ConfirmOrderMethod extends AbstractMethod
{
* Get Order Endpoint
const ENDPOINT = '/orders';
const CONFIRM_ENDPOINT = 'confirm';
* @var string $orderId
protected $orderId;
* @param string $orderId
* @return $this
public function setOrderId($orderId)
$this->orderId = $orderId;
return $this;
}
* call
* @return $this|AbstractMethod
* @throws \Httpful\Exception\ConnectionErrorException
* @throws \Pagantis\OrdersApiClient\Exception\HttpException
* @throws ClientException
public function call()
if (is_string($this->orderId)) {
is_string($this->orderId)
true
$this->prepareRequest();
return $this->setResponse($this->request->send());
throw new ClientException('Please set OrderId');
* @return bool|Order
* @throws \Exception
public function getOrder()
$response = $this->getResponse();
if ($response instanceof Response) {
$response
Httpful\Response
$order = new Order();
$order->import($this->getResponse()->body);
return $order;
return false;
* prepareRequest
protected function prepareRequest()
if (!$this->request instanceof Request) {
$this->request
Httpful\Request
$this->request = $this->getRequest()
->method(Http::PUT)
->uri(
$this->apiConfiguration->getBaseUri()
. self::ENDPOINT
. self::SLASH
. $this->orderId
. self::CONFIRM_ENDPOINT
)
;