Skip to content
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
84 changes: 84 additions & 0 deletions src/Api/ActualSender.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

namespace Andyts93\BrtApiWrapper\Api;

class ActualSender
{
/** @var string */
private $actualSenderName;

/** @var string */
private $actualSenderEmail;

/** @var string */
private $actualSenderMobilePhoneNumber;

/**
* Get the value of actualSenderMobilePhoneNumber
*/
public function getActualSenderMobilePhoneNumber()
{
return $this->actualSenderMobilePhoneNumber;
}

/**
* Set the value of actualSenderMobilePhoneNumber
*
* @return self
*/
public function setActualSenderMobilePhoneNumber($actualSenderMobilePhoneNumber)
{
$this->actualSenderMobilePhoneNumber = $actualSenderMobilePhoneNumber;

return $this;
}

/**
* Get the value of actualSenderEmail
*/
public function getActualSenderEmail()
{
return $this->actualSenderEmail;
}

/**
* Set the value of actualSenderEmail
*
* @return self
*/
public function setActualSenderEmail($actualSenderEmail)
{
$this->actualSenderEmail = $actualSenderEmail;

return $this;
}

/**
* Get the value of actualSenderName
*/
public function getActualSenderName()
{
return $this->actualSenderName;
}

/**
* Set the value of actualSenderName
*
* @return self
*/
public function setActualSenderName($actualSenderName)
{
$this->actualSenderName = $actualSenderName;

return $this;
}

public function toArray()
{
return [
'actualSenderName' => $this->actualSenderName,
'actualSenderEmail' => $this->actualSenderEmail,
'actualSenderMobilePhoneNumber' => $this->actualSenderMobilePhoneNumber
];
}
}
22 changes: 20 additions & 2 deletions src/Api/LabelParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ class LabelParameter
*/
private $isBarcodeControlRowRequired;

/**
* @var string
*/
private $labelFormat;

public function __construct(
$outputType = 'ZPL',
$offsetX = 0,
$offsetY = 0,
$isBorderRequired = 0,
$isLogoRequired = 0,
$isBarcodeControlRowRequired = 0
$isBarcodeControlRowRequired = 0,
$labelFormat = ''
) {

$this->outputType = $outputType;
Expand All @@ -49,6 +55,7 @@ public function __construct(
$this->isBorderRequired = $isBorderRequired;
$this->isLogoRequired = $isLogoRequired;
$this->isBarcodeControlRowRequired = $isBarcodeControlRowRequired;
$this->labelFormat = $labelFormat;
}

/**
Expand Down Expand Up @@ -111,6 +118,16 @@ public function setIsBarcodeControlRowRequired($isBarcodeControlRowRequired)
return $this;
}

/**
* @param string $labelFormat
* @return LabelParameter
*/
public function setLabelFormat($labelFormat)
{
$this->labelFormat = $labelFormat;
return $this;
}

public function toArray()
{
return [
Expand All @@ -119,7 +136,8 @@ public function toArray()
'offsetY' => $this->offsetY,
'isBorderRequired' => $this->isBorderRequired ? 1 : 0,
'isLogoRequired' => $this->isLogoRequired ? 1 : 0,
'isBarcodeControlRowRequired' => $this->isBarcodeControlRowRequired ? 1 : 0
'isBarcodeControlRowRequired' => $this->isBarcodeControlRowRequired ? 1 : 0,
'labelFormat' => $this->labelFormat
];
}
}
33 changes: 33 additions & 0 deletions src/Request/ParcelIDRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Andyts93\BrtApiWrapper\Request;

use Andyts93\BrtApiWrapper\Exception\InvalidJsonException;
use Andyts93\BrtApiWrapper\Response\ParcelIDResponse;
use GuzzleHttp\Client;

class ParcelIDRequest extends BaseRequest
{
protected $endpoint = 'tracking/parcelID/';
protected $method = 'GET';
protected $mandatoryFields = [];

public function callWithPath($parcelID)
{
$client = new Client();

$request = $client->createRequest($this->method, 'https://api.brt.it/rest/v1/'.$this->endpoint.'/'.$parcelID);
$request->addHeader('userID', $this->account['userID']);
$request->addHeader('password', $this->account['password']);

$response = $client->send($request);

$response = json_decode($response->getBody());

if (json_last_error() !== JSON_ERROR_NONE) {
throw new InvalidJsonException(json_last_error_msg(), json_last_error());
}

return new ParcelIDResponse($response);
}
}
Loading