diff --git a/src/Mappers/Loyalty/Receptions/CreditReceptionMapper.php b/src/Mappers/Loyalty/Receptions/CreditReceptionMapper.php index 084ecfc..9637202 100644 --- a/src/Mappers/Loyalty/Receptions/CreditReceptionMapper.php +++ b/src/Mappers/Loyalty/Receptions/CreditReceptionMapper.php @@ -37,16 +37,7 @@ public function map(stdClass $data): CreditReception $attributes = []; foreach ($data as $propertyName => $value) { - if (in_array($propertyName, ['type', 'credits', 'uuid', 'contact', 'shop', 'contact_identifier', 'created_at', 'unit_value', 'unit'])) { - continue; - } - $attributes[$propertyName] = $value; - } - - $attributes = []; - - foreach ($data as $propertyName => $value) { - if (in_array($propertyName, ['type', 'credits', 'uuid', 'contact', 'shop', 'contact_identifier', 'created_at', 'unit_value', 'unit'])) { + if (in_array($propertyName, ['type', 'credits', 'uuid', 'contact', 'shop', 'contact_identifier', 'created_at', 'unit_value', 'unit', 'channel'])) { continue; } $attributes[$propertyName] = $value; @@ -58,6 +49,7 @@ public function map(stdClass $data): CreditReception $data->uuid, $contact ?? null, $shop ?? null, + $data->channel, $contactIdentifier ?? null, $this->parseDate($data->created_at), $data->unit_value ?? null, diff --git a/src/Mappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php b/src/Mappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php index 75cd1dd..e0819e1 100644 --- a/src/Mappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php +++ b/src/Mappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php @@ -44,6 +44,7 @@ public function map(stdClass $data): DigitalRewardReception $data->uuid, $contact, $shop, + $data->channel, $contactIdentifier, $this->parseDate($data->created_at), $data->title, diff --git a/src/Mappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php b/src/Mappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php index 95ef3d8..ff7e9b7 100644 --- a/src/Mappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php +++ b/src/Mappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php @@ -35,6 +35,7 @@ public function map(stdClass $data): PhysicalRewardReception $data->uuid, $contact, $shop, + $data->channel, $contactIdentifier, $this->parseDate($data->created_at), $data->title, diff --git a/src/Models/Loyalty/Receptions/CreditReception.php b/src/Models/Loyalty/Receptions/CreditReception.php index 2e76b24..7bb0912 100644 --- a/src/Models/Loyalty/Receptions/CreditReception.php +++ b/src/Models/Loyalty/Receptions/CreditReception.php @@ -41,6 +41,11 @@ class CreditReception extends BaseReception */ private $shop; + /** + * @var string + */ + private $channel; + /** * @var ContactIdentifier|null */ @@ -68,13 +73,14 @@ class CreditReception extends BaseReception /** * @param mixed[] $attributes */ - public function __construct(string $type, int $credits, string $uuid, ?Contact $contact, ?Shop $shop, ?ContactIdentifier $contactIdentifier, DateTime $createdAt, ?float $unitValue = null, ?Unit $unit = null, array $attributes = []) + public function __construct(string $type, int $credits, string $uuid, ?Contact $contact, ?Shop $shop, string $channel, ?ContactIdentifier $contactIdentifier, DateTime $createdAt, ?float $unitValue = null, ?Unit $unit = null, array $attributes = []) { $this->type = $type; $this->credits = $credits; $this->uuid = $uuid; $this->contact = $contact; $this->shop = $shop; + $this->channel = $channel; $this->contactIdentifier = $contactIdentifier; $this->createdAt = $createdAt; $this->unitValue = $unitValue; @@ -107,6 +113,11 @@ public function getShop(): ?Shop return $this->shop; } + public function getChannel(): string + { + return $this->channel; + } + public function getContactIdentifier(): ?ContactIdentifier { return $this->contactIdentifier; diff --git a/src/Models/Loyalty/Receptions/DigitalRewardReception.php b/src/Models/Loyalty/Receptions/DigitalRewardReception.php index 4618d73..4d10e78 100644 --- a/src/Models/Loyalty/Receptions/DigitalRewardReception.php +++ b/src/Models/Loyalty/Receptions/DigitalRewardReception.php @@ -36,6 +36,11 @@ class DigitalRewardReception extends BaseReception */ protected $shop; + /** + * @var string + */ + protected $channel; + /** * @var ContactIdentifier|null */ @@ -61,13 +66,14 @@ class DigitalRewardReception extends BaseReception */ protected $digitalRewardCode; - public function __construct(string $type, int $credits, string $uuid, Contact $contact, Shop $shop, ?ContactIdentifier $contactIdentifier, DateTime $createdAt, string $title, ?DigitalReward $digitalReward, ?DigitalRewardCode $digitalRewardCode) + public function __construct(string $type, int $credits, string $uuid, Contact $contact, Shop $shop, string $channel, ?ContactIdentifier $contactIdentifier, DateTime $createdAt, string $title, ?DigitalReward $digitalReward, ?DigitalRewardCode $digitalRewardCode) { $this->type = $type; $this->credits = $credits; $this->uuid = $uuid; $this->contact = $contact; $this->shop = $shop; + $this->channel = $channel; $this->contactIdentifier = $contactIdentifier; $this->createdAt = $createdAt; $this->title = $title; @@ -100,6 +106,11 @@ public function getShop(): Shop return $this->shop; } + public function getChannel(): string + { + return $this->channel; + } + public function getContactIdentifier(): ?ContactIdentifier { return $this->contactIdentifier; diff --git a/src/Models/Loyalty/Receptions/PhysicalRewardReception.php b/src/Models/Loyalty/Receptions/PhysicalRewardReception.php index 0c9e4d4..a7c1b8b 100644 --- a/src/Models/Loyalty/Receptions/PhysicalRewardReception.php +++ b/src/Models/Loyalty/Receptions/PhysicalRewardReception.php @@ -35,6 +35,11 @@ class PhysicalRewardReception extends BaseReception */ protected $shop; + /** + * @var string + */ + protected $channel; + /** * @var ContactIdentifier|null */ @@ -65,13 +70,14 @@ class PhysicalRewardReception extends BaseReception */ protected $hasBeenCollected; - public function __construct(string $type, int $credits, string $uuid, Contact $contact, Shop $shop, ?ContactIdentifier $contactIdentifier, DateTime $createdAt, string $title, Reward $reward, ?DateTime $expiresAt, bool $hasBeenCollected) + public function __construct(string $type, int $credits, string $uuid, Contact $contact, Shop $shop, string $channel, ?ContactIdentifier $contactIdentifier, DateTime $createdAt, string $title, Reward $reward, ?DateTime $expiresAt, bool $hasBeenCollected) { $this->type = $type; $this->credits = $credits; $this->uuid = $uuid; $this->contact = $contact; $this->shop = $shop; + $this->channel = $channel; $this->contactIdentifier = $contactIdentifier; $this->createdAt = $createdAt; $this->title = $title; @@ -105,6 +111,11 @@ public function getShop(): Shop return $this->shop; } + public function getChannel(): string + { + return $this->channel; + } + public function getContactIdentifier(): ?ContactIdentifier { return $this->contactIdentifier; diff --git a/src/StaticMappers/Loyalty/Receptions/CreditReceptionMapper.php b/src/StaticMappers/Loyalty/Receptions/CreditReceptionMapper.php index 29eb13e..ab1cf15 100644 --- a/src/StaticMappers/Loyalty/Receptions/CreditReceptionMapper.php +++ b/src/StaticMappers/Loyalty/Receptions/CreditReceptionMapper.php @@ -54,6 +54,7 @@ public static function map(stdClass $data): CreditReception $data->uuid, $contact ?? null, $shop ?? null, + $data->channel, $contactIdentifier ?? null, self::parseDate($data->created_at), $data->unit_value ?? null, diff --git a/src/StaticMappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php b/src/StaticMappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php index e19f039..75adda6 100644 --- a/src/StaticMappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php +++ b/src/StaticMappers/Loyalty/Receptions/DigitalRewardReceptionMapper.php @@ -37,6 +37,7 @@ public static function map(stdClass $data): DigitalRewardReception $data->uuid, $contact, $shop, + $data->channel, $contactIdentifier, self::parseDate($data->created_at), $data->title, diff --git a/src/StaticMappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php b/src/StaticMappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php index 6de847a..fd69231 100644 --- a/src/StaticMappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php +++ b/src/StaticMappers/Loyalty/Receptions/PhysicalRewardReceptionMapper.php @@ -29,6 +29,7 @@ public static function map(stdClass $data): PhysicalRewardReception $data->uuid, $contact, $shop, + $data->channel, $contactIdentifier, self::parseDate($data->created_at), $data->title, diff --git a/tests/OAuth/Loyalty/Receptions/CreditReceptionsResourceTest.php b/tests/OAuth/Loyalty/Receptions/CreditReceptionsResourceTest.php index bfa5972..a2b68ab 100644 --- a/tests/OAuth/Loyalty/Receptions/CreditReceptionsResourceTest.php +++ b/tests/OAuth/Loyalty/Receptions/CreditReceptionsResourceTest.php @@ -27,6 +27,7 @@ public function it_returns_a_credit_reception() 'name' => 'shopName', 'uuid' => '123-312', ], + 'channel' => 'BUSINESS_DASHBOARD', 'created_at' => '2022-06-30T13:42:04+00:00', 'unit_value' => 1011, 'unit' => [ @@ -44,6 +45,7 @@ public function it_returns_a_credit_reception() $this->assertEquals('123-123', $creditReception->getContact()->getUuid()); $this->assertEquals('123-312', $creditReception->getShop()->getUuid()); $this->assertEquals('shopName', $creditReception->getShop()->getName()); + $this->assertEquals('BUSINESS_DASHBOARD', $creditReception->getChannel()); $this->assertEquals('2022-06-30T13:42:04+00:00', $creditReception->getCreatedAt()->format('c')); $this->assertEquals(1011, $creditReception->getUnitValue()); $this->assertEquals('bonkers', $creditReception->getUnit()->getName()); diff --git a/tests/OAuth/Loyalty/Receptions/RewardReceptionsResourceTest.php b/tests/OAuth/Loyalty/Receptions/RewardReceptionsResourceTest.php index bbe011d..d5204b5 100644 --- a/tests/OAuth/Loyalty/Receptions/RewardReceptionsResourceTest.php +++ b/tests/OAuth/Loyalty/Receptions/RewardReceptionsResourceTest.php @@ -27,6 +27,7 @@ public function it_returns_a_physical_reward_reception() 'name' => 'shopName', 'uuid' => '123-312', ], + 'channel' => 'BUSINESS_DASHBOARD', 'created_at' => '2022-06-30T13:42:04+00:00', 'title' => 'reward title', 'reward' => [ @@ -72,6 +73,7 @@ public function it_returns_a_digital_reward_reception_without_a_reward_linked() 'name' => 'shopName', 'uuid' => '123-312', ], + 'channel' => 'BUSINESS_DASHBOARD', 'created_at' => '2022-06-30T13:42:04+00:00', 'title' => 'digital reward title', ]); @@ -109,6 +111,7 @@ public function it_returns_a_digital_reward_reception() 'name' => 'shopName', 'uuid' => '123-312', ], + 'channel' => 'BUSINESS_DASHBOARD', 'created_at' => '2022-06-30T13:42:04+00:00', 'title' => 'digital reward title', 'digital_reward' => [ @@ -128,6 +131,7 @@ public function it_returns_a_digital_reward_reception() $this->assertEquals('123-123', $rewardReception->getContact()->getUuid()); $this->assertEquals('123-312', $rewardReception->getShop()->getUuid()); $this->assertEquals('shopName', $rewardReception->getShop()->getName()); + $this->assertEquals('BUSINESS_DASHBOARD', $rewardReception->getChannel()); $this->assertEquals('2022-06-30T13:42:04+00:00', $rewardReception->getCreatedAt()->format('c')); $this->assertEquals('digital reward title', $rewardReception->getTitle()); $this->assertEquals('DIGITAL', $rewardReception->getDigitalReward()->getRewardType()); diff --git a/tests/OAuth/Loyalty/Tokens/LoyaltyTokenResourceTest.php b/tests/OAuth/Loyalty/Tokens/LoyaltyTokenResourceTest.php index 6e3d65f..7c8bbd7 100644 --- a/tests/OAuth/Loyalty/Tokens/LoyaltyTokenResourceTest.php +++ b/tests/OAuth/Loyalty/Tokens/LoyaltyTokenResourceTest.php @@ -64,6 +64,7 @@ public function it_can_claim_a_credit_based_loyalty_token_url_and_returns_a_cred 'name' => 'Visjes', 'uuid' => '1', ], + 'channel' => 'BUSINESS_DASHBOARD', 'contact_identifier' => null, 'created_at' => '2023-01-10T15:59:58+00:00', 'uuid' => '0c655a10-7980-4fdb-ac11-2caca19f2329', @@ -104,6 +105,7 @@ public function it_can_claim_a_unit_based_loyalty_token_url_and_returns_a_credit 'name' => 'Visjes', 'uuid' => '1', ], + 'channel' => 'BUSINESS_DASHBOARD', 'created_at' => '2023-01-12T14:59:03+00:00', 'uuid' => '0c655a10-7980-4fdb-ac11-2caca19f2329', 'unit_value' => 200.0,