diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 53dda76..85f87dd 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -3,7 +3,6 @@ composer.json docs/Api/BusinessApi.md docs/Api/CarrierApi.md -docs/Api/ESIMsApi.md docs/Api/InformationApi.md docs/Api/PreordersApi.md docs/Api/PricingApi.md @@ -12,7 +11,6 @@ docs/Api/SMSApi.md docs/Api/VoucherApi.md lib/Api/BusinessApi.php lib/Api/CarrierApi.php -lib/Api/ESIMsApi.php lib/Api/InformationApi.php lib/Api/PreordersApi.php lib/Api/PricingApi.php diff --git a/docs/Api/ESIMsApi.md b/docs/Api/ESIMsApi.md deleted file mode 100644 index 4c47b93..0000000 --- a/docs/Api/ESIMsApi.md +++ /dev/null @@ -1,550 +0,0 @@ -# SMSPool\ESIMsApi - -Introduction to the eSIM API usage. Here's a step-to-step process on how to streamline your eSIM purchases: 1. Retrieve the country list from **View eSIM countries** 2. Retrieve the plans per country using the **countryCode** 3. Create your first purchase using the **Purchase eSIM** 4. Retrieve the **transactionId** from **Purchase eSIM** 5. Use the **View eSIM profile** endpoint to retrieve the QR code, or the access URL in order to install the eSIM or view remaining data. - -All URIs are relative to https://api.smspool.net, except if the operation defines another base path. - -| Method | HTTP request | Description | -| ------------- | ------------- | ------------- | -| [**esimDelete()**](ESIMsApi.md#esimDelete) | **POST** /esim/delete | Delete eSIM | -| [**esimHistory()**](ESIMsApi.md#esimHistory) | **POST** /esim/history | View eSIM history | -| [**esimLabelUpdate()**](ESIMsApi.md#esimLabelUpdate) | **POST** /esim/label/update | Update eSIM label | -| [**esimPlans()**](ESIMsApi.md#esimPlans) | **POST** /esim/plans | View eSIM plans per country | -| [**esimPricing()**](ESIMsApi.md#esimPricing) | **POST** /esim/pricing | View eSIM countries | -| [**esimProfile()**](ESIMsApi.md#esimProfile) | **POST** /esim/profile | View eSIM profile | -| [**esimPurchase()**](ESIMsApi.md#esimPurchase) | **POST** /esim/purchase | Purchase eSIM | -| [**esimTopup()**](ESIMsApi.md#esimTopup) | **POST** /esim/topup | Top up eSIM | -| [**esimTopupPlans()**](ESIMsApi.md#esimTopupPlans) | **POST** /esim/topup_plans | Top Up Plans | - - -## `esimDelete()` - -```php -esimDelete($transaction_id): mixed -``` - -Delete eSIM - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$transaction_id = 'transaction_id_example'; // string | transactionId retrieved from /esim/purchase - -try { - $result = $apiInstance->esimDelete($transaction_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimDelete: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **transaction_id** | **string**| transactionId retrieved from /esim/purchase | | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimHistory()` - -```php -esimHistory($start, $length, $search): mixed -``` - -View eSIM history - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$start = 56; // int | Start page -$length = 56; // int | Amount of rows per page -$search = 'search_example'; // string | Alphanumeric search - -try { - $result = $apiInstance->esimHistory($start, $length, $search); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimHistory: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **start** | **int**| Start page | [optional] | -| **length** | **int**| Amount of rows per page | [optional] | -| **search** | **string**| Alphanumeric search | [optional] | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimLabelUpdate()` - -```php -esimLabelUpdate($transaction_id, $label): mixed -``` - -Update eSIM label - -Set or clear the label of one of your eSIMs. The label is returned as `label` by **View eSIM history**, so you can use it to tell your eSIMs apart. A label can be up to 30 characters long and may only contain letters, numbers and spaces. Leave `label` out, or send it empty, to remove the label. - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$transaction_id = 'transaction_id_example'; // string | transactionId retrieved from /esim/purchase -$label = 'label_example'; // string | The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. - -try { - $result = $apiInstance->esimLabelUpdate($transaction_id, $label); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimLabelUpdate: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **transaction_id** | **string**| transactionId retrieved from /esim/purchase | | -| **label** | **string**| The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. | [optional] | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimPlans()` - -```php -esimPlans($country): mixed -``` - -View eSIM plans per country - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$country = 'country_example'; // string | ISO 3166 country code - -try { - $result = $apiInstance->esimPlans($country); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimPlans: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **country** | **string**| ISO 3166 country code | | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimPricing()` - -```php -esimPricing($start, $length, $search): mixed -``` - -View eSIM countries - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$start = 56; // int | Start page -$length = 56; // int | Amount of rows per page -$search = 'search_example'; // string | Search query for country - -try { - $result = $apiInstance->esimPricing($start, $length, $search); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimPricing: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **start** | **int**| Start page | [optional] | -| **length** | **int**| Amount of rows per page | [optional] | -| **search** | **string**| Search query for country | [optional] | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimProfile()` - -```php -esimProfile($transaction_id): mixed -``` - -View eSIM profile - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$transaction_id = 'transaction_id_example'; // string | transactionId retrieved from /esim/purchase - -try { - $result = $apiInstance->esimProfile($transaction_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimProfile: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **transaction_id** | **string**| transactionId retrieved from /esim/purchase | [optional] | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimPurchase()` - -```php -esimPurchase($plan): mixed -``` - -Purchase eSIM - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$plan = 56; // int | The plan ID which is obtained from /esim/pricing - -try { - $result = $apiInstance->esimPurchase($plan); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimPurchase: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **plan** | **int**| The plan ID which is obtained from /esim/pricing | | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimTopup()` - -```php -esimTopup($transaction_id, $plan): mixed -``` - -Top up eSIM - -### Example - -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - - -$apiInstance = new SMSPool\Api\ESIMsApi( - // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. - // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); -$transaction_id = 'transaction_id_example'; // string | Transaction ID retrieved from eSIM history -$plan = 56; // int | Topup plan retrieved from \\\"Top Up Plans\\\" - -try { - $result = $apiInstance->esimTopup($transaction_id, $plan); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimTopup: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **transaction_id** | **string**| Transaction ID retrieved from eSIM history | | -| **plan** | **int**| Topup plan retrieved from \\\"Top Up Plans\\\" | | - -### Return type - -**mixed** - -### Authorization - -[bearerAuth](../../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) - -## `esimTopupPlans()` - -```php -esimTopupPlans($plan): mixed -``` - -Top Up Plans - -### Example - -```php -esimTopupPlans($plan); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling ESIMsApi->esimTopupPlans: ', $e->getMessage(), PHP_EOL; -} -``` - -### Parameters - -| Name | Type | Description | Notes | -| ------------- | ------------- | ------------- | ------------- | -| **plan** | **int**| `plan` retrieved from eSIM history | | - -### Return type - -**mixed** - -### Authorization - -No authorization required - -### HTTP request headers - -- **Content-Type**: `application/x-www-form-urlencoded` -- **Accept**: `application/json` - -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/InformationApi.md b/docs/Api/InformationApi.md index ae2e4d3..007b38b 100644 --- a/docs/Api/InformationApi.md +++ b/docs/Api/InformationApi.md @@ -9,7 +9,9 @@ All URIs are relative to https://api.smspool.net, except if the operation define | [**countryRetrieveAll()**](InformationApi.md#countryRetrieveAll) | **GET** /country/retrieve_all | Country list | | [**poolRetrieveAll()**](InformationApi.md#poolRetrieveAll) | **POST** /pool/retrieve_all | Pool list | | [**poolRetrieveValid()**](InformationApi.md#poolRetrieveValid) | **POST** /pool/retrieve_valid | Suggested Pools | +| [**requestAutoCountry()**](InformationApi.md#requestAutoCountry) | **POST** /request/auto_country | Pick the best country for a service | | [**requestBalance()**](InformationApi.md#requestBalance) | **POST** /request/balance | Balance | +| [**requestHistorySearch()**](InformationApi.md#requestHistorySearch) | **POST** /request/history_search | History search | | [**requestSuccessRate()**](InformationApi.md#requestSuccessRate) | **POST** /request/success_rate | Retrieve country success rates per service | | [**requestSuggestedCountries()**](InformationApi.md#requestSuggestedCountries) | **POST** /request/suggested_countries | Suggested Countries | | [**serviceRetrieveAll()**](InformationApi.md#serviceRetrieveAll) | **GET** /service/retrieve_all | Service list | @@ -186,6 +188,64 @@ No authorization required [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `requestAutoCountry()` + +```php +requestAutoCountry($service, $pricing_option): mixed +``` + +Pick the best country for a service + +Returns the country SMSPool would order from for this service when you do not want to choose one (the quick order's \"Pick for me\"). It sends an HTTP POST request to the URL `https://api.smspool.net/request/auto_country`. Every country with stock is scored on its measured success rate (a country with no order history displays 100% but has nothing to back it up, so it is left out unless no measured country has stock), weighed down when little stock backs it, minus a little per dollar, plus a bonus when it matches the country your request's IP resolves to (a local number verifies more often). The IP country is only used for that comparison; it is neither stored nor returned. Ties go to more stock, then the lower price. With `pricing_option=1` the cheapest country within reach of the best score wins instead. Send `auto_country=1` to `/purchase/sms` to order with the same choice in one call. + +### Example + +```php +requestAutoCountry($service, $pricing_option); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling InformationApi->requestAutoCountry: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **service** | **string**| Service name or service ID which can be retrieved at the /service/retrieve_all endpoint | | +| **pricing_option** | **int**| Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. | [optional] | + +### Return type + +**mixed** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: `application/x-www-form-urlencoded` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + ## `requestBalance()` ```php @@ -243,6 +303,70 @@ This endpoint does not need any parameter. [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `requestHistorySearch()` + +```php +requestHistorySearch($search, $cursor, $limit): mixed +``` + +History search + +_Not documented yet: the parameters below come straight from the code._ + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new SMSPool\Api\InformationApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$search = 'search_example'; // string +$cursor = 'cursor_example'; // string +$limit = 56; // int + +try { + $result = $apiInstance->requestHistorySearch($search, $cursor, $limit); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling InformationApi->requestHistorySearch: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **search** | **string**| | | +| **cursor** | **string**| | [optional] | +| **limit** | **int**| | [optional] | + +### Return type + +**mixed** + +### Authorization + +[bearerAuth](../../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/x-www-form-urlencoded` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + ## `requestSuccessRate()` ```php diff --git a/docs/Api/RentalApi.md b/docs/Api/RentalApi.md index 94edc8f..0ccd077 100644 --- a/docs/Api/RentalApi.md +++ b/docs/Api/RentalApi.md @@ -918,11 +918,15 @@ Retrieve Rental Stock require_once(__DIR__ . '/vendor/autoload.php'); +// Configure Bearer authorization: bearerAuth +$config = SMSPool\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + $apiInstance = new SMSPool\Api\RentalApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client() + new GuzzleHttp\Client(), + $config ); $id = 56; // int | The rental ID retrieved from `Retrieve Rental IDs` $days = 56; // int @@ -950,7 +954,7 @@ try { ### Authorization -No authorization required +[bearerAuth](../../README.md#bearerAuth) ### HTTP request headers diff --git a/docs/Api/SMSApi.md b/docs/Api/SMSApi.md index 93c0e60..7a4d6d2 100644 --- a/docs/Api/SMSApi.md +++ b/docs/Api/SMSApi.md @@ -13,6 +13,7 @@ All URIs are relative to https://api.smspool.net, except if the operation define | [**requestHistory()**](SMSApi.md#requestHistory) | **POST** /request/history | Order History | | [**smsActivate()**](SMSApi.md#smsActivate) | **POST** /sms/activate | Activate SMS | | [**smsAllStock()**](SMSApi.md#smsAllStock) | **POST** /sms/all_stock | One-time stock for all services | +| [**smsArchive()**](SMSApi.md#smsArchive) | **POST** /sms/archive | Archive | | [**smsCancel()**](SMSApi.md#smsCancel) | **POST** /sms/cancel | Cancel SMS | | [**smsCancelAll()**](SMSApi.md#smsCancelAll) | **POST** /sms/cancel_all | Cancel All SMS | | [**smsCheck()**](SMSApi.md#smsCheck) | **POST** /sms/check | Check SMS | @@ -28,7 +29,7 @@ All URIs are relative to https://api.smspool.net, except if the operation define ## `purchaseSms()` ```php -purchaseSms($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $software): mixed +purchaseSms($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $software): mixed ``` Order SMS @@ -62,10 +63,11 @@ $create_token = 56; // int | Optional param; set to 1 if you'd like to create a $activation_type = 'activation_type_example'; // string | Options: SMS, VOICE, FLASH. SMS will receive regular SMS, VOICE will receive phone calls that mentions the SMS and FLASH is for FLASH calls for verification. $carrier = 56; // int | Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) $phonenumber = 56; // int | In case you want to select a specific phone number to order +$auto_country = 56; // int | Set to 1 to let SMSPool pick the country: every country with stock is scored on its measured success rate (weighed down when little stock backs it, minus a little per dollar; countries with no order history are left out unless nothing else has stock) with a bonus for a local number, the country your request's IP resolves to; with pricing_option=1 the cheapest country close to the best score wins. Ignored when country is sent. The response then carries auto_country with the chosen country and the reason. $software = 56; // int try { - $result = $apiInstance->purchaseSms($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $software); + $result = $apiInstance->purchaseSms($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $software); print_r($result); } catch (Exception $e) { echo 'Exception when calling SMSApi->purchaseSms: ', $e->getMessage(), PHP_EOL; @@ -88,6 +90,7 @@ try { | **activation_type** | **string**| Options: SMS, VOICE, FLASH. SMS will receive regular SMS, VOICE will receive phone calls that mentions the SMS and FLASH is for FLASH calls for verification. | [optional] | | **carrier** | **int**| Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) | [optional] | | **phonenumber** | **int**| In case you want to select a specific phone number to order | [optional] | +| **auto_country** | **int**| Set to 1 to let SMSPool pick the country: every country with stock is scored on its measured success rate (weighed down when little stock backs it, minus a little per dollar; countries with no order history are left out unless nothing else has stock) with a bonus for a local number, the country your request's IP resolves to; with pricing_option=1 the cheapest country close to the best score wins. Ignored when country is sent. The response then carries auto_country with the chosen country and the reason. | [optional] | | **software** | **int**| | [optional] | ### Return type @@ -236,11 +239,15 @@ Request available areacodes require_once(__DIR__ . '/vendor/autoload.php'); +// Configure Bearer authorization: bearerAuth +$config = SMSPool\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + $apiInstance = new SMSPool\Api\SMSApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client() + new GuzzleHttp\Client(), + $config ); $service = 'service_example'; // string | The service or number retrieved from the `Service List` endpoint $country = 'country_example'; // string | The country in ISO format or number retrieved from the `Country List` endpoint @@ -268,7 +275,7 @@ try { ### Authorization -No authorization required +[bearerAuth](../../README.md#bearerAuth) ### HTTP request headers @@ -463,6 +470,66 @@ No authorization required [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `smsArchive()` + +```php +smsArchive($orderid): mixed +``` + +Archive + +_Not documented yet: the parameters below come straight from the code._ + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new SMSPool\Api\SMSApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$orderid = 'orderid_example'; // string + +try { + $result = $apiInstance->smsArchive($orderid); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling SMSApi->smsArchive: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **orderid** | **string**| | | + +### Return type + +**mixed** + +### Authorization + +[bearerAuth](../../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/x-www-form-urlencoded` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + ## `smsCancel()` ```php @@ -771,7 +838,7 @@ smsMissed($phonenumber, $limit): mixed Missed SMS -Some messages arrive on a number from your one-time orders but cannot finish the order, such as Ticketmaster and Seated codes or Hark reward payouts. This returns those messages, the same ones the Missed SMS tool on the website shows. Only numbers from pool Foxtrot are covered. The newest messages come first. `url`, `code` and `email` hold the first link, code and email address found in the message, or an empty string. +Some messages arrive on a number from your one-time orders but cannot finish the order, such as Ticketmaster and Seated codes, Hark reward payouts or Neon Money Talks messages. This returns those messages, the same ones the Missed SMS tool on the website shows. Only numbers from pool Foxtrot are covered. The newest messages come first. `url`, `code` and `email` hold the first link, code and email address found in the message, or an empty string. ### Example diff --git a/lib/Api/ESIMsApi.php b/lib/Api/ESIMsApi.php deleted file mode 100644 index a128936..0000000 --- a/lib/Api/ESIMsApi.php +++ /dev/null @@ -1,2964 +0,0 @@ -`) or as a `key` parameter. - * - * The version of the OpenAPI document: 1.0 - * Generated by: https://openapi-generator.tech - * Generator version: 7.25.0 - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -namespace SMSPool\Api; - -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use GuzzleHttp\RequestOptions; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use SMSPool\ApiException; -use SMSPool\Configuration; -use SMSPool\FormDataProcessor; -use SMSPool\HeaderSelector; -use SMSPool\ObjectSerializer; - -/** - * ESIMsApi Class Doc Comment - * - * @category Class - * @package SMSPool - * @author OpenAPI Generator team - * @link https://openapi-generator.tech - */ -class ESIMsApi -{ - /** - * @var ClientInterface - */ - protected $client; - - /** - * @var Configuration - */ - protected $config; - - /** - * @var HeaderSelector - */ - protected $headerSelector; - - /** - * @var int Host index - */ - protected $hostIndex; - - /** @var string[] $contentTypes **/ - public const contentTypes = [ - 'esimDelete' => [ - 'application/x-www-form-urlencoded', - ], - 'esimHistory' => [ - 'application/x-www-form-urlencoded', - ], - 'esimLabelUpdate' => [ - 'application/x-www-form-urlencoded', - ], - 'esimPlans' => [ - 'application/x-www-form-urlencoded', - ], - 'esimPricing' => [ - 'application/x-www-form-urlencoded', - ], - 'esimProfile' => [ - 'application/x-www-form-urlencoded', - ], - 'esimPurchase' => [ - 'application/x-www-form-urlencoded', - ], - 'esimTopup' => [ - 'application/x-www-form-urlencoded', - ], - 'esimTopupPlans' => [ - 'application/x-www-form-urlencoded', - ], - ]; - - /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ?ClientInterface $client = null, - ?Configuration $config = null, - ?HeaderSelector $selector = null, - int $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: Configuration::getDefaultConfiguration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation esimDelete - * - * Delete eSIM - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimDelete'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimDelete($transaction_id, string $contentType = self::contentTypes['esimDelete'][0]) - { - list($response) = $this->esimDeleteWithHttpInfo($transaction_id, $contentType); - return $response; - } - - /** - * Operation esimDeleteWithHttpInfo - * - * Delete eSIM - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimDelete'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimDeleteWithHttpInfo($transaction_id, string $contentType = self::contentTypes['esimDelete'][0]) - { - $request = $this->esimDeleteRequest($transaction_id, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimDeleteAsync - * - * Delete eSIM - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimDelete'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimDeleteAsync($transaction_id, string $contentType = self::contentTypes['esimDelete'][0]) - { - return $this->esimDeleteAsyncWithHttpInfo($transaction_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimDeleteAsyncWithHttpInfo - * - * Delete eSIM - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimDelete'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimDeleteAsyncWithHttpInfo($transaction_id, string $contentType = self::contentTypes['esimDelete'][0]) - { - $returnType = 'mixed'; - $request = $this->esimDeleteRequest($transaction_id, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimDelete' - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimDelete'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimDeleteRequest($transaction_id, string $contentType = self::contentTypes['esimDelete'][0]) - { - - // verify the required parameter 'transaction_id' is set - if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $transaction_id when calling esimDelete' - ); - } - - - $resourcePath = '/esim/delete'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'transactionId' => $transaction_id, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimHistory - * - * View eSIM history - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Alphanumeric search (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimHistory'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimHistory($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimHistory'][0]) - { - list($response) = $this->esimHistoryWithHttpInfo($start, $length, $search, $contentType); - return $response; - } - - /** - * Operation esimHistoryWithHttpInfo - * - * View eSIM history - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Alphanumeric search (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimHistory'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimHistoryWithHttpInfo($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimHistory'][0]) - { - $request = $this->esimHistoryRequest($start, $length, $search, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimHistoryAsync - * - * View eSIM history - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Alphanumeric search (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimHistory'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimHistoryAsync($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimHistory'][0]) - { - return $this->esimHistoryAsyncWithHttpInfo($start, $length, $search, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimHistoryAsyncWithHttpInfo - * - * View eSIM history - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Alphanumeric search (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimHistory'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimHistoryAsyncWithHttpInfo($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimHistory'][0]) - { - $returnType = 'mixed'; - $request = $this->esimHistoryRequest($start, $length, $search, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimHistory' - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Alphanumeric search (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimHistory'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimHistoryRequest($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimHistory'][0]) - { - - - - - - $resourcePath = '/esim/history'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'start' => $start, - 'length' => $length, - 'search' => $search, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimLabelUpdate - * - * Update eSIM label - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string|null $label The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimLabelUpdate'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimLabelUpdate($transaction_id, $label = null, string $contentType = self::contentTypes['esimLabelUpdate'][0]) - { - list($response) = $this->esimLabelUpdateWithHttpInfo($transaction_id, $label, $contentType); - return $response; - } - - /** - * Operation esimLabelUpdateWithHttpInfo - * - * Update eSIM label - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string|null $label The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimLabelUpdate'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimLabelUpdateWithHttpInfo($transaction_id, $label = null, string $contentType = self::contentTypes['esimLabelUpdate'][0]) - { - $request = $this->esimLabelUpdateRequest($transaction_id, $label, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimLabelUpdateAsync - * - * Update eSIM label - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string|null $label The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimLabelUpdate'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimLabelUpdateAsync($transaction_id, $label = null, string $contentType = self::contentTypes['esimLabelUpdate'][0]) - { - return $this->esimLabelUpdateAsyncWithHttpInfo($transaction_id, $label, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimLabelUpdateAsyncWithHttpInfo - * - * Update eSIM label - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string|null $label The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimLabelUpdate'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimLabelUpdateAsyncWithHttpInfo($transaction_id, $label = null, string $contentType = self::contentTypes['esimLabelUpdate'][0]) - { - $returnType = 'mixed'; - $request = $this->esimLabelUpdateRequest($transaction_id, $label, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimLabelUpdate' - * - * @param string $transaction_id transactionId retrieved from /esim/purchase (required) - * @param string|null $label The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimLabelUpdate'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimLabelUpdateRequest($transaction_id, $label = null, string $contentType = self::contentTypes['esimLabelUpdate'][0]) - { - - // verify the required parameter 'transaction_id' is set - if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $transaction_id when calling esimLabelUpdate' - ); - } - - - - $resourcePath = '/esim/label/update'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'transactionId' => $transaction_id, - 'label' => $label, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimPlans - * - * View eSIM plans per country - * - * @param string $country ISO 3166 country code (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPlans'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimPlans($country, string $contentType = self::contentTypes['esimPlans'][0]) - { - list($response) = $this->esimPlansWithHttpInfo($country, $contentType); - return $response; - } - - /** - * Operation esimPlansWithHttpInfo - * - * View eSIM plans per country - * - * @param string $country ISO 3166 country code (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPlans'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimPlansWithHttpInfo($country, string $contentType = self::contentTypes['esimPlans'][0]) - { - $request = $this->esimPlansRequest($country, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimPlansAsync - * - * View eSIM plans per country - * - * @param string $country ISO 3166 country code (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPlans'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimPlansAsync($country, string $contentType = self::contentTypes['esimPlans'][0]) - { - return $this->esimPlansAsyncWithHttpInfo($country, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimPlansAsyncWithHttpInfo - * - * View eSIM plans per country - * - * @param string $country ISO 3166 country code (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPlans'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimPlansAsyncWithHttpInfo($country, string $contentType = self::contentTypes['esimPlans'][0]) - { - $returnType = 'mixed'; - $request = $this->esimPlansRequest($country, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimPlans' - * - * @param string $country ISO 3166 country code (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPlans'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimPlansRequest($country, string $contentType = self::contentTypes['esimPlans'][0]) - { - - // verify the required parameter 'country' is set - if ($country === null || (is_array($country) && count($country) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $country when calling esimPlans' - ); - } - - - $resourcePath = '/esim/plans'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'country' => $country, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimPricing - * - * View eSIM countries - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Search query for country (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPricing'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimPricing($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimPricing'][0]) - { - list($response) = $this->esimPricingWithHttpInfo($start, $length, $search, $contentType); - return $response; - } - - /** - * Operation esimPricingWithHttpInfo - * - * View eSIM countries - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Search query for country (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPricing'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimPricingWithHttpInfo($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimPricing'][0]) - { - $request = $this->esimPricingRequest($start, $length, $search, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimPricingAsync - * - * View eSIM countries - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Search query for country (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPricing'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimPricingAsync($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimPricing'][0]) - { - return $this->esimPricingAsyncWithHttpInfo($start, $length, $search, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimPricingAsyncWithHttpInfo - * - * View eSIM countries - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Search query for country (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPricing'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimPricingAsyncWithHttpInfo($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimPricing'][0]) - { - $returnType = 'mixed'; - $request = $this->esimPricingRequest($start, $length, $search, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimPricing' - * - * @param int|null $start Start page (optional) - * @param int|null $length Amount of rows per page (optional) - * @param string|null $search Search query for country (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPricing'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimPricingRequest($start = null, $length = null, $search = null, string $contentType = self::contentTypes['esimPricing'][0]) - { - - - - - - $resourcePath = '/esim/pricing'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'start' => $start, - 'length' => $length, - 'search' => $search, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimProfile - * - * View eSIM profile - * - * @param string|null $transaction_id transactionId retrieved from /esim/purchase (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimProfile'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimProfile($transaction_id = null, string $contentType = self::contentTypes['esimProfile'][0]) - { - list($response) = $this->esimProfileWithHttpInfo($transaction_id, $contentType); - return $response; - } - - /** - * Operation esimProfileWithHttpInfo - * - * View eSIM profile - * - * @param string|null $transaction_id transactionId retrieved from /esim/purchase (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimProfile'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimProfileWithHttpInfo($transaction_id = null, string $contentType = self::contentTypes['esimProfile'][0]) - { - $request = $this->esimProfileRequest($transaction_id, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimProfileAsync - * - * View eSIM profile - * - * @param string|null $transaction_id transactionId retrieved from /esim/purchase (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimProfile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimProfileAsync($transaction_id = null, string $contentType = self::contentTypes['esimProfile'][0]) - { - return $this->esimProfileAsyncWithHttpInfo($transaction_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimProfileAsyncWithHttpInfo - * - * View eSIM profile - * - * @param string|null $transaction_id transactionId retrieved from /esim/purchase (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimProfile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimProfileAsyncWithHttpInfo($transaction_id = null, string $contentType = self::contentTypes['esimProfile'][0]) - { - $returnType = 'mixed'; - $request = $this->esimProfileRequest($transaction_id, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimProfile' - * - * @param string|null $transaction_id transactionId retrieved from /esim/purchase (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimProfile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimProfileRequest($transaction_id = null, string $contentType = self::contentTypes['esimProfile'][0]) - { - - - - $resourcePath = '/esim/profile'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'transactionId' => $transaction_id, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimPurchase - * - * Purchase eSIM - * - * @param int $plan The plan ID which is obtained from /esim/pricing (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPurchase'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimPurchase($plan, string $contentType = self::contentTypes['esimPurchase'][0]) - { - list($response) = $this->esimPurchaseWithHttpInfo($plan, $contentType); - return $response; - } - - /** - * Operation esimPurchaseWithHttpInfo - * - * Purchase eSIM - * - * @param int $plan The plan ID which is obtained from /esim/pricing (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPurchase'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimPurchaseWithHttpInfo($plan, string $contentType = self::contentTypes['esimPurchase'][0]) - { - $request = $this->esimPurchaseRequest($plan, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimPurchaseAsync - * - * Purchase eSIM - * - * @param int $plan The plan ID which is obtained from /esim/pricing (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPurchase'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimPurchaseAsync($plan, string $contentType = self::contentTypes['esimPurchase'][0]) - { - return $this->esimPurchaseAsyncWithHttpInfo($plan, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimPurchaseAsyncWithHttpInfo - * - * Purchase eSIM - * - * @param int $plan The plan ID which is obtained from /esim/pricing (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPurchase'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimPurchaseAsyncWithHttpInfo($plan, string $contentType = self::contentTypes['esimPurchase'][0]) - { - $returnType = 'mixed'; - $request = $this->esimPurchaseRequest($plan, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimPurchase' - * - * @param int $plan The plan ID which is obtained from /esim/pricing (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimPurchase'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimPurchaseRequest($plan, string $contentType = self::contentTypes['esimPurchase'][0]) - { - - // verify the required parameter 'plan' is set - if ($plan === null || (is_array($plan) && count($plan) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $plan when calling esimPurchase' - ); - } - - - $resourcePath = '/esim/purchase'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'plan' => $plan, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimTopup - * - * Top up eSIM - * - * @param string $transaction_id Transaction ID retrieved from eSIM history (required) - * @param int $plan Topup plan retrieved from \\\"Top Up Plans\\\" (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopup'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed|mixed|mixed - */ - public function esimTopup($transaction_id, $plan, string $contentType = self::contentTypes['esimTopup'][0]) - { - list($response) = $this->esimTopupWithHttpInfo($transaction_id, $plan, $contentType); - return $response; - } - - /** - * Operation esimTopupWithHttpInfo - * - * Top up eSIM - * - * @param string $transaction_id Transaction ID retrieved from eSIM history (required) - * @param int $plan Topup plan retrieved from \\\"Top Up Plans\\\" (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopup'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimTopupWithHttpInfo($transaction_id, $plan, string $contentType = self::contentTypes['esimTopup'][0]) - { - $request = $this->esimTopupRequest($transaction_id, $plan, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimTopupAsync - * - * Top up eSIM - * - * @param string $transaction_id Transaction ID retrieved from eSIM history (required) - * @param int $plan Topup plan retrieved from \\\"Top Up Plans\\\" (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopup'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimTopupAsync($transaction_id, $plan, string $contentType = self::contentTypes['esimTopup'][0]) - { - return $this->esimTopupAsyncWithHttpInfo($transaction_id, $plan, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimTopupAsyncWithHttpInfo - * - * Top up eSIM - * - * @param string $transaction_id Transaction ID retrieved from eSIM history (required) - * @param int $plan Topup plan retrieved from \\\"Top Up Plans\\\" (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopup'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimTopupAsyncWithHttpInfo($transaction_id, $plan, string $contentType = self::contentTypes['esimTopup'][0]) - { - $returnType = 'mixed'; - $request = $this->esimTopupRequest($transaction_id, $plan, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimTopup' - * - * @param string $transaction_id Transaction ID retrieved from eSIM history (required) - * @param int $plan Topup plan retrieved from \\\"Top Up Plans\\\" (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopup'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimTopupRequest($transaction_id, $plan, string $contentType = self::contentTypes['esimTopup'][0]) - { - - // verify the required parameter 'transaction_id' is set - if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $transaction_id when calling esimTopup' - ); - } - - // verify the required parameter 'plan' is set - if ($plan === null || (is_array($plan) && count($plan) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $plan when calling esimTopup' - ); - } - - - $resourcePath = '/esim/topup'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'transactionId' => $transaction_id, - 'plan' => $plan, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation esimTopupPlans - * - * Top Up Plans - * - * @param int $plan `plan` retrieved from eSIM history (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopupPlans'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return mixed - */ - public function esimTopupPlans($plan, string $contentType = self::contentTypes['esimTopupPlans'][0]) - { - list($response) = $this->esimTopupPlansWithHttpInfo($plan, $contentType); - return $response; - } - - /** - * Operation esimTopupPlansWithHttpInfo - * - * Top Up Plans - * - * @param int $plan `plan` retrieved from eSIM history (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopupPlans'] to see the possible values for this operation - * - * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of mixed, HTTP status code, HTTP response headers (array of strings) - */ - public function esimTopupPlansWithHttpInfo($plan, string $contentType = self::contentTypes['esimTopupPlans'][0]) - { - $request = $this->esimTopupPlansRequest($plan, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } - - - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - } - - - throw $e; - } - } - - /** - * Operation esimTopupPlansAsync - * - * Top Up Plans - * - * @param int $plan `plan` retrieved from eSIM history (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopupPlans'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimTopupPlansAsync($plan, string $contentType = self::contentTypes['esimTopupPlans'][0]) - { - return $this->esimTopupPlansAsyncWithHttpInfo($plan, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation esimTopupPlansAsyncWithHttpInfo - * - * Top Up Plans - * - * @param int $plan `plan` retrieved from eSIM history (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopupPlans'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function esimTopupPlansAsyncWithHttpInfo($plan, string $contentType = self::contentTypes['esimTopupPlans'][0]) - { - $returnType = 'mixed'; - $request = $this->esimTopupPlansRequest($plan, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'esimTopupPlans' - * - * @param int $plan `plan` retrieved from eSIM history (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['esimTopupPlans'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function esimTopupPlansRequest($plan, string $contentType = self::contentTypes['esimTopupPlans'][0]) - { - - // verify the required parameter 'plan' is set - if ($plan === null || (is_array($plan) && count($plan) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $plan when calling esimTopupPlans' - ); - } - - - $resourcePath = '/esim/topup_plans'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - $formDataProcessor = new FormDataProcessor(); - - $formData = $formDataProcessor->prepare([ - 'plan' => $plan, - ]); - - $formParams = $formDataProcessor->flatten($formData); - $multipart = $formDataProcessor->has_file; - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - try { - $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { - throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); - } - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - if ($this->config->getCertFile()) { - $options[RequestOptions::CERT] = $this->config->getCertFile(); - } - - if ($this->config->getKeyFile()) { - $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); - } - - return $options; - } - - private function handleResponseWithDataType( - string $dataType, - RequestInterface $request, - ResponseInterface $response - ): array { - if ($dataType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($dataType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $response->getStatusCode(), - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $dataType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - private function responseWithinRangeCode( - string $rangeCode, - int $statusCode - ): bool { - $left = (int) ($rangeCode[0].'00'); - $right = (int) ($rangeCode[0].'99'); - - return $statusCode >= $left && $statusCode <= $right; - } -} diff --git a/lib/Api/InformationApi.php b/lib/Api/InformationApi.php index 8b8e20c..b4e562a 100644 --- a/lib/Api/InformationApi.php +++ b/lib/Api/InformationApi.php @@ -83,9 +83,15 @@ class InformationApi 'poolRetrieveValid' => [ 'application/x-www-form-urlencoded', ], + 'requestAutoCountry' => [ + 'application/x-www-form-urlencoded', + ], 'requestBalance' => [ 'application/json', ], + 'requestHistorySearch' => [ + 'application/x-www-form-urlencoded', + ], 'requestSuccessRate' => [ 'application/x-www-form-urlencoded', ], @@ -977,36 +983,40 @@ public function poolRetrieveValidRequest($service, $country, $web = null, $inclu } /** - * Operation requestBalance + * Operation requestAutoCountry * - * Balance + * Pick the best country for a service * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * @param string $service Service name or service ID which can be retrieved at the /service/retrieve_all endpoint (required) + * @param int|null $pricing_option Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestAutoCountry'] to see the possible values for this operation * * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return mixed|mixed|mixed|mixed + * @return mixed|mixed */ - public function requestBalance(string $contentType = self::contentTypes['requestBalance'][0]) + public function requestAutoCountry($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) { - list($response) = $this->requestBalanceWithHttpInfo($contentType); + list($response) = $this->requestAutoCountryWithHttpInfo($service, $pricing_option, $contentType); return $response; } /** - * Operation requestBalanceWithHttpInfo + * Operation requestAutoCountryWithHttpInfo * - * Balance + * Pick the best country for a service * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * @param string $service Service name or service ID which can be retrieved at the /service/retrieve_all endpoint (required) + * @param int|null $pricing_option Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestAutoCountry'] to see the possible values for this operation * * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of mixed|mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) + * @return array of mixed|mixed, HTTP status code, HTTP response headers (array of strings) */ - public function requestBalanceWithHttpInfo(string $contentType = self::contentTypes['requestBalance'][0]) + public function requestAutoCountryWithHttpInfo($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) { - $request = $this->requestBalanceRequest($contentType); + $request = $this->requestAutoCountryRequest($service, $pricing_option, $contentType); try { $options = $this->createHttpClientOption(); @@ -1044,18 +1054,6 @@ public function requestBalanceWithHttpInfo(string $contentType = self::contentTy $request, $response, ); - case 401: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); - case 403: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); } @@ -1096,22 +1094,6 @@ public function requestBalanceWithHttpInfo(string $contentType = self::contentTy ); $e->setResponseObject($data); throw $e; - case 401: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'mixed', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - throw $e; } @@ -1120,18 +1102,20 @@ public function requestBalanceWithHttpInfo(string $contentType = self::contentTy } /** - * Operation requestBalanceAsync + * Operation requestAutoCountryAsync * - * Balance + * Pick the best country for a service * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * @param string $service Service name or service ID which can be retrieved at the /service/retrieve_all endpoint (required) + * @param int|null $pricing_option Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestAutoCountry'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function requestBalanceAsync(string $contentType = self::contentTypes['requestBalance'][0]) + public function requestAutoCountryAsync($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) { - return $this->requestBalanceAsyncWithHttpInfo($contentType) + return $this->requestAutoCountryAsyncWithHttpInfo($service, $pricing_option, $contentType) ->then( function ($response) { return $response[0]; @@ -1140,19 +1124,21 @@ function ($response) { } /** - * Operation requestBalanceAsyncWithHttpInfo + * Operation requestAutoCountryAsyncWithHttpInfo * - * Balance + * Pick the best country for a service * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * @param string $service Service name or service ID which can be retrieved at the /service/retrieve_all endpoint (required) + * @param int|null $pricing_option Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestAutoCountry'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function requestBalanceAsyncWithHttpInfo(string $contentType = self::contentTypes['requestBalance'][0]) + public function requestAutoCountryAsyncWithHttpInfo($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) { $returnType = 'mixed'; - $request = $this->requestBalanceRequest($contentType); + $request = $this->requestAutoCountryRequest($service, $pricing_option, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1191,18 +1177,28 @@ function ($exception) { } /** - * Create request for operation 'requestBalance' + * Create request for operation 'requestAutoCountry' * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * @param string $service Service name or service ID which can be retrieved at the /service/retrieve_all endpoint (required) + * @param int|null $pricing_option Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestAutoCountry'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function requestBalanceRequest(string $contentType = self::contentTypes['requestBalance'][0]) + public function requestAutoCountryRequest($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) { + // verify the required parameter 'service' is set + if ($service === null || (is_array($service) && count($service) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $service when calling requestAutoCountry' + ); + } - $resourcePath = '/request/balance'; + + + $resourcePath = '/request/auto_country'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1212,6 +1208,629 @@ public function requestBalanceRequest(string $contentType = self::contentTypes[' + // form params + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'service' => $service, + 'pricing_option' => $pricing_option, + ]); + + $formParams = $formDataProcessor->flatten($formData); + $multipart = $formDataProcessor->has_file; + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation requestBalance + * + * Balance + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * + * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return mixed|mixed|mixed|mixed + */ + public function requestBalance(string $contentType = self::contentTypes['requestBalance'][0]) + { + list($response) = $this->requestBalanceWithHttpInfo($contentType); + return $response; + } + + /** + * Operation requestBalanceWithHttpInfo + * + * Balance + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * + * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of mixed|mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) + */ + public function requestBalanceWithHttpInfo(string $contentType = self::contentTypes['requestBalance'][0]) + { + $request = $this->requestBalanceRequest($contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 400: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 401: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 403: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation requestBalanceAsync + * + * Balance + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function requestBalanceAsync(string $contentType = self::contentTypes['requestBalance'][0]) + { + return $this->requestBalanceAsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation requestBalanceAsyncWithHttpInfo + * + * Balance + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function requestBalanceAsyncWithHttpInfo(string $contentType = self::contentTypes['requestBalance'][0]) + { + $returnType = 'mixed'; + $request = $this->requestBalanceRequest($contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'requestBalance' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestBalance'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function requestBalanceRequest(string $contentType = self::contentTypes['requestBalance'][0]) + { + + + $resourcePath = '/request/balance'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation requestHistorySearch + * + * History search + * + * @param string $search search (required) + * @param string|null $cursor cursor (optional) + * @param int|null $limit limit (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestHistorySearch'] to see the possible values for this operation + * + * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return mixed|mixed|mixed + */ + public function requestHistorySearch($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) + { + list($response) = $this->requestHistorySearchWithHttpInfo($search, $cursor, $limit, $contentType); + return $response; + } + + /** + * Operation requestHistorySearchWithHttpInfo + * + * History search + * + * @param string $search (required) + * @param string|null $cursor (optional) + * @param int|null $limit (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestHistorySearch'] to see the possible values for this operation + * + * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) + */ + public function requestHistorySearchWithHttpInfo($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) + { + $request = $this->requestHistorySearchRequest($search, $cursor, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 401: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 403: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation requestHistorySearchAsync + * + * History search + * + * @param string $search (required) + * @param string|null $cursor (optional) + * @param int|null $limit (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestHistorySearch'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function requestHistorySearchAsync($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) + { + return $this->requestHistorySearchAsyncWithHttpInfo($search, $cursor, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation requestHistorySearchAsyncWithHttpInfo + * + * History search + * + * @param string $search (required) + * @param string|null $cursor (optional) + * @param int|null $limit (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestHistorySearch'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function requestHistorySearchAsyncWithHttpInfo($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) + { + $returnType = 'mixed'; + $request = $this->requestHistorySearchRequest($search, $cursor, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'requestHistorySearch' + * + * @param string $search (required) + * @param string|null $cursor (optional) + * @param int|null $limit (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['requestHistorySearch'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function requestHistorySearchRequest($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) + { + + // verify the required parameter 'search' is set + if ($search === null || (is_array($search) && count($search) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $search when calling requestHistorySearch' + ); + } + + + + + $resourcePath = '/request/history_search'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + // form params + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'search' => $search, + 'cursor' => $cursor, + 'limit' => $limit, + ]); + + $formParams = $formDataProcessor->flatten($formData); + $multipart = $formDataProcessor->has_file; $headers = $this->headerSelector->selectHeaders( ['application/json', ], diff --git a/lib/Api/RentalApi.php b/lib/Api/RentalApi.php index 2a3c694..3a29b94 100644 --- a/lib/Api/RentalApi.php +++ b/lib/Api/RentalApi.php @@ -4799,7 +4799,7 @@ public function rentalServicePriceRequest($id, $service_id, string $contentType * * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return mixed + * @return mixed|mixed|mixed */ public function rentalStock($id, $days, $service_id = null, string $contentType = self::contentTypes['rentalStock'][0]) { @@ -4819,7 +4819,7 @@ public function rentalStock($id, $days, $service_id = null, string $contentType * * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of mixed, HTTP status code, HTTP response headers (array of strings) + * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) */ public function rentalStockWithHttpInfo($id, $days, $service_id = null, string $contentType = self::contentTypes['rentalStock'][0]) { @@ -4855,6 +4855,18 @@ public function rentalStockWithHttpInfo($id, $days, $service_id = null, string $ $request, $response, ); + case 401: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 403: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); } @@ -4887,6 +4899,22 @@ public function rentalStockWithHttpInfo($id, $days, $service_id = null, string $ ); $e->setResponseObject($data); throw $e; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; } @@ -5058,6 +5086,10 @@ public function rentalStockRequest($id, $days, $service_id = null, string $conte } } + // this endpoint requires Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } $defaultHeaders = []; if ($this->config->getUserAgent()) { diff --git a/lib/Api/SMSApi.php b/lib/Api/SMSApi.php index 5fc18b1..f40f5a7 100644 --- a/lib/Api/SMSApi.php +++ b/lib/Api/SMSApi.php @@ -95,6 +95,9 @@ class SMSApi 'smsAllStock' => [ 'application/x-www-form-urlencoded', ], + 'smsArchive' => [ + 'application/x-www-form-urlencoded', + ], 'smsCancel' => [ 'application/x-www-form-urlencoded', ], @@ -190,6 +193,7 @@ public function getConfig() * @param string|null $activation_type Options: SMS, VOICE, FLASH. SMS will receive regular SMS, VOICE will receive phone calls that mentions the SMS and FLASH is for FLASH calls for verification. (optional) * @param int|null $carrier Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) (optional) * @param int|null $phonenumber In case you want to select a specific phone number to order (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its measured success rate (weighed down when little stock backs it, minus a little per dollar; countries with no order history are left out unless nothing else has stock) with a bonus for a local number, the country your request's IP resolves to; with pricing_option=1 the cheapest country close to the best score wins. Ignored when country is sent. The response then carries auto_country with the chosen country and the reason. (optional) * @param int|null $software software (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['purchaseSms'] to see the possible values for this operation * @@ -197,9 +201,9 @@ public function getConfig() * @throws \InvalidArgumentException * @return mixed|mixed|mixed|mixed */ - public function purchaseSms($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) + public function purchaseSms($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $auto_country = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) { - list($response) = $this->purchaseSmsWithHttpInfo($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $software, $contentType); + list($response) = $this->purchaseSmsWithHttpInfo($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $software, $contentType); return $response; } @@ -220,6 +224,7 @@ public function purchaseSms($service, $country = null, $pool = null, $max_price * @param string|null $activation_type Options: SMS, VOICE, FLASH. SMS will receive regular SMS, VOICE will receive phone calls that mentions the SMS and FLASH is for FLASH calls for verification. (optional) * @param int|null $carrier Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) (optional) * @param int|null $phonenumber In case you want to select a specific phone number to order (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its measured success rate (weighed down when little stock backs it, minus a little per dollar; countries with no order history are left out unless nothing else has stock) with a bonus for a local number, the country your request's IP resolves to; with pricing_option=1 the cheapest country close to the best score wins. Ignored when country is sent. The response then carries auto_country with the chosen country and the reason. (optional) * @param int|null $software (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['purchaseSms'] to see the possible values for this operation * @@ -227,9 +232,9 @@ public function purchaseSms($service, $country = null, $pool = null, $max_price * @throws \InvalidArgumentException * @return array of mixed|mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) */ - public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) + public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $auto_country = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) { - $request = $this->purchaseSmsRequest($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $software, $contentType); + $request = $this->purchaseSmsRequest($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $software, $contentType); try { $options = $this->createHttpClientOption(); @@ -359,15 +364,16 @@ public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, * @param string|null $activation_type Options: SMS, VOICE, FLASH. SMS will receive regular SMS, VOICE will receive phone calls that mentions the SMS and FLASH is for FLASH calls for verification. (optional) * @param int|null $carrier Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) (optional) * @param int|null $phonenumber In case you want to select a specific phone number to order (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its measured success rate (weighed down when little stock backs it, minus a little per dollar; countries with no order history are left out unless nothing else has stock) with a bonus for a local number, the country your request's IP resolves to; with pricing_option=1 the cheapest country close to the best score wins. Ignored when country is sent. The response then carries auto_country with the chosen country and the reason. (optional) * @param int|null $software (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['purchaseSms'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function purchaseSmsAsync($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) + public function purchaseSmsAsync($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $auto_country = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) { - return $this->purchaseSmsAsyncWithHttpInfo($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $software, $contentType) + return $this->purchaseSmsAsyncWithHttpInfo($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $software, $contentType) ->then( function ($response) { return $response[0]; @@ -392,16 +398,17 @@ function ($response) { * @param string|null $activation_type Options: SMS, VOICE, FLASH. SMS will receive regular SMS, VOICE will receive phone calls that mentions the SMS and FLASH is for FLASH calls for verification. (optional) * @param int|null $carrier Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) (optional) * @param int|null $phonenumber In case you want to select a specific phone number to order (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its measured success rate (weighed down when little stock backs it, minus a little per dollar; countries with no order history are left out unless nothing else has stock) with a bonus for a local number, the country your request's IP resolves to; with pricing_option=1 the cheapest country close to the best score wins. Ignored when country is sent. The response then carries auto_country with the chosen country and the reason. (optional) * @param int|null $software (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['purchaseSms'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function purchaseSmsAsyncWithHttpInfo($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) + public function purchaseSmsAsyncWithHttpInfo($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $auto_country = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) { $returnType = 'mixed'; - $request = $this->purchaseSmsRequest($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $software, $contentType); + $request = $this->purchaseSmsRequest($service, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $software, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -454,13 +461,14 @@ function ($exception) { * @param string|null $activation_type Options: SMS, VOICE, FLASH. SMS will receive regular SMS, VOICE will receive phone calls that mentions the SMS and FLASH is for FLASH calls for verification. (optional) * @param int|null $carrier Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) (optional) * @param int|null $phonenumber In case you want to select a specific phone number to order (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its measured success rate (weighed down when little stock backs it, minus a little per dollar; countries with no order history are left out unless nothing else has stock) with a bonus for a local number, the country your request's IP resolves to; with pricing_option=1 the cheapest country close to the best score wins. Ignored when country is sent. The response then carries auto_country with the chosen country and the reason. (optional) * @param int|null $software (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['purchaseSms'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function purchaseSmsRequest($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) + public function purchaseSmsRequest($service, $country = null, $pool = null, $max_price = null, $pricing_option = null, $quantity = null, $areacode = null, $exclude = null, $create_token = null, $activation_type = null, $carrier = null, $phonenumber = null, $auto_country = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) { // verify the required parameter 'service' is set @@ -483,6 +491,7 @@ public function purchaseSmsRequest($service, $country = null, $pool = null, $max + $resourcePath = '/purchase/sms'; $formParams = []; $queryParams = []; @@ -509,6 +518,7 @@ public function purchaseSmsRequest($service, $country = null, $pool = null, $max 'activation_type' => $activation_type, 'carrier' => $carrier, 'phonenumber' => $phonenumber, + 'auto_country' => $auto_country, 'software' => $software, ]); @@ -1156,7 +1166,7 @@ public function requestArchiveRequest(string $contentType = self::contentTypes[' * * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return mixed + * @return mixed|mixed|mixed */ public function requestAreacodes($service, $country, $pool, string $contentType = self::contentTypes['requestAreacodes'][0]) { @@ -1176,7 +1186,7 @@ public function requestAreacodes($service, $country, $pool, string $contentType * * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of mixed, HTTP status code, HTTP response headers (array of strings) + * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) */ public function requestAreacodesWithHttpInfo($service, $country, $pool, string $contentType = self::contentTypes['requestAreacodes'][0]) { @@ -1212,6 +1222,18 @@ public function requestAreacodesWithHttpInfo($service, $country, $pool, string $ $request, $response, ); + case 401: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 403: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); } @@ -1244,6 +1266,22 @@ public function requestAreacodesWithHttpInfo($service, $country, $pool, string $ ); $e->setResponseObject($data); throw $e; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; } @@ -1421,6 +1459,10 @@ public function requestAreacodesRequest($service, $country, $pool, string $conte } } + // this endpoint requires Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } $defaultHeaders = []; if ($this->config->getUserAgent()) { @@ -2370,6 +2412,311 @@ public function smsAllStockRequest($country = null, $service = null, $pool = nul ); } + /** + * Operation smsArchive + * + * Archive + * + * @param string $orderid orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsArchive'] to see the possible values for this operation + * + * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return mixed|mixed|mixed + */ + public function smsArchive($orderid, string $contentType = self::contentTypes['smsArchive'][0]) + { + list($response) = $this->smsArchiveWithHttpInfo($orderid, $contentType); + return $response; + } + + /** + * Operation smsArchiveWithHttpInfo + * + * Archive + * + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsArchive'] to see the possible values for this operation + * + * @throws \SMSPool\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) + */ + public function smsArchiveWithHttpInfo($orderid, string $contentType = self::contentTypes['smsArchive'][0]) + { + $request = $this->smsArchiveRequest($orderid, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 401: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + case 403: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation smsArchiveAsync + * + * Archive + * + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function smsArchiveAsync($orderid, string $contentType = self::contentTypes['smsArchive'][0]) + { + return $this->smsArchiveAsyncWithHttpInfo($orderid, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation smsArchiveAsyncWithHttpInfo + * + * Archive + * + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function smsArchiveAsyncWithHttpInfo($orderid, string $contentType = self::contentTypes['smsArchive'][0]) + { + $returnType = 'mixed'; + $request = $this->smsArchiveRequest($orderid, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'smsArchive' + * + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function smsArchiveRequest($orderid, string $contentType = self::contentTypes['smsArchive'][0]) + { + + // verify the required parameter 'orderid' is set + if ($orderid === null || (is_array($orderid) && count($orderid) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $orderid when calling smsArchive' + ); + } + + + $resourcePath = '/sms/archive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + // form params + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'orderid' => $orderid, + ]); + + $formParams = $formDataProcessor->flatten($formData); + $multipart = $formDataProcessor->has_file; + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Operation smsCancel *