File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace Piggy \Api \Mappers \Vouchers ;
44
5+ use Piggy \Api \Mappers \Loyalty \MediaMapper ;
56use Piggy \Api \Models \Vouchers \Promotion ;
67use stdClass ;
78
@@ -13,6 +14,10 @@ public function map(stdClass $data): Promotion
1314 $ attributes = get_object_vars ($ data ->attributes );
1415 }
1516
17+ if (isset ($ data ->media )) {
18+ $ media = (new MediaMapper )->map ($ data ->media );
19+ }
20+
1621 return new Promotion (
1722 $ data ->uuid ,
1823 $ data ->name ,
@@ -22,7 +27,8 @@ public function map(stdClass $data): Promotion
2227 $ data ->expiration_duration ?? null ,
2328 $ attributes ?? [],
2429 $ data ->type ,
25- $ data ->redemptions_per_voucher
30+ $ data ->redemptions_per_voucher ,
31+ $ media ?? null
2632 );
2733 }
2834}
Original file line number Diff line number Diff line change 66use Piggy \Api \ApiClient ;
77use Piggy \Api \Exceptions \MaintenanceModeException ;
88use Piggy \Api \Exceptions \PiggyRequestException ;
9+ use Piggy \Api \Models \Loyalty \Media ;
910use Piggy \Api \StaticMappers \Vouchers \PromotionMapper ;
1011use Piggy \Api \StaticMappers \Vouchers \PromotionsMapper ;
1112
@@ -56,6 +57,11 @@ class Promotion
5657 */
5758 protected $ attributes ;
5859
60+ /**
61+ * @var Media|null
62+ */
63+ protected $ media ;
64+
5965 /**
6066 * @var string
6167 */
@@ -73,7 +79,8 @@ public function __construct(
7379 ?int $ expiration_duration = null ,
7480 array $ attributes = [],
7581 ?string $ type = null ,
76- ?int $ redemptions_per_voucher = null
82+ ?int $ redemptions_per_voucher = null ,
83+ ?Media $ media = null
7784 ) {
7885 $ this ->uuid = $ uuid ;
7986 $ this ->name = $ name ;
@@ -84,6 +91,7 @@ public function __construct(
8491 $ this ->attributes = $ attributes ;
8592 $ this ->type = $ type ;
8693 $ this ->redemptions_per_voucher = $ redemptions_per_voucher ;
94+ $ this ->media = $ media ;
8795 }
8896
8997 public function getName (): string
@@ -134,6 +142,11 @@ public function getAttributes(): array
134142 return $ this ->attributes ;
135143 }
136144
145+ public function getMedia (): ?Media
146+ {
147+ return $ this ->media ;
148+ }
149+
137150 /**
138151 * @param mixed[] $body
139152 *
Original file line number Diff line number Diff line change 22
33namespace Piggy \Api \StaticMappers \Vouchers ;
44
5+ use Piggy \Api \Mappers \Loyalty \MediaMapper ;
56use Piggy \Api \Models \Vouchers \Promotion ;
67
78class PromotionMapper
@@ -14,6 +15,10 @@ public static function map($data): Promotion
1415 $ attributes = get_object_vars ($ data ->attributes );
1516 }
1617
18+ if (isset ($ data ->media )) {
19+ $ media = (new MediaMapper )->map ($ data ->media );
20+ }
21+
1722 return new Promotion (
1823 $ data ->uuid ,
1924 $ data ->name ,
@@ -23,7 +28,8 @@ public static function map($data): Promotion
2328 $ data ->expiration_duration ?? null ,
2429 isset ($ data ->attributes ) ? $ attributes : [],
2530 $ data ->type ,
26- $ data ->redemptions_per_voucher
31+ $ data ->redemptions_per_voucher ,
32+ $ media ?? null
2733 );
2834 }
2935}
You can’t perform that action at this time.
0 commit comments