22
33namespace Vonage \Messages \Channel \Viber ;
44
5+ use Vonage \Messages \Channel \Viber \MessageObjects \ViberActionObject ;
56use Vonage \Messages \MessageObjects \ImageObject ;
67use Vonage \Messages \Channel \BaseMessage ;
78
@@ -18,13 +19,15 @@ public function __construct(
1819 protected ImageObject $ image ,
1920 ?string $ category = null ,
2021 ?int $ ttl = null ,
21- ?string $ type = null
22+ ?string $ type = null ,
23+ ?ViberActionObject $ viberActionObject = null
2224 ) {
2325 $ this ->to = $ to ;
2426 $ this ->from = $ from ;
2527 $ this ->category = $ category ;
2628 $ this ->ttl = $ ttl ;
2729 $ this ->type = $ type ;
30+ $ this ->action = $ viberActionObject ;
2831 }
2932
3033 public function toArray (): array
@@ -33,9 +36,10 @@ public function toArray(): array
3336 $ returnArray ['image ' ] = $ this ->image ->toArray ();
3437
3538 if ($ this ->requiresViberServiceObject ()) {
36- $ returnArray ['viber_service ' ]['category ' ] = $ this ->getCategory ();
37- $ returnArray ['viber_service ' ]['ttl ' ] = $ this ->getTtl ();
38- $ returnArray ['viber_service ' ]['type ' ] = $ this ->getType ();
39+ $ this ->getCategory () ? $ returnArray ['viber_service ' ]['category ' ] = $ this ->getCategory (): null ;
40+ $ this ->getTtl () ? $ returnArray ['viber_service ' ]['ttl ' ] = $ this ->getTtl (): null ;
41+ $ this ->getType () ? $ returnArray ['viber_service ' ]['type ' ] = $ this ->getType (): null ;
42+ $ this ->getAction () ? $ returnArray ['viber_service ' ]['action ' ] = $ this ->getAction ()->toArray (): null ;
3943 }
4044
4145 return array_filter ($ returnArray );
0 commit comments