Skip to content

Commit

Permalink
PickupPoint class now implements exposes and getType() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinOrlowski committed Nov 28, 2023
1 parent f2af4d8 commit 64f4995
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Olza Logistic's Pickup Point API Client PHP library.

# Changelog

* dev
* `PickupPoint` class now implements exposes and `getType()` method.


* v1.3.1 (2023-10-31)
* Refactored to lower PHP requirements down to 7.2+
* Updated tests.
Expand Down
31 changes: 30 additions & 1 deletion src/Model/PickupPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PickupPoint implements ArrayableContract

public const KEY_ID = 'id';
public const KEY_SPEDITION = 'spedition';
public const KEY_TYPE = 'type';

/* ****************************************************************************************** */

Expand Down Expand Up @@ -136,6 +137,32 @@ protected function setSpedition(string $spedition): self
return $this;
}

/* ****************************************************************************************** */

/**
* @var string
*/
protected $type;

/**
* Returns type of the pickup point.
*/
public function getType(): string
{
return $this->type;
}

/**
* Sets type of the pickup point.
*
* @param string $type Type of the pickup point to set (i.e. "point")
*/
protected function setType(string $type): self
{
$this->type = $type;
return $this;
}

/* ****************************************************************************************** */
/* ****************************************************************************************** */
/* ****************************************************************************************** */
Expand Down Expand Up @@ -1019,7 +1046,8 @@ public static function fromApiResponse(array $ppData): self
{
$pp = (new static())
->setSpeditionId($ppData[static::KEY_ID])
->setSpedition($ppData[static::KEY_SPEDITION]);
->setSpedition($ppData[static::KEY_SPEDITION])
->setType($ppData[static::KEY_TYPE]);

if (\array_key_exists(static::KEY_GROUP_NAME, $ppData)) {
$pp->setName1($ppData[static::KEY_GROUP_NAME][0] ?? '???');
Expand Down Expand Up @@ -1107,6 +1135,7 @@ public function toArray(): array
return [
static::KEY_ID => $this->getSpeditionId(),
static::KEY_SPEDITION => $this->getSpedition(),
static::KEY_TYPE => $this->getType(),
static::KEY_GROUP_NAME => $this->getNames(),
static::KEY_GROUP_ADDRESS => [
static::KEY_FULL_ADDRESS => $this->getFullAddress(),
Expand Down
1 change: 1 addition & 0 deletions tests/Util/PickupPointResponseGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ final protected function __construct()
$this->data = [
PP::KEY_ID => $this->getRandomString('id'),
PP::KEY_SPEDITION => $this->getRandomString('sped'),
PP::KEY_TYPE => $this->getRandomString('type'),
];
}

Expand Down
1 change: 1 addition & 0 deletions tests/tests/Model/PickupPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected function assertModelMatchesData(array $expected, PP $pp): void
{
$this->assertEquals($expected[ PP::KEY_ID ], $pp->getSpeditionId());
$this->assertEquals($expected[ PP::KEY_SPEDITION ], $pp->getSpedition());
$this->assertEquals($expected[ PP::KEY_TYPE ], $pp->getType());

if (\array_key_exists(PP::KEY_GROUP_NAME, $expected)) {
$nameLines = $expected[ PP::KEY_GROUP_NAME ];
Expand Down

0 comments on commit 64f4995

Please sign in to comment.