Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cancelPack method #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Shoplo/PaczkaWRuchu/Model/CancelPackRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php


namespace Shoplo\PaczkaWRuchu\Model;


class CancelPackRequest extends BaseRequest
{
/** @var string */
public $PackCode;

/**
* BusinessPackLabelRequest constructor.
* @param string $PackCode
*/
public function __construct(string $PackCode)
{
$this->PackCode = $PackCode;
}
}
17 changes: 17 additions & 0 deletions src/Shoplo/PaczkaWRuchu/Model/CancelPackResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php


namespace Shoplo\PaczkaWRuchu\Model;


class CancelPackResponse extends AbstractArrayResponse
{
public $Err;
public $ErrDes;
public $PackCode;

public function __construct(array $response)
{
parent::__construct($response);
}
}
17 changes: 17 additions & 0 deletions src/Shoplo/PaczkaWRuchu/PaczkaWRuchuClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Shoplo\PaczkaWRuchu\Model\BusinessPackResponse;
use Shoplo\PaczkaWRuchu\Model\BusinessPackStatusRequest;
use Shoplo\PaczkaWRuchu\Model\BusinessPackStatusResponse;
use Shoplo\PaczkaWRuchu\Model\CancelPackRequest;
use Shoplo\PaczkaWRuchu\Model\CancelPackResponse;
use Shoplo\PaczkaWRuchu\Model\GenerateProtocolRequest;
use Shoplo\PaczkaWRuchu\Model\GenerateProtocolResponse;

Expand Down Expand Up @@ -162,4 +164,19 @@ public function getBusinessPackStatus(BusinessPackStatusRequest $businessPackSta

return $response;
}

public function cancelPack(CancelPackRequest $cancelPackRequest): CancelPackResponse
{
$cancelPackRequest->setAuthParams($this->partnerId, $this->partnerKey);

$rsp = $this->PutCustomerPackCanceled($cancelPackRequest);

$response = null;
if ($rsp->PutCustomerPackCanceledResult && $rsp->PutCustomerPackCanceledResult->any) {
$rspXml = simplexml_load_string($rsp->PutCustomerPackCanceledResult->any);
$response = new CancelPackResponse((array)$rspXml->NewDataSet);
}

return $response;
}
}