Skip to content

Commit 9d56308

Browse files
committed
add language to voice parameter
1 parent e6f84b8 commit 9d56308

11 files changed

+300
-3
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/markdown.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php-client.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/phpunit.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ $client->sms($params
3131
<details>
3232
<summary>Analytics</summary>
3333

34-
3534
<ul>
3635
<li>analytics(array options = [], string $groupBy = 'date'): AbstractAnalytic[]</li>
3736
<li>analyticsByCountry(array options = []): AnalyticByCountry[]</li>
@@ -164,4 +163,4 @@ particular API key. SMS77_RECIPIENT is the recipient of the test SMS.
164163

165164
Need help? Feel free to [contact us](https://www.seven.io/en/company/contact/).
166165

167-
[![MIT](https://img.shields.io/badge/License-MIT-teal.svg)](./LICENSE)
166+
[![MIT](https://img.shields.io/badge/License-MIT-teal.svg)](LICENSE)

src/Params/VoiceParams.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class VoiceParams extends AbstractParams implements VoiceParamsInterface {
66
protected $debug;
77
protected $from;
88
protected $json;
9+
protected $language;
910
protected $text;
1011
protected $to;
1112
protected $xml;
@@ -69,4 +70,14 @@ public function setXml(?bool $xml): self {
6970

7071
return $this;
7172
}
73+
74+
public function getLanguage(): ?string {
75+
return $this->language;
76+
}
77+
78+
public function setLanguage(?string $language): self {
79+
$this->language = $language;
80+
81+
return $this;
82+
}
7283
}

src/Params/VoiceParamsInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public function getDebug(): ?bool;
77

88
public function getFrom(): ?string;
99

10+
public function getLanguage(): ?string;
11+
1012
public function getJson(): ?bool;
1113

1214
public function getText(): ?string;
@@ -21,6 +23,8 @@ public function setFrom(?string $from);
2123

2224
public function setJson(?bool $json);
2325

26+
public function setLanguage();
27+
2428
public function setText(string $text);
2529

2630
public function setTo(string $to);

src/Validator/VoiceValidator.php

Lines changed: 211 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,202 @@
77
use Sms77\Api\Params\VoiceParamsInterface;
88

99
class VoiceValidator extends BaseValidator implements ValidatorInterface {
10+
public static $LANGUAGES = [
11+
'af-ZA',
12+
'am-ET',
13+
'ar-AE',
14+
'ar-BH',
15+
'ar-DZ',
16+
'ar-EG',
17+
'ar-IQ',
18+
'ar-JO',
19+
'ar-KW',
20+
'ar-LB',
21+
'ar-LY',
22+
'ar-MA',
23+
'ar-OM',
24+
'ar-QA',
25+
'ar-SA',
26+
'ar-SY',
27+
'ar-TN',
28+
'ar-YE',
29+
'az-AZ',
30+
'bg-BG',
31+
'bn-BD',
32+
'bn-IN',
33+
'bs-BA',
34+
'ca-ES',
35+
'cs-CZ',
36+
'cy-GB',
37+
'da-DK',
38+
'de-AT',
39+
'de-CH',
40+
'de-DE',
41+
'el-GR',
42+
'en-AU',
43+
'en-CA',
44+
'en-GB',
45+
'en-HK',
46+
'en-IE',
47+
'en-IN',
48+
'en-KE',
49+
'en-NG',
50+
'en-NZ',
51+
'en-PH',
52+
'en-SG',
53+
'en-TZ',
54+
'en-US',
55+
'en-ZA',
56+
'es-AR',
57+
'es-BO',
58+
'es-CL',
59+
'es-CO',
60+
'es-CR',
61+
'es-CU',
62+
'es-DO',
63+
'es-EC',
64+
'es-ES',
65+
'es-GQ',
66+
'es-GT',
67+
'es-HN',
68+
'es-MX',
69+
'es-NI',
70+
'es-PA',
71+
'es-PE',
72+
'es-PR',
73+
'es-PY',
74+
'es-SV',
75+
'es-US',
76+
'es-UY',
77+
'es-VE',
78+
'et-EE',
79+
'eu-ES',
80+
'fa-IR',
81+
'fi-FI',
82+
'fil-PH',
83+
'fr-BE',
84+
'fr-CA',
85+
'fr-CH',
86+
'fr-FR',
87+
'ga-IE',
88+
'gl-ES',
89+
'gu-IN',
90+
'he-IL',
91+
'hi-IN',
92+
'hr-HR',
93+
'hu-HU',
94+
'hy-AM',
95+
'id-ID',
96+
'is-IS',
97+
'it-IT',
98+
'ja-JP',
99+
'jv-ID',
100+
'ka-GE',
101+
'kk-KZ',
102+
'km-KH',
103+
'kn-IN',
104+
'ko-KR',
105+
'lo-LA',
106+
'lt-LT',
107+
'lv-LV',
108+
'mk-MK',
109+
'ml-IN',
110+
'mn-MN',
111+
'mr-IN',
112+
'ms-MY',
113+
'mt-MT',
114+
'my-MM',
115+
'nb-NO',
116+
'ne-NP',
117+
'nl-BE',
118+
'nl-NL',
119+
'pl-PL',
120+
'ps-AF',
121+
'pt-BR',
122+
'pt-PT',
123+
'ro-RO',
124+
'ru-RU',
125+
'si-LK',
126+
'sk-SK',
127+
'sl-SI',
128+
'so-SO',
129+
'sq-AL',
130+
'sr-RS',
131+
'su-ID',
132+
'sv-SE',
133+
'sw-KE',
134+
'sw-TZ',
135+
'ta-IN',
136+
'ta-LK',
137+
'ta-MY',
138+
'ta-SG',
139+
'te-IN',
140+
'th-TH',
141+
'tr-TR',
142+
'uk-UA',
143+
'ur-IN',
144+
'ur-PK',
145+
'uz-UZ',
146+
'vi-VN',
147+
'wuu-CN',
148+
'yue-CN',
149+
'zh-CN',
150+
'zh-HK',
151+
'zh-TW',
152+
'zu-ZA',
153+
'ar-EG',
154+
'ar-SA',
155+
'bg-BG',
156+
'ca-ES',
157+
'cs-CZ',
158+
'da-DK',
159+
'de-AT',
160+
'de-CH',
161+
'de-DE',
162+
'el-GR',
163+
'en-AU',
164+
'en-CA',
165+
'en-GB',
166+
'en-IE',
167+
'en-IN',
168+
'en-US',
169+
'es-ES',
170+
'es-MX',
171+
'fi-FI',
172+
'fr-BE',
173+
'fr-CA',
174+
'fr-CH',
175+
'fr-FR',
176+
'he-IL',
177+
'hi-IN',
178+
'hr-HR',
179+
'hu-HU',
180+
'id-ID',
181+
'it-IT',
182+
'ja-JP',
183+
'ko-KR',
184+
'ms-MY',
185+
'nb-NO',
186+
'nl-BE',
187+
'nl-NL',
188+
'pl-PL',
189+
'pt-BR',
190+
'pt-PT',
191+
'ro-RO',
192+
'ru-RU',
193+
'sk-SK',
194+
'sl-SI',
195+
'sv-SE',
196+
'ta-IN',
197+
'te-IN',
198+
'th-TH',
199+
'tr-TR',
200+
'vi-VN',
201+
'zh-CN',
202+
'zh-HK',
203+
'zh-TW',
204+
];
205+
10206
/* @var VoiceParamsInterface $params */
11207
protected $params;
12208

@@ -22,6 +218,7 @@ public function __construct(VoiceParamsInterface $params) {
22218
*/
23219
public function validate(): void {
24220
$this->from();
221+
$this->language();
25222
$this->text();
26223
$this->to();
27224

@@ -34,6 +231,19 @@ public function from(): void {
34231
}
35232
}
36233

234+
/**
235+
* @throws InvalidRequiredArgumentException
236+
*/
237+
public function language(): void {
238+
$language = $this->params->getLanguage();
239+
240+
if ($language === null) return;
241+
242+
if (!in_array($language, self::$LANGUAGES)) {
243+
throw new InvalidRequiredArgumentException('Invalid language.');
244+
}
245+
}
246+
37247
/** @throws InvalidRequiredArgumentException */
38248
public function text(): void {
39249
$text = $this->params->getText() ?? '';
@@ -53,4 +263,4 @@ public function to(): void {
53263
'You cannot send a message without specifying a recipient.');
54264
}
55265
}
56-
}
266+
}

0 commit comments

Comments
 (0)