|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace SMSGatewayMe\Client; |
| 4 | + |
| 5 | +use SMSGatewayMe\Client\Api\CallbackApi; |
| 6 | +use SMSGatewayMe\Client\Api\ContactApi; |
| 7 | +use SMSGatewayMe\Client\Api\DeviceApi; |
| 8 | +use SMSGatewayMe\Client\Api\MessageApi; |
| 9 | + |
| 10 | +class ClientProvider |
| 11 | +{ |
| 12 | + /** |
| 13 | + * @var DeviceApi |
| 14 | + */ |
| 15 | + private $deviceClient; |
| 16 | + |
| 17 | + /** |
| 18 | + * @var MessageApi |
| 19 | + */ |
| 20 | + private $messageClient; |
| 21 | + |
| 22 | + /** |
| 23 | + * @var ContactApi |
| 24 | + */ |
| 25 | + private $contactClient; |
| 26 | + |
| 27 | + /** |
| 28 | + * @var CallbackApi |
| 29 | + */ |
| 30 | + private $callbackClient; |
| 31 | + |
| 32 | + /** |
| 33 | + * ClientFactory constructor. |
| 34 | + * |
| 35 | + * @param string $apiToken |
| 36 | + */ |
| 37 | + public function __construct($apiToken) |
| 38 | + { |
| 39 | + // Configure client |
| 40 | + $config = Configuration::getDefaultConfiguration(); |
| 41 | + $config->setApiKey('Authorization',$apiToken); |
| 42 | + $apiClient = new ApiClient($config); |
| 43 | + |
| 44 | + $this->deviceClient = new DeviceApi($apiClient); |
| 45 | + $this->messageClient = new MessageApi($apiClient); |
| 46 | + $this->contactClient = new ContactApi($apiClient); |
| 47 | + $this->callbackClient = new CallbackApi($apiClient); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @return DeviceApi |
| 52 | + */ |
| 53 | + public function getDeviceClient() |
| 54 | + { |
| 55 | + return $this->deviceClient; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @return MessageApi |
| 60 | + */ |
| 61 | + public function getMessageClient() |
| 62 | + { |
| 63 | + return $this->messageClient; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @return ContactApi |
| 68 | + */ |
| 69 | + public function getContactClient() |
| 70 | + { |
| 71 | + return $this->contactClient; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * @return CallbackApi |
| 76 | + */ |
| 77 | + public function getCallbackClient() |
| 78 | + { |
| 79 | + return $this->callbackClient; |
| 80 | + } |
| 81 | +} |
0 commit comments