|
4 | 4 |
|
5 | 5 | use Sms77\Api\Constant\ContactsConstants;
|
6 | 6 | use Sms77\Api\Constant\HooksConstants;
|
| 7 | +use Sms77\Api\Constant\JournalConstants; |
7 | 8 | use Sms77\Api\Exception\InvalidOptionalArgumentException;
|
8 | 9 | use Sms77\Api\Exception\InvalidRequiredArgumentException;
|
9 | 10 | use Sms77\Api\Exception\UnexpectedApiResponseException;
|
|
14 | 15 | use Sms77\Api\Response\ContactCreate;
|
15 | 16 | use Sms77\Api\Response\ContactDelete;
|
16 | 17 | use Sms77\Api\Response\ContactEdit;
|
| 18 | +use Sms77\Api\Response\JournalBase; |
| 19 | +use Sms77\Api\Response\JournalInbound; |
| 20 | +use Sms77\Api\Response\JournalOutbound; |
| 21 | +use Sms77\Api\Response\JournalReplies; |
| 22 | +use Sms77\Api\Response\JournalVoice; |
17 | 23 | use Sms77\Api\Response\LookupCnam;
|
18 | 24 | use Sms77\Api\Response\LookupFormat;
|
19 | 25 | use Sms77\Api\Response\LookupHlr;
|
|
28 | 34 | use Sms77\Api\Validator\AnalyticsValidator;
|
29 | 35 | use Sms77\Api\Validator\ContactsValidator;
|
30 | 36 | use Sms77\Api\Validator\HooksValidator;
|
| 37 | +use Sms77\Api\Validator\JournalValidator; |
31 | 38 | use Sms77\Api\Validator\LookupValidator;
|
32 | 39 | use Sms77\Api\Validator\PricingValidator;
|
33 | 40 | use Sms77\Api\Validator\SmsValidator;
|
@@ -197,6 +204,35 @@ public function editContact(array $options = []) {
|
197 | 204 | return (bool)($options['json'] ?? false) ? new ContactEdit($res) : $res;
|
198 | 205 | }
|
199 | 206 |
|
| 207 | + /** |
| 208 | + * @param string $type |
| 209 | + * @param array $options |
| 210 | + * @return JournalBase[] |
| 211 | + * @throws InvalidOptionalArgumentException|InvalidRequiredArgumentException |
| 212 | + */ |
| 213 | + public function journal(string $type, array $options = []): array { |
| 214 | + $options['type'] = $type; |
| 215 | + |
| 216 | + (new JournalValidator($options))->validate(); |
| 217 | + |
| 218 | + switch ($type) { |
| 219 | + case JournalConstants::TYPE_VOICE: |
| 220 | + $class = JournalVoice::class; |
| 221 | + break; |
| 222 | + case JournalConstants::TYPE_OUTBOUND: |
| 223 | + $class = JournalOutbound::class; |
| 224 | + break; |
| 225 | + case JournalConstants::TYPE_REPLIES: |
| 226 | + $class = JournalReplies::class; |
| 227 | + break; |
| 228 | + default: |
| 229 | + $class = JournalInbound::class; |
| 230 | + } |
| 231 | + |
| 232 | + return Util::toArrayOfObject( |
| 233 | + $this->get(JournalConstants::ENDPOINT, $options), $class); |
| 234 | + } |
| 235 | + |
200 | 236 | /**
|
201 | 237 | * @param string $number
|
202 | 238 | * @return LookupFormat
|
|
0 commit comments