@@ -9,8 +9,18 @@ class SMSText extends BaseMessage
99{
1010 use TextTrait;
1111
12+ protected array $ permittedEncodingTypes = [
13+ 'text ' ,
14+ 'unicode ' ,
15+ 'auto '
16+ ];
17+
1218 protected string $ subType = BaseMessage::MESSAGES_SUBTYPE_TEXT ;
1319 protected string $ channel = 'sms ' ;
20+ protected ?int $ ttl = null ;
21+ protected ?string $ encodingType = null ;
22+ protected ?string $ contentId = null ;
23+ protected ?string $ entityId = null ;
1424
1525 public function __construct (
1626 string $ to ,
@@ -22,11 +32,71 @@ public function __construct(
2232 $ this ->text = $ message ;
2333 }
2434
35+ public function getEncodingType (): ?string
36+ {
37+ return $ this ->encodingType ;
38+ }
39+
40+ public function setEncodingType (?string $ encodingType ): void
41+ {
42+ if (! in_array ($ encodingType , $ this ->permittedEncodingTypes , true )) {
43+ throw new \InvalidArgumentException ($ encodingType . ' is not a valid encoding type ' );
44+ }
45+
46+ $ this ->encodingType = $ encodingType ;
47+ }
48+
49+ public function getContentId (): ?string
50+ {
51+ return $ this ->contentId ;
52+ }
53+
54+ public function setContentId (?string $ contentId ): void
55+ {
56+ $ this ->contentId = $ contentId ;
57+ }
58+
59+ public function getEntityId (): ?string
60+ {
61+ return $ this ->entityId ;
62+ }
63+
64+ public function setEntityId (?string $ entityId ): void
65+ {
66+ $ this ->entityId = $ entityId ;
67+ }
68+
69+ public function getTtl (): ?int
70+ {
71+ return $ this ->ttl ;
72+ }
73+
74+ public function setTtl (?int $ ttl ): void
75+ {
76+ $ this ->ttl = $ ttl ;
77+ }
78+
2579 public function toArray (): array
2680 {
2781 $ returnArray = $ this ->getBaseMessageUniversalOutputArray ();
2882 $ returnArray ['text ' ] = $ this ->getText ();
2983
84+ if ($ this ->getEncodingType ()) {
85+ $ returnArray ['sms ' ]['encoding_type ' ] = $ this ->getEncodingType ();
86+ }
87+
88+ if ($ this ->getContentId ()) {
89+ $ returnArray ['sms ' ]['content_id ' ] = $ this ->getContentId ();
90+ }
91+
92+ if ($ this ->getEntityId ()) {
93+ $ returnArray ['sms ' ]['entity_id ' ] = $ this ->getEntityId ();
94+ }
95+
96+ if ($ this ->getTtl ()) {
97+ $ returnArray ['ttl ' ] = $ this ->getTtl ();
98+ }
99+
30100 return $ returnArray ;
31101 }
32102}
0 commit comments