diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 53dda76..2f6e374 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -3,21 +3,21 @@ 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 docs/Api/RentalApi.md docs/Api/SMSApi.md +docs/Api/StatusApi.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 lib/Api/RentalApi.php lib/Api/SMSApi.php +lib/Api/StatusApi.php lib/Api/VoucherApi.php lib/ApiException.php lib/Configuration.php diff --git a/docs/Api/BusinessApi.md b/docs/Api/BusinessApi.md index 4a089be..6559f64 100644 --- a/docs/Api/BusinessApi.md +++ b/docs/Api/BusinessApi.md @@ -140,6 +140,8 @@ businessUserUpdate($id, $password, $balance, $active, $daily_spend_limit): mixed Update +Updates a sub-account. Send only the fields you want to change. `query` holds the result of each requested change. `success` is 1 only when every one of them succeeded; otherwise it is 0, `failed` lists the fields that were refused and `message` repeats the first refusal. + ### Example ```php diff --git a/docs/Api/CarrierApi.md b/docs/Api/CarrierApi.md index efc0c3e..0d06509 100644 --- a/docs/Api/CarrierApi.md +++ b/docs/Api/CarrierApi.md @@ -17,7 +17,7 @@ carrierPaidLookup($phonenumber): mixed Lookup -This API endpoint is used to perform a paid lookup for a phone number. The request is sent via an HTTP POST method to the following URL: `https://api.smspool.net/carrier/paid_lookup` ``` json { \"success\": true, \"phonenumber\": \"\", \"country\": \"\", \"carrier\": \"\", \"carrier_type\": \"\", \"charge\": 0 } ``` The `success` field indicates whether the lookup was successful or not. The `phonenumber` field represents the phone number for which the lookup was performed. The `country` field indicates the country associated with the phone number. The `carrier` field provides the name of the carrier associated with the phone number. The `carrier_type` field specifies the type of carrier. The `charge` field represents the cost charged for the lookup operation. Please note that specific values for `phonenumber`, `country`, `carrier`, and `carrier_type` were not provided in the response, and the `charge` field had a value of 0. To use this endpoint, send an HTTP POST request to the provided URL with the necessary parameters. The request should include the phone number for which you want to perform the lookup. The response will contain the details of the carrier and associated information. Make sure to handle any errors that may occur during the lookup process and check the `success` field in the response to determine the outcome of the operation. +This API endpoint is used to perform a paid lookup for a phone number. The request is sent via an HTTP POST method to the following URL: `https://api.smspool.net/carrier/paid_lookup` ``` json { \"success\": true, \"phonenumber\": \"\", \"country\": \"\", \"carrier\": \"\", \"carrier_type\": \"\", \"charge\": 0 } ``` The `success` field indicates whether the lookup was successful or not. The `phonenumber` field represents the phone number for which the lookup was performed. The `country` field indicates the country associated with the phone number. The `carrier` field provides the name of the carrier associated with the phone number. The `carrier_type` field specifies the type of carrier. The `charge` field represents the cost charged for the lookup operation. Please note that specific values for `phonenumber`, `country`, `carrier`, and `carrier_type` were not provided in the response, and the `charge` field had a value of 0. To use this endpoint, send an HTTP POST request to the provided URL with the necessary parameters. The request should include the phone number for which you want to perform the lookup. The response will contain the details of the carrier and associated information. Make sure to handle any errors that may occur during the lookup process and check the `success` field in the response to determine the outcome of the operation. A lookup costs $0.01. When the lookup fails (`success: false`) the charge is returned and the response carries `refunded: true`. `phonenumber` is the number with its country code; a leading `+`, spaces and dashes are ignored. ### Example 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..e7070c3 100644 --- a/docs/Api/InformationApi.md +++ b/docs/Api/InformationApi.md @@ -9,6 +9,7 @@ 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 | | [**requestSuccessRate()**](InformationApi.md#requestSuccessRate) | **POST** /request/success_rate | Retrieve country success rates per service | | [**requestSuggestedCountries()**](InformationApi.md#requestSuggestedCountries) | **POST** /request/suggested_countries | Suggested Countries | @@ -186,6 +187,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 expected success rate, 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. `success_rate` is that expected rate. Where the service has at least 20 recent orders in the country it is the measured rate and `rate_measured` is true. With fewer, it is an estimate that blends those orders (`rate_orders` of them) with how the country does across all services and how the service does elsewhere, and `rate_measured` is false. 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 @@ -194,7 +253,7 @@ requestBalance(): mixed Balance -This HTTP POST request is used to retrieve the balance for a specific SMSPool. The request is sent to the URL `https://api.smspool.net/request/balance`. ### Request Parameters This request require the \\`key\\` param which is your API key ### Response The response to this request will have a status code of 200 if the request is successful. The response body will be in JSON format and will include a `balance` field. However, the last execution of this request returned an empty string for the `balance` field. Please note that the actual value of the `balance` field may vary depending on the user and its configuration. +Retrieves your account balance in USD. ### Request Parameters Only your API key, sent as a bearer token. ### Response A JSON object with a `balance` field: the balance as a string with two decimals, for example `\"5.00\"`. ### Example diff --git a/docs/Api/PricingApi.md b/docs/Api/PricingApi.md index 47a2eb2..c72dca8 100644 --- a/docs/Api/PricingApi.md +++ b/docs/Api/PricingApi.md @@ -78,6 +78,8 @@ requestPricing($country, $service, $pool, $max_price): mixed Retrieve all pricing +Retrieves prices, optionally filtered by country, service, pool and maximum price (`max_price` is rounded to two decimals). Without any filter the response is the full catalog (about 20 MB), rebuilt once an hour. It is sent with `ETag`, `Last-Modified` and `Cache-Control` headers: send `If-None-Match` (or `If-Modified-Since`) with your next request and you get `304 Not Modified` with no body while the catalog has not changed. + ### Example ```php diff --git a/docs/Api/RentalApi.md b/docs/Api/RentalApi.md index 94edc8f..68530c4 100644 --- a/docs/Api/RentalApi.md +++ b/docs/Api/RentalApi.md @@ -27,7 +27,7 @@ All URIs are relative to https://api.smspool.net, except if the operation define ## `purchaseRental()` ```php -purchaseRental($id, $days, $service_id, $create_token, $city, $state, $zipcode): mixed +purchaseRental($id, $days, $idempotency_key, $service_id, $create_token, $city, $state, $zipcode): mixed ``` Order Rental @@ -51,6 +51,7 @@ $apiInstance = new SMSPool\Api\RentalApi( ); $id = 56; // int | Rental ID retrieved from Retrieve Rental IDs $days = 56; // int +$idempotency_key = 3f1c2c0e-7d5b-4a52-9a53-1f6f0f0f2b11; // string $service_id = 56; // int | Optional value on which service you'd purchase the rental for $create_token = 56; // int | Create a rental token which allows you to share this specific rental $city = 'city_example'; // string @@ -58,7 +59,7 @@ $state = 'state_example'; // string $zipcode = 'zipcode_example'; // string try { - $result = $apiInstance->purchaseRental($id, $days, $service_id, $create_token, $city, $state, $zipcode); + $result = $apiInstance->purchaseRental($id, $days, $idempotency_key, $service_id, $create_token, $city, $state, $zipcode); print_r($result); } catch (Exception $e) { echo 'Exception when calling RentalApi->purchaseRental: ', $e->getMessage(), PHP_EOL; @@ -71,6 +72,7 @@ try { | ------------- | ------------- | ------------- | ------------- | | **id** | **int**| Rental ID retrieved from Retrieve Rental IDs | | | **days** | **int**| | | +| **idempotency_key** | **string**| | [optional] | | **service_id** | **int**| Optional value on which service you'd purchase the rental for | [optional] | | **create_token** | **int**| Create a rental token which allows you to share this specific rental | [optional] | | **city** | **string**| | [optional] | @@ -623,6 +625,8 @@ rentalRetrieveMessages($rental_code): mixed Retrieve Rental Messages +Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. + ### Example ```php @@ -791,6 +795,8 @@ rentalRetrieveStatus($rental_code): mixed Retrieve Rental Status +Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. + ### Example ```php @@ -918,11 +924,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 +960,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..636a5d1 100644 --- a/docs/Api/SMSApi.md +++ b/docs/Api/SMSApi.md @@ -11,8 +11,10 @@ All URIs are relative to https://api.smspool.net, except if the operation define | [**requestArchive()**](SMSApi.md#requestArchive) | **POST** /request/archive | Archive all orders | | [**requestAreacodes()**](SMSApi.md#requestAreacodes) | **POST** /request/areacodes | Request available areacodes | | [**requestHistory()**](SMSApi.md#requestHistory) | **POST** /request/history | Order History | +| [**requestHistorySearch()**](SMSApi.md#requestHistorySearch) | **POST** /request/history_search | Search 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 one order | | [**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,11 +30,13 @@ 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, $idempotency_key, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $response, $software): mixed ``` Order SMS +Orders one or more numbers for a service. ### Response shapes Without `response=v2` the shape depends on `quantity`: one number returns the order object; several return a JSON array of order objects; if ordering stops part-way, an object with the orders bought so far under `\"0\"`, `\"1\"`, ... plus `message`. With `response=v2` every case returns the same object: - `success`: 1 when every requested number was ordered, otherwise 0 - `orders`: the orders that were placed (may be empty) - `failed`: the error that stopped the request, as a one-element list (empty on success) - `message`: a summary - `auto_country`: only with `auto_country=1`, the chosen country `response=v2` is ignored together with `create_token=1`. ### Pool `pool` is a pool ID or name from the `Pool List` endpoint. A name that does not exist answers 400 with `type: INVALID_POOL`. Leave it out (or send it empty or `0`) for any pool. ### Retrying safely Send an `Idempotency-Key` header so a retry after a timeout cannot buy twice. + ### Example ```php @@ -51,21 +55,24 @@ $apiInstance = new SMSPool\Api\SMSApi( $config ); $service = 'service_example'; // string | The service or number retrieved from the `Service List` endpoint +$idempotency_key = 3f1c2c0e-7d5b-4a52-9a53-1f6f0f0f2b11; // string $country = 'country_example'; // string | The country in ISO format or number retrieved from the `Country List` endpoint -$pool = 'pool_example'; // string | The pool or number retrieved from the `Pool List` endpoint (optional) +$pool = 'pool_example'; // string | The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. $max_price = 3.4; // float | The max price you are willing to pay per number $pricing_option = 56; // int | Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate -$quantity = 56; // int | Quantity of numbers ordered +$quantity = 56; // int | Quantity of numbers ordered, 1 to 20. Must be a whole number. $areacode = 'areacode_example'; // string | Areacodes you would like to include or exclude in JSON format $exclude = 56; // int | Set exclude to 1 if you would like to exclude all listed area codes. $create_token = 56; // int | Optional param; set to 1 if you'd like to create a token link that anyone can access. $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 +$phonenumber = 56; // int | In case you want to select a specific phone number to order. Digits with the country code; a leading +, spaces and dashes are ignored. +$auto_country = 56; // int | Set to 1 to let SMSPool pick the country: every country with stock is scored on its expected success rate (estimated from the country's record across all services when the service has few orders there; weighed down when little stock backs it, minus a little per dollar) 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. +$response = 'response_example'; // string | Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. $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, $idempotency_key, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $response, $software); print_r($result); } catch (Exception $e) { echo 'Exception when calling SMSApi->purchaseSms: ', $e->getMessage(), PHP_EOL; @@ -77,17 +84,20 @@ try { | Name | Type | Description | Notes | | ------------- | ------------- | ------------- | ------------- | | **service** | **string**| The service or number retrieved from the `Service List` endpoint | | +| **idempotency_key** | **string**| | [optional] | | **country** | **string**| The country in ISO format or number retrieved from the `Country List` endpoint | [optional] | -| **pool** | **string**| The pool or number retrieved from the `Pool List` endpoint (optional) | [optional] | +| **pool** | **string**| The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. | [optional] | | **max_price** | **float**| The max price you are willing to pay per number | [optional] | | **pricing_option** | **int**| Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate | [optional] | -| **quantity** | **int**| Quantity of numbers ordered | [optional] | +| **quantity** | **int**| Quantity of numbers ordered, 1 to 20. Must be a whole number. | [optional] | | **areacode** | **string**| Areacodes you would like to include or exclude in JSON format | [optional] | | **exclude** | **int**| Set exclude to 1 if you would like to exclude all listed area codes. | [optional] | | **create_token** | **int**| Optional param; set to 1 if you'd like to create a token link that anyone can access. | [optional] | | **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] | +| **phonenumber** | **int**| In case you want to select a specific phone number to order. Digits with the country code; a leading +, spaces and dashes are ignored. | [optional] | +| **auto_country** | **int**| Set to 1 to let SMSPool pick the country: every country with stock is scored on its expected success rate (estimated from the country's record across all services when the service has few orders there; weighed down when little stock backs it, minus a little per dollar) 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] | +| **response** | **string**| Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. | [optional] | | **software** | **int**| | [optional] | ### Return type @@ -236,11 +246,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 +282,7 @@ try { ### Authorization -No authorization required +[bearerAuth](../../README.md#bearerAuth) ### HTTP request headers @@ -343,6 +357,70 @@ try { [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `requestHistorySearch()` + +```php +requestHistorySearch($search, $cursor, $limit): mixed +``` + +Search order history + +One step of a search through your order history, newest orders first. Each call reads a bounded slice of your orders and returns the matches in it plus `next`. Pass `next` back as `cursor` to continue; the search is complete when `next` is `null`. A call can return no matches and still have a `next`. + +### 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 +); +$search = 'search_example'; // string | The search term, as typed into the order history's search box. At most 32 characters. +$cursor = 'cursor_example'; // string | `next` from the previous call. Leave out for the first call. +$limit = 56; // int | Matches per call, 1 to 500 (default 100). + +try { + $result = $apiInstance->requestHistorySearch($search, $cursor, $limit); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling SMSApi->requestHistorySearch: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **search** | **string**| The search term, as typed into the order history's search box. At most 32 characters. | | +| **cursor** | **string**| `next` from the previous call. Leave out for the first call. | [optional] | +| **limit** | **int**| Matches per call, 1 to 500 (default 100). | [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) + ## `smsActivate()` ```php @@ -411,7 +489,7 @@ smsAllStock($country, $service, $pool): mixed One-time stock for all services -This API endpoint is used to retrieve one-time SMS stock in the SMSPool system. The HTTP POST request should be sent to `https://api.smspool.net/sms/stock`. ### Request Parameters The \\`key\\` parameter is required for this endpoint, this is your API key. ### Response The response for this API endpoint will have a status code of 200, indicating a successful request. The response body will be in JSON format and will contain the following properties: - `success` (integer): A flag indicating the success of the request. A value of 0 indicates failure. - `message` (string): An optional message providing additional information about the request. In this case, the message is empty. Please note that the response may contain additional properties not mentioned here, but they can be ignored for the purpose of this documentation. +Retrieves the one-time SMS stock for every country, service and pool, optionally filtered by `country`, `service` and `pool`. The API key is optional. The unfiltered list is large and rebuilt once a minute. It is sent with `ETag`, `Last-Modified` and `Cache-Control` headers: send `If-None-Match` (or `If-Modified-Since`) with your next request and you get `304 Not Modified` with no body while the list has not changed. ### Example @@ -463,6 +541,66 @@ No authorization required [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `smsArchive()` + +```php +smsArchive($orderid): mixed +``` + +Archive one order + +Removes one finished order from your active orders. Nothing is refunded and the order stays in your history; `/sms/unarchive` brings it back. An order that is still waiting for an SMS cannot be archived: cancel it with `/sms/cancel` instead. + +### 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 | The order code from the `Order SMS` endpoint. + +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**| The order code from the `Order SMS` endpoint. | | + +### 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 @@ -471,7 +609,7 @@ smsCancel($orderid, $orderids, $expiry, $ban): mixed Cancel SMS -# Cancel your SMS order ## Responses | **Success** | {\"success\":1} | | **Fail** | {\"success\":0} | +Cancels an order. An order that has not received a code is cancelled and refunded. An order that already has its code cannot be refunded; it is only archived (removed from your active orders). Both answer `success: 1`; `action` tells them apart: `refunded` or `archived`. Send `orderids` (comma-separated) to cancel several orders at once; the response then lists one result per order under `results`. ### Example @@ -771,7 +909,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 @@ -953,7 +1091,7 @@ smsStock($country, $service, $pool, $include_price): mixed One-time SMS stock -This API endpoint is used to retrieve one-time SMS stock in the SMSPool system. The HTTP POST request should be sent to `https://api.smspool.net/sms/stock`. ### Request Parameters The \\`key\\` parameter is required for this endpoint, this is your API key. ### Response The response for this API endpoint will have a status code of 200, indicating a successful request. The response body will be in JSON format and will contain the following properties: - `success` (integer): A flag indicating the success of the request. A value of 0 indicates failure. - `message` (string): An optional message providing additional information about the request. In this case, the message is empty. Please note that the response may contain additional properties not mentioned here, but they can be ignored for the purpose of this documentation. +Retrieves the one-time SMS stock for a country and service, optionally for one pool. ### Request Parameters The API key is optional. Without it the request is limited to 20 calls a minute per IP address; with it the limit is 200 a minute. ### Response - `success` (integer): 1 when the stock could be read, 0 otherwise. - `amount` (integer): the numbers in stock. ### Example diff --git a/docs/Api/StatusApi.md b/docs/Api/StatusApi.md new file mode 100644 index 0000000..75d56c4 --- /dev/null +++ b/docs/Api/StatusApi.md @@ -0,0 +1,63 @@ +# SMSPool\StatusApi + +Service health. + +All URIs are relative to https://api.smspool.net, except if the operation defines another base path. + +| Method | HTTP request | Description | +| ------------- | ------------- | ------------- | +| [**up()**](StatusApi.md#up) | **GET** /up | Health check | + + +## `up()` + +```php +up(): mixed +``` + +Health check + +For uptime monitors. Needs no API key. `db` and `cache` say whether the database and the cache answered; `status` is `ok` when both did. The result is refreshed every few seconds. + +### Example + +```php +up(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StatusApi->up: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**mixed** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **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/VoucherApi.md b/docs/Api/VoucherApi.md index 8e5d6d5..9ea199f 100644 --- a/docs/Api/VoucherApi.md +++ b/docs/Api/VoucherApi.md @@ -133,7 +133,7 @@ try { ## `voucherGenerate()` ```php -voucherGenerate($amount): mixed +voucherGenerate($amount, $idempotency_key): mixed ``` Generate voucher @@ -156,9 +156,10 @@ $apiInstance = new SMSPool\Api\VoucherApi( $config ); $amount = 3.4; // float | The amount per promocode +$idempotency_key = 3f1c2c0e-7d5b-4a52-9a53-1f6f0f0f2b11; // string try { - $result = $apiInstance->voucherGenerate($amount); + $result = $apiInstance->voucherGenerate($amount, $idempotency_key); print_r($result); } catch (Exception $e) { echo 'Exception when calling VoucherApi->voucherGenerate: ', $e->getMessage(), PHP_EOL; @@ -170,6 +171,7 @@ try { | Name | Type | Description | Notes | | ------------- | ------------- | ------------- | ------------- | | **amount** | **float**| The amount per promocode | | +| **idempotency_key** | **string**| | [optional] | ### Return type diff --git a/lib/Api/BusinessApi.php b/lib/Api/BusinessApi.php index 0bfc755..485f87e 100644 --- a/lib/Api/BusinessApi.php +++ b/lib/Api/BusinessApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/Api/CarrierApi.php b/lib/Api/CarrierApi.php index 6055336..35ed311 100644 --- a/lib/Api/CarrierApi.php +++ b/lib/Api/CarrierApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech 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..608736b 100644 --- a/lib/Api/InformationApi.php +++ b/lib/Api/InformationApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech @@ -83,6 +83,9 @@ class InformationApi 'poolRetrieveValid' => [ 'application/x-www-form-urlencoded', ], + 'requestAutoCountry' => [ + 'application/x-www-form-urlencoded', + ], 'requestBalance' => [ 'application/json', ], @@ -976,6 +979,300 @@ public function poolRetrieveValidRequest($service, $country, $web = null, $inclu ); } + /** + * Operation requestAutoCountry + * + * Pick the best country for a service + * + * @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 + */ + public function requestAutoCountry($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) + { + list($response) = $this->requestAutoCountryWithHttpInfo($service, $pricing_option, $contentType); + return $response; + } + + /** + * Operation requestAutoCountryWithHttpInfo + * + * Pick the best country for a service + * + * @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, HTTP status code, HTTP response headers (array of strings) + */ + public function requestAutoCountryWithHttpInfo($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) + { + $request = $this->requestAutoCountryRequest($service, $pricing_option, $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, + ); + } + + + + 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; + } + + + throw $e; + } + } + + /** + * Operation requestAutoCountryAsync + * + * Pick the best country for a service + * + * @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 requestAutoCountryAsync($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) + { + return $this->requestAutoCountryAsyncWithHttpInfo($service, $pricing_option, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation requestAutoCountryAsyncWithHttpInfo + * + * Pick the best country for a service + * + * @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 requestAutoCountryAsyncWithHttpInfo($service, $pricing_option = null, string $contentType = self::contentTypes['requestAutoCountry'][0]) + { + $returnType = 'mixed'; + $request = $this->requestAutoCountryRequest($service, $pricing_option, $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 'requestAutoCountry' + * + * @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 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/auto_country'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + // 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 * diff --git a/lib/Api/PreordersApi.php b/lib/Api/PreordersApi.php index dcacab6..3d06849 100644 --- a/lib/Api/PreordersApi.php +++ b/lib/Api/PreordersApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/Api/PricingApi.php b/lib/Api/PricingApi.php index d00c913..064cb04 100644 --- a/lib/Api/PricingApi.php +++ b/lib/Api/PricingApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/Api/RentalApi.php b/lib/Api/RentalApi.php index 2a3c694..596cdd8 100644 --- a/lib/Api/RentalApi.php +++ b/lib/Api/RentalApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech @@ -177,6 +177,7 @@ public function getConfig() * * @param int $id Rental ID retrieved from Retrieve Rental IDs (required) * @param int $days days (required) + * @param string|null $idempotency_key idempotency_key (optional) * @param int|null $service_id Optional value on which service you'd purchase the rental for (optional) * @param int|null $create_token Create a rental token which allows you to share this specific rental (optional) * @param string|null $city city (optional) @@ -186,11 +187,11 @@ public function getConfig() * * @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|mixed|mixed|mixed */ - public function purchaseRental($id, $days, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) + public function purchaseRental($id, $days, $idempotency_key = null, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) { - list($response) = $this->purchaseRentalWithHttpInfo($id, $days, $service_id, $create_token, $city, $state, $zipcode, $contentType); + list($response) = $this->purchaseRentalWithHttpInfo($id, $days, $idempotency_key, $service_id, $create_token, $city, $state, $zipcode, $contentType); return $response; } @@ -201,6 +202,7 @@ public function purchaseRental($id, $days, $service_id = null, $create_token = n * * @param int $id Rental ID retrieved from Retrieve Rental IDs (required) * @param int $days (required) + * @param string|null $idempotency_key (optional) * @param int|null $service_id Optional value on which service you'd purchase the rental for (optional) * @param int|null $create_token Create a rental token which allows you to share this specific rental (optional) * @param string|null $city (optional) @@ -210,11 +212,11 @@ public function purchaseRental($id, $days, $service_id = null, $create_token = n * * @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|mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) */ - public function purchaseRentalWithHttpInfo($id, $days, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) + public function purchaseRentalWithHttpInfo($id, $days, $idempotency_key = null, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) { - $request = $this->purchaseRentalRequest($id, $days, $service_id, $create_token, $city, $state, $zipcode, $contentType); + $request = $this->purchaseRentalRequest($id, $days, $idempotency_key, $service_id, $create_token, $city, $state, $zipcode, $contentType); try { $options = $this->createHttpClientOption(); @@ -264,6 +266,12 @@ public function purchaseRentalWithHttpInfo($id, $days, $service_id = null, $crea $request, $response, ); + case 409: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); } @@ -320,6 +328,14 @@ public function purchaseRentalWithHttpInfo($id, $days, $service_id = null, $crea ); $e->setResponseObject($data); throw $e; + case 409: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; } @@ -334,6 +350,7 @@ public function purchaseRentalWithHttpInfo($id, $days, $service_id = null, $crea * * @param int $id Rental ID retrieved from Retrieve Rental IDs (required) * @param int $days (required) + * @param string|null $idempotency_key (optional) * @param int|null $service_id Optional value on which service you'd purchase the rental for (optional) * @param int|null $create_token Create a rental token which allows you to share this specific rental (optional) * @param string|null $city (optional) @@ -344,9 +361,9 @@ public function purchaseRentalWithHttpInfo($id, $days, $service_id = null, $crea * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function purchaseRentalAsync($id, $days, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) + public function purchaseRentalAsync($id, $days, $idempotency_key = null, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) { - return $this->purchaseRentalAsyncWithHttpInfo($id, $days, $service_id, $create_token, $city, $state, $zipcode, $contentType) + return $this->purchaseRentalAsyncWithHttpInfo($id, $days, $idempotency_key, $service_id, $create_token, $city, $state, $zipcode, $contentType) ->then( function ($response) { return $response[0]; @@ -361,6 +378,7 @@ function ($response) { * * @param int $id Rental ID retrieved from Retrieve Rental IDs (required) * @param int $days (required) + * @param string|null $idempotency_key (optional) * @param int|null $service_id Optional value on which service you'd purchase the rental for (optional) * @param int|null $create_token Create a rental token which allows you to share this specific rental (optional) * @param string|null $city (optional) @@ -371,10 +389,10 @@ function ($response) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function purchaseRentalAsyncWithHttpInfo($id, $days, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) + public function purchaseRentalAsyncWithHttpInfo($id, $days, $idempotency_key = null, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) { $returnType = 'mixed'; - $request = $this->purchaseRentalRequest($id, $days, $service_id, $create_token, $city, $state, $zipcode, $contentType); + $request = $this->purchaseRentalRequest($id, $days, $idempotency_key, $service_id, $create_token, $city, $state, $zipcode, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -417,6 +435,7 @@ function ($exception) { * * @param int $id Rental ID retrieved from Retrieve Rental IDs (required) * @param int $days (required) + * @param string|null $idempotency_key (optional) * @param int|null $service_id Optional value on which service you'd purchase the rental for (optional) * @param int|null $create_token Create a rental token which allows you to share this specific rental (optional) * @param string|null $city (optional) @@ -427,7 +446,7 @@ function ($exception) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function purchaseRentalRequest($id, $days, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) + public function purchaseRentalRequest($id, $days, $idempotency_key = null, $service_id = null, $create_token = null, $city = null, $state = null, $zipcode = null, string $contentType = self::contentTypes['purchaseRental'][0]) { // verify the required parameter 'id' is set @@ -450,6 +469,7 @@ public function purchaseRentalRequest($id, $days, $service_id = null, $create_to + $resourcePath = '/purchase/rental'; $formParams = []; $queryParams = []; @@ -458,6 +478,10 @@ public function purchaseRentalRequest($id, $days, $service_id = null, $create_to $multipart = false; + // header params + if ($idempotency_key !== null) { + $headerParams['Idempotency-Key'] = ObjectSerializer::toHeaderValue($idempotency_key); + } // form params @@ -4799,7 +4823,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 +4843,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 +4879,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 +4923,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 +5110,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..7c007b1 100644 --- a/lib/Api/SMSApi.php +++ b/lib/Api/SMSApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech @@ -89,12 +89,18 @@ class SMSApi 'requestHistory' => [ 'application/x-www-form-urlencoded', ], + 'requestHistorySearch' => [ + 'application/x-www-form-urlencoded', + ], 'smsActivate' => [ 'application/x-www-form-urlencoded', ], 'smsAllStock' => [ 'application/x-www-form-urlencoded', ], + 'smsArchive' => [ + 'application/x-www-form-urlencoded', + ], 'smsCancel' => [ 'application/x-www-form-urlencoded', ], @@ -179,27 +185,30 @@ public function getConfig() * Order SMS * * @param string $service The service or number retrieved from the `Service List` endpoint (required) + * @param string|null $idempotency_key idempotency_key (optional) * @param string|null $country The country in ISO format or number retrieved from the `Country List` endpoint (optional) - * @param string|null $pool The pool or number retrieved from the `Pool List` endpoint (optional) (optional) + * @param string|null $pool The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. (optional) * @param float|null $max_price The max price you are willing to pay per number (optional) * @param int|null $pricing_option Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate (optional) - * @param int|null $quantity Quantity of numbers ordered (optional) + * @param int|null $quantity Quantity of numbers ordered, 1 to 20. Must be a whole number. (optional) * @param string|null $areacode Areacodes you would like to include or exclude in JSON format (optional) * @param int|null $exclude Set exclude to 1 if you would like to exclude all listed area codes. (optional) * @param int|null $create_token Optional param; set to 1 if you'd like to create a token link that anyone can access. (optional) * @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 $phonenumber In case you want to select a specific phone number to order. Digits with the country code; a leading +, spaces and dashes are ignored. (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its expected success rate (estimated from the country's record across all services when the service has few orders there; weighed down when little stock backs it, minus a little per dollar) 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 string|null $response Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. (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 * * @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|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, $idempotency_key = null, $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, $response = 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, $idempotency_key, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $response, $software, $contentType); return $response; } @@ -209,27 +218,30 @@ public function purchaseSms($service, $country = null, $pool = null, $max_price * Order SMS * * @param string $service The service or number retrieved from the `Service List` endpoint (required) + * @param string|null $idempotency_key (optional) * @param string|null $country The country in ISO format or number retrieved from the `Country List` endpoint (optional) - * @param string|null $pool The pool or number retrieved from the `Pool List` endpoint (optional) (optional) + * @param string|null $pool The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. (optional) * @param float|null $max_price The max price you are willing to pay per number (optional) * @param int|null $pricing_option Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate (optional) - * @param int|null $quantity Quantity of numbers ordered (optional) + * @param int|null $quantity Quantity of numbers ordered, 1 to 20. Must be a whole number. (optional) * @param string|null $areacode Areacodes you would like to include or exclude in JSON format (optional) * @param int|null $exclude Set exclude to 1 if you would like to exclude all listed area codes. (optional) * @param int|null $create_token Optional param; set to 1 if you'd like to create a token link that anyone can access. (optional) * @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 $phonenumber In case you want to select a specific phone number to order. Digits with the country code; a leading +, spaces and dashes are ignored. (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its expected success rate (estimated from the country's record across all services when the service has few orders there; weighed down when little stock backs it, minus a little per dollar) 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 string|null $response Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. (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 \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|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, $idempotency_key = null, $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, $response = 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, $idempotency_key, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $response, $software, $contentType); try { $options = $this->createHttpClientOption(); @@ -261,6 +273,12 @@ public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, $request, $response, ); + case 400: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); case 401: return $this->handleResponseWithDataType( 'mixed', @@ -273,6 +291,12 @@ public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, $request, $response, ); + case 409: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); case 422: return $this->handleResponseWithDataType( 'mixed', @@ -311,6 +335,14 @@ public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, ); $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(), @@ -327,6 +359,14 @@ public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, ); $e->setResponseObject($data); throw $e; + case 409: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -348,26 +388,29 @@ public function purchaseSmsWithHttpInfo($service, $country = null, $pool = null, * Order SMS * * @param string $service The service or number retrieved from the `Service List` endpoint (required) + * @param string|null $idempotency_key (optional) * @param string|null $country The country in ISO format or number retrieved from the `Country List` endpoint (optional) - * @param string|null $pool The pool or number retrieved from the `Pool List` endpoint (optional) (optional) + * @param string|null $pool The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. (optional) * @param float|null $max_price The max price you are willing to pay per number (optional) * @param int|null $pricing_option Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate (optional) - * @param int|null $quantity Quantity of numbers ordered (optional) + * @param int|null $quantity Quantity of numbers ordered, 1 to 20. Must be a whole number. (optional) * @param string|null $areacode Areacodes you would like to include or exclude in JSON format (optional) * @param int|null $exclude Set exclude to 1 if you would like to exclude all listed area codes. (optional) * @param int|null $create_token Optional param; set to 1 if you'd like to create a token link that anyone can access. (optional) * @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 $phonenumber In case you want to select a specific phone number to order. Digits with the country code; a leading +, spaces and dashes are ignored. (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its expected success rate (estimated from the country's record across all services when the service has few orders there; weighed down when little stock backs it, minus a little per dollar) 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 string|null $response Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. (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, $idempotency_key = null, $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, $response = 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, $idempotency_key, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $response, $software, $contentType) ->then( function ($response) { return $response[0]; @@ -381,27 +424,30 @@ function ($response) { * Order SMS * * @param string $service The service or number retrieved from the `Service List` endpoint (required) + * @param string|null $idempotency_key (optional) * @param string|null $country The country in ISO format or number retrieved from the `Country List` endpoint (optional) - * @param string|null $pool The pool or number retrieved from the `Pool List` endpoint (optional) (optional) + * @param string|null $pool The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. (optional) * @param float|null $max_price The max price you are willing to pay per number (optional) * @param int|null $pricing_option Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate (optional) - * @param int|null $quantity Quantity of numbers ordered (optional) + * @param int|null $quantity Quantity of numbers ordered, 1 to 20. Must be a whole number. (optional) * @param string|null $areacode Areacodes you would like to include or exclude in JSON format (optional) * @param int|null $exclude Set exclude to 1 if you would like to exclude all listed area codes. (optional) * @param int|null $create_token Optional param; set to 1 if you'd like to create a token link that anyone can access. (optional) * @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 $phonenumber In case you want to select a specific phone number to order. Digits with the country code; a leading +, spaces and dashes are ignored. (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its expected success rate (estimated from the country's record across all services when the service has few orders there; weighed down when little stock backs it, minus a little per dollar) 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 string|null $response Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. (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, $idempotency_key = null, $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, $response = 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, $idempotency_key, $country, $pool, $max_price, $pricing_option, $quantity, $areacode, $exclude, $create_token, $activation_type, $carrier, $phonenumber, $auto_country, $response, $software, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -443,24 +489,27 @@ function ($exception) { * Create request for operation 'purchaseSms' * * @param string $service The service or number retrieved from the `Service List` endpoint (required) + * @param string|null $idempotency_key (optional) * @param string|null $country The country in ISO format or number retrieved from the `Country List` endpoint (optional) - * @param string|null $pool The pool or number retrieved from the `Pool List` endpoint (optional) (optional) + * @param string|null $pool The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. (optional) * @param float|null $max_price The max price you are willing to pay per number (optional) * @param int|null $pricing_option Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate (optional) - * @param int|null $quantity Quantity of numbers ordered (optional) + * @param int|null $quantity Quantity of numbers ordered, 1 to 20. Must be a whole number. (optional) * @param string|null $areacode Areacodes you would like to include or exclude in JSON format (optional) * @param int|null $exclude Set exclude to 1 if you would like to exclude all listed area codes. (optional) * @param int|null $create_token Optional param; set to 1 if you'd like to create a token link that anyone can access. (optional) * @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 $phonenumber In case you want to select a specific phone number to order. Digits with the country code; a leading +, spaces and dashes are ignored. (optional) + * @param int|null $auto_country Set to 1 to let SMSPool pick the country: every country with stock is scored on its expected success rate (estimated from the country's record across all services when the service has few orders there; weighed down when little stock backs it, minus a little per dollar) 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 string|null $response Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. (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, $idempotency_key = null, $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, $response = null, $software = null, string $contentType = self::contentTypes['purchaseSms'][0]) { // verify the required parameter 'service' is set @@ -483,6 +532,9 @@ public function purchaseSmsRequest($service, $country = null, $pool = null, $max + + + $resourcePath = '/purchase/sms'; $formParams = []; $queryParams = []; @@ -491,6 +543,10 @@ public function purchaseSmsRequest($service, $country = null, $pool = null, $max $multipart = false; + // header params + if ($idempotency_key !== null) { + $headerParams['Idempotency-Key'] = ObjectSerializer::toHeaderValue($idempotency_key); + } // form params @@ -509,6 +565,8 @@ public function purchaseSmsRequest($service, $country = null, $pool = null, $max 'activation_type' => $activation_type, 'carrier' => $carrier, 'phonenumber' => $phonenumber, + 'auto_country' => $auto_country, + 'response' => $response, 'software' => $software, ]); @@ -1156,7 +1214,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 +1234,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 +1270,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 +1314,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 +1507,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()) { @@ -1757,38 +1847,42 @@ public function requestHistoryRequest($start = null, $length = null, $search = n } /** - * Operation smsActivate + * Operation requestHistorySearch * - * Activate SMS + * Search order history * - * @param string $orderid orderid (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation + * @param string $search The search term, as typed into the order history's search box. At most 32 characters. (required) + * @param string|null $cursor `next` from the previous call. Leave out for the first call. (optional) + * @param int|null $limit Matches per call, 1 to 500 (default 100). (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|mixed|mixed + * @return mixed|mixed|mixed|mixed */ - public function smsActivate($orderid, string $contentType = self::contentTypes['smsActivate'][0]) + public function requestHistorySearch($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) { - list($response) = $this->smsActivateWithHttpInfo($orderid, $contentType); + list($response) = $this->requestHistorySearchWithHttpInfo($search, $cursor, $limit, $contentType); return $response; } /** - * Operation smsActivateWithHttpInfo + * Operation requestHistorySearchWithHttpInfo * - * Activate SMS + * Search order history * - * @param string $orderid (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation + * @param string $search The search term, as typed into the order history's search box. At most 32 characters. (required) + * @param string|null $cursor `next` from the previous call. Leave out for the first call. (optional) + * @param int|null $limit Matches per call, 1 to 500 (default 100). (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|mixed|mixed, HTTP status code, HTTP response headers (array of strings) + * @return array of mixed|mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) */ - public function smsActivateWithHttpInfo($orderid, string $contentType = self::contentTypes['smsActivate'][0]) + public function requestHistorySearchWithHttpInfo($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) { - $request = $this->smsActivateRequest($orderid, $contentType); + $request = $this->requestHistorySearchRequest($search, $cursor, $limit, $contentType); try { $options = $this->createHttpClientOption(); @@ -1820,12 +1914,6 @@ public function smsActivateWithHttpInfo($orderid, string $contentType = self::co $request, $response, ); - case 400: - return $this->handleResponseWithDataType( - 'mixed', - $request, - $response, - ); case 401: return $this->handleResponseWithDataType( 'mixed', @@ -1838,7 +1926,7 @@ public function smsActivateWithHttpInfo($orderid, string $contentType = self::co $request, $response, ); - case 404: + case 422: return $this->handleResponseWithDataType( 'mixed', $request, @@ -1876,14 +1964,6 @@ public function smsActivateWithHttpInfo($orderid, string $contentType = self::co ); $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(), @@ -1900,7 +1980,7 @@ public function smsActivateWithHttpInfo($orderid, string $contentType = self::co ); $e->setResponseObject($data); throw $e; - case 404: + case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), 'mixed', @@ -1916,19 +1996,21 @@ public function smsActivateWithHttpInfo($orderid, string $contentType = self::co } /** - * Operation smsActivateAsync + * Operation requestHistorySearchAsync * - * Activate SMS + * Search order history * - * @param string $orderid (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation + * @param string $search The search term, as typed into the order history's search box. At most 32 characters. (required) + * @param string|null $cursor `next` from the previous call. Leave out for the first call. (optional) + * @param int|null $limit Matches per call, 1 to 500 (default 100). (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 smsActivateAsync($orderid, string $contentType = self::contentTypes['smsActivate'][0]) + public function requestHistorySearchAsync($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) { - return $this->smsActivateAsyncWithHttpInfo($orderid, $contentType) + return $this->requestHistorySearchAsyncWithHttpInfo($search, $cursor, $limit, $contentType) ->then( function ($response) { return $response[0]; @@ -1937,20 +2019,22 @@ function ($response) { } /** - * Operation smsActivateAsyncWithHttpInfo + * Operation requestHistorySearchAsyncWithHttpInfo * - * Activate SMS + * Search order history * - * @param string $orderid (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation + * @param string $search The search term, as typed into the order history's search box. At most 32 characters. (required) + * @param string|null $cursor `next` from the previous call. Leave out for the first call. (optional) + * @param int|null $limit Matches per call, 1 to 500 (default 100). (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 smsActivateAsyncWithHttpInfo($orderid, string $contentType = self::contentTypes['smsActivate'][0]) + public function requestHistorySearchAsyncWithHttpInfo($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) { $returnType = 'mixed'; - $request = $this->smsActivateRequest($orderid, $contentType); + $request = $this->requestHistorySearchRequest($search, $cursor, $limit, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1989,26 +2073,30 @@ function ($exception) { } /** - * Create request for operation 'smsActivate' + * Create request for operation 'requestHistorySearch' * - * @param string $orderid (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation + * @param string $search The search term, as typed into the order history's search box. At most 32 characters. (required) + * @param string|null $cursor `next` from the previous call. Leave out for the first call. (optional) + * @param int|null $limit Matches per call, 1 to 500 (default 100). (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 smsActivateRequest($orderid, string $contentType = self::contentTypes['smsActivate'][0]) + public function requestHistorySearchRequest($search, $cursor = null, $limit = null, string $contentType = self::contentTypes['requestHistorySearch'][0]) { - // verify the required parameter 'orderid' is set - if ($orderid === null || (is_array($orderid) && count($orderid) === 0)) { + // verify the required parameter 'search' is set + if ($search === null || (is_array($search) && count($search) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $orderid when calling smsActivate' + 'Missing the required parameter $search when calling requestHistorySearch' ); } - $resourcePath = '/sms/activate'; + + + $resourcePath = '/request/history_search'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2022,7 +2110,9 @@ public function smsActivateRequest($orderid, string $contentType = self::content $formDataProcessor = new FormDataProcessor(); $formData = $formDataProcessor->prepare([ - 'orderid' => $orderid, + 'search' => $search, + 'cursor' => $cursor, + 'limit' => $limit, ]); $formParams = $formDataProcessor->flatten($formData); @@ -2090,42 +2180,38 @@ public function smsActivateRequest($orderid, string $contentType = self::content } /** - * Operation smsAllStock + * Operation smsActivate * - * One-time stock for all services + * Activate SMS * - * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) - * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) - * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * @param string $orderid orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] 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 + * @return mixed|mixed|mixed|mixed|mixed */ - public function smsAllStock($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + public function smsActivate($orderid, string $contentType = self::contentTypes['smsActivate'][0]) { - list($response) = $this->smsAllStockWithHttpInfo($country, $service, $pool, $contentType); + list($response) = $this->smsActivateWithHttpInfo($orderid, $contentType); return $response; } /** - * Operation smsAllStockWithHttpInfo + * Operation smsActivateWithHttpInfo * - * One-time stock for all services + * Activate SMS * - * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) - * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) - * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] 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) + * @return array of mixed|mixed|mixed|mixed|mixed, HTTP status code, HTTP response headers (array of strings) */ - public function smsAllStockWithHttpInfo($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + public function smsActivateWithHttpInfo($orderid, string $contentType = self::contentTypes['smsActivate'][0]) { - $request = $this->smsAllStockRequest($country, $service, $pool, $contentType); + $request = $this->smsActivateRequest($orderid, $contentType); try { $options = $this->createHttpClientOption(); @@ -2157,6 +2243,30 @@ public function smsAllStockWithHttpInfo($country = null, $service = null, $pool $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, + ); + case 404: + return $this->handleResponseWithDataType( + 'mixed', + $request, + $response, + ); } @@ -2189,6 +2299,38 @@ public function smsAllStockWithHttpInfo($country = null, $service = null, $pool ); $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; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; } @@ -2197,21 +2339,19 @@ public function smsAllStockWithHttpInfo($country = null, $service = null, $pool } /** - * Operation smsAllStockAsync + * Operation smsActivateAsync * - * One-time stock for all services + * Activate SMS * - * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) - * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) - * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function smsAllStockAsync($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + public function smsActivateAsync($orderid, string $contentType = self::contentTypes['smsActivate'][0]) { - return $this->smsAllStockAsyncWithHttpInfo($country, $service, $pool, $contentType) + return $this->smsActivateAsyncWithHttpInfo($orderid, $contentType) ->then( function ($response) { return $response[0]; @@ -2220,22 +2360,20 @@ function ($response) { } /** - * Operation smsAllStockAsyncWithHttpInfo + * Operation smsActivateAsyncWithHttpInfo * - * One-time stock for all services + * Activate SMS * - * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) - * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) - * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function smsAllStockAsyncWithHttpInfo($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + public function smsActivateAsyncWithHttpInfo($orderid, string $contentType = self::contentTypes['smsActivate'][0]) { $returnType = 'mixed'; - $request = $this->smsAllStockRequest($country, $service, $pool, $contentType); + $request = $this->smsActivateRequest($orderid, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2274,24 +2412,612 @@ function ($exception) { } /** - * Create request for operation 'smsAllStock' + * Create request for operation 'smsActivate' * - * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) - * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) - * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * @param string $orderid (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsActivate'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function smsAllStockRequest($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + public function smsActivateRequest($orderid, string $contentType = self::contentTypes['smsActivate'][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 smsActivate' + ); + } + + + $resourcePath = '/sms/activate'; + $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 smsAllStock + * + * One-time stock for all services + * + * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) + * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) + * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] 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 smsAllStock($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + { + list($response) = $this->smsAllStockWithHttpInfo($country, $service, $pool, $contentType); + return $response; + } + + /** + * Operation smsAllStockWithHttpInfo + * + * One-time stock for all services + * + * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) + * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) + * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] 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 smsAllStockWithHttpInfo($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + { + $request = $this->smsAllStockRequest($country, $service, $pool, $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 smsAllStockAsync + * + * One-time stock for all services + * + * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) + * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) + * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function smsAllStockAsync($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + { + return $this->smsAllStockAsyncWithHttpInfo($country, $service, $pool, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation smsAllStockAsyncWithHttpInfo + * + * One-time stock for all services + * + * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) + * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) + * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function smsAllStockAsyncWithHttpInfo($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + { + $returnType = 'mixed'; + $request = $this->smsAllStockRequest($country, $service, $pool, $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 'smsAllStock' + * + * @param string|null $country Country retrieved from ''Country list\\\" endpoint (optional) (optional) + * @param string|null $service Service retrieved from ''Service list\\\" endpoint (optional) (optional) + * @param string|null $pool Pool retrieved from ''Pool list\\\" endpoint (optional) (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['smsAllStock'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function smsAllStockRequest($country = null, $service = null, $pool = null, string $contentType = self::contentTypes['smsAllStock'][0]) + { + + + + + + $resourcePath = '/sms/all_stock'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + // form params + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'country' => $country, + 'service' => $service, + 'pool' => $pool, + ]); + + $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 smsArchive + * + * Archive one order + * + * @param string $orderid The order code from the `Order SMS` endpoint. (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 one order + * + * @param string $orderid The order code from the `Order SMS` endpoint. (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, + ); + } + - $resourcePath = '/sms/all_stock'; + 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 one order + * + * @param string $orderid The order code from the `Order SMS` endpoint. (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 one order + * + * @param string $orderid The order code from the `Order SMS` endpoint. (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 The order code from the `Order SMS` endpoint. (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 = []; @@ -2305,9 +3031,7 @@ public function smsAllStockRequest($country = null, $service = null, $pool = nul $formDataProcessor = new FormDataProcessor(); $formData = $formDataProcessor->prepare([ - 'country' => $country, - 'service' => $service, - 'pool' => $pool, + 'orderid' => $orderid, ]); $formParams = $formDataProcessor->flatten($formData); @@ -2348,6 +3072,10 @@ public function smsAllStockRequest($country = null, $service = null, $pool = nul } } + // 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/StatusApi.php b/lib/Api/StatusApi.php new file mode 100644 index 0000000..4fcfa33 --- /dev/null +++ b/lib/Api/StatusApi.php @@ -0,0 +1,463 @@ +`. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. + * + * 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; + +/** + * StatusApi Class Doc Comment + * + * @category Class + * @package SMSPool + * @author OpenAPI Generator team + * @link https://openapi-generator.tech + */ +class StatusApi +{ + /** + * @var ClientInterface + */ + protected $client; + + /** + * @var Configuration + */ + protected $config; + + /** + * @var HeaderSelector + */ + protected $headerSelector; + + /** + * @var int Host index + */ + protected $hostIndex; + + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'up' => [ + 'application/json', + ], + ]; + + /** + * @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 up + * + * Health check + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['up'] 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 + */ + public function up(string $contentType = self::contentTypes['up'][0]) + { + list($response) = $this->upWithHttpInfo($contentType); + return $response; + } + + /** + * Operation upWithHttpInfo + * + * Health check + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['up'] 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, HTTP status code, HTTP response headers (array of strings) + */ + public function upWithHttpInfo(string $contentType = self::contentTypes['up'][0]) + { + $request = $this->upRequest($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 503: + 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 503: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'mixed', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation upAsync + * + * Health check + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['up'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function upAsync(string $contentType = self::contentTypes['up'][0]) + { + return $this->upAsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation upAsyncWithHttpInfo + * + * Health check + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['up'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function upAsyncWithHttpInfo(string $contentType = self::contentTypes['up'][0]) + { + $returnType = 'mixed'; + $request = $this->upRequest($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 'up' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['up'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function upRequest(string $contentType = self::contentTypes['up'][0]) + { + + + $resourcePath = '/up'; + $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); + } + } + + + $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( + 'GET', + $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/VoucherApi.php b/lib/Api/VoucherApi.php index 946b6be..884d163 100644 --- a/lib/Api/VoucherApi.php +++ b/lib/Api/VoucherApi.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech @@ -763,15 +763,16 @@ public function voucherDeleteRequest($voucher, string $contentType = self::conte * Generate voucher * * @param float $amount The amount per promocode (required) + * @param string|null $idempotency_key idempotency_key (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['voucherGenerate'] 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 voucherGenerate($amount, string $contentType = self::contentTypes['voucherGenerate'][0]) + public function voucherGenerate($amount, $idempotency_key = null, string $contentType = self::contentTypes['voucherGenerate'][0]) { - list($response) = $this->voucherGenerateWithHttpInfo($amount, $contentType); + list($response) = $this->voucherGenerateWithHttpInfo($amount, $idempotency_key, $contentType); return $response; } @@ -781,15 +782,16 @@ public function voucherGenerate($amount, string $contentType = self::contentType * Generate voucher * * @param float $amount The amount per promocode (required) + * @param string|null $idempotency_key (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['voucherGenerate'] 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 voucherGenerateWithHttpInfo($amount, string $contentType = self::contentTypes['voucherGenerate'][0]) + public function voucherGenerateWithHttpInfo($amount, $idempotency_key = null, string $contentType = self::contentTypes['voucherGenerate'][0]) { - $request = $this->voucherGenerateRequest($amount, $contentType); + $request = $this->voucherGenerateRequest($amount, $idempotency_key, $contentType); try { $options = $this->createHttpClientOption(); @@ -894,14 +896,15 @@ public function voucherGenerateWithHttpInfo($amount, string $contentType = self: * Generate voucher * * @param float $amount The amount per promocode (required) + * @param string|null $idempotency_key (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['voucherGenerate'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function voucherGenerateAsync($amount, string $contentType = self::contentTypes['voucherGenerate'][0]) + public function voucherGenerateAsync($amount, $idempotency_key = null, string $contentType = self::contentTypes['voucherGenerate'][0]) { - return $this->voucherGenerateAsyncWithHttpInfo($amount, $contentType) + return $this->voucherGenerateAsyncWithHttpInfo($amount, $idempotency_key, $contentType) ->then( function ($response) { return $response[0]; @@ -915,15 +918,16 @@ function ($response) { * Generate voucher * * @param float $amount The amount per promocode (required) + * @param string|null $idempotency_key (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['voucherGenerate'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function voucherGenerateAsyncWithHttpInfo($amount, string $contentType = self::contentTypes['voucherGenerate'][0]) + public function voucherGenerateAsyncWithHttpInfo($amount, $idempotency_key = null, string $contentType = self::contentTypes['voucherGenerate'][0]) { $returnType = 'mixed'; - $request = $this->voucherGenerateRequest($amount, $contentType); + $request = $this->voucherGenerateRequest($amount, $idempotency_key, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -965,12 +969,13 @@ function ($exception) { * Create request for operation 'voucherGenerate' * * @param float $amount The amount per promocode (required) + * @param string|null $idempotency_key (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['voucherGenerate'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function voucherGenerateRequest($amount, string $contentType = self::contentTypes['voucherGenerate'][0]) + public function voucherGenerateRequest($amount, $idempotency_key = null, string $contentType = self::contentTypes['voucherGenerate'][0]) { // verify the required parameter 'amount' is set @@ -981,6 +986,7 @@ public function voucherGenerateRequest($amount, string $contentType = self::cont } + $resourcePath = '/voucher/generate'; $formParams = []; $queryParams = []; @@ -989,6 +995,10 @@ public function voucherGenerateRequest($amount, string $contentType = self::cont $multipart = false; + // header params + if ($idempotency_key !== null) { + $headerParams['Idempotency-Key'] = ObjectSerializer::toHeaderValue($idempotency_key); + } // form params diff --git a/lib/ApiException.php b/lib/ApiException.php index b7ff509..603ff04 100644 --- a/lib/ApiException.php +++ b/lib/ApiException.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/Configuration.php b/lib/Configuration.php index 089734a..58634b4 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/FormDataProcessor.php b/lib/FormDataProcessor.php index b0f1642..6b436d7 100644 --- a/lib/FormDataProcessor.php +++ b/lib/FormDataProcessor.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/HeaderSelector.php b/lib/HeaderSelector.php index a9404cf..0de1395 100644 --- a/lib/HeaderSelector.php +++ b/lib/HeaderSelector.php @@ -12,7 +12,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/Model/ModelInterface.php b/lib/Model/ModelInterface.php index 7b3642b..5c4fd46 100644 --- a/lib/Model/ModelInterface.php +++ b/lib/Model/ModelInterface.php @@ -13,7 +13,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php index 8da50f6..de02e2b 100644 --- a/lib/ObjectSerializer.php +++ b/lib/ObjectSerializer.php @@ -13,7 +13,7 @@ /** * SMSPool API * - * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). Authenticate with your API key from https://www.smspool.net/my/settings, either as a bearer token (`Authorization: Bearer `) or as a `key` parameter. + * Every endpoint accepts its parameters as form fields (POST) or query parameters (GET). A JSON object body (`Content-Type: application/json`) works too: its top-level fields are read as parameters; a parameter that is also in the query string or form body wins. Authenticate with your API key from https://www.smspool.net/my/settings as a bearer token: `Authorization: Bearer `. A `key` field in a POST body works too. Keep the key out of the URL: a URL is saved in browser history and can be recorded by proxies and logs on the way to us. Use of the API is subject to the [Terms of Service](https://www.smspool.net/tos#api). Article 11 covers API use: sanctions and geographic restrictions, what you must require of your own users if you resell the service, and the safekeeping of keys. ## Errors An error answers with `success: 0`, a human-readable `message` and, where the API can name the cause, a machine-readable `type`. Check `type`, not the text of `message`. Parameter and key errors also carry `errors`, one entry per problem (`message`, `param`, `type`); the top-level `message` and `type` repeat the API key's entry when there is one, otherwise the first. | `type` | HTTP | Meaning | | --- | --- | --- | | `MISSING_PARAMETER` | 400 | A required parameter was not sent | | `INVALID_PARAMETER` | varies | A parameter has a value the endpoint cannot use | | `INVALID_POOL` | 400 | `/purchase/sms`: the `pool` name does not exist | | `INVALID_KEY` | 401 / 403 | The API key is malformed (401) or unknown or revoked (403) | | `API_KEY_SCOPE` | 403 | The API key is not allowed to call this endpoint, or not from this IP address | | `RATE_LIMITED` | 429 | Too many requests; wait for the `Retry-After` header's seconds | | `IDEMPOTENCY_IN_PROGRESS` | 409 | The first request with this `Idempotency-Key` has not finished | Endpoints add their own types (for example `OUT_OF_STOCK`). Older errors may have no `type`. ## Idempotent purchases `/purchase/sms`, `/purchase/rental`, `/esim/purchase` and `/voucher/generate` accept an optional `Idempotency-Key` header (or an `idempotency_key` parameter): 1 to 128 printable ASCII characters that you choose, unique per purchase, for example a UUID. If a request times out, send it again with the same key: - the first request runs normally; - a repeat within 24 hours answers with the first request's status and body and the header `Idempotent-Replay: true`, and buys nothing; - a repeat while the first is still running answers `409` with `type: IDEMPOTENCY_IN_PROGRESS`; retry shortly. A request that bought nothing (`success: 0`) does not use up its key, so it can be retried with the same one. A key belongs to your account and the endpoint. Requests without a key behave as they always have. ## Webhooks Instead of polling `/sms/check`, set a webhook URL under Settings → Developer and receive each SMS as a signed JSON `POST`. The events are listed under Webhooks below; setup, retries and signature checks are described in [How to set up webhooks](https://www.smspool.net/article/how-to-setup-webhooks-for-smspool-ec19b80ade92). ## Health check `GET /up` needs no key and answers `200 {\"status\":\"ok\",...}` or `503 {\"status\":\"degraded\",...}`. * * The version of the OpenAPI document: 1.0 * Generated by: https://openapi-generator.tech