From 71c907f3ee95e18cb2fd136f5b3532ffdb71422a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:13:18 +0000 Subject: [PATCH] Regenerate from the latest API spec --- .openapi-generator/FILES | 4 +- docs/BusinessApi.md | 2 + docs/CarrierApi.md | 2 +- docs/ESIMsApi.md | 636 ---------------------------- docs/InformationApi.md | 71 +++- docs/PricingApi.md | 2 + docs/RentalApi.md | 13 +- docs/SMSApi.md | 181 +++++++- docs/StatusApi.md | 69 ++++ docs/VoucherApi.md | 12 +- lib/smspool.rb | 4 +- lib/smspool/api/business_api.rb | 4 +- lib/smspool/api/carrier_api.rb | 6 +- lib/smspool/api/esims_api.rb | 637 ----------------------------- lib/smspool/api/information_api.rb | 78 +++- lib/smspool/api/preorders_api.rb | 2 +- lib/smspool/api/pricing_api.rb | 4 +- lib/smspool/api/rental_api.rb | 11 +- lib/smspool/api/sms_api.rb | 187 ++++++++- lib/smspool/api/status_api.rb | 79 ++++ lib/smspool/api/voucher_api.rb | 5 +- lib/smspool/api_client.rb | 2 +- lib/smspool/api_error.rb | 2 +- lib/smspool/api_model_base.rb | 2 +- lib/smspool/configuration.rb | 2 +- lib/smspool/version.rb | 2 +- smspool.gemspec | 2 +- 27 files changed, 692 insertions(+), 1329 deletions(-) delete mode 100644 docs/ESIMsApi.md create mode 100644 docs/StatusApi.md delete mode 100644 lib/smspool/api/esims_api.rb create mode 100644 lib/smspool/api/status_api.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index a31829d..41f1417 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -4,22 +4,22 @@ Gemfile Rakefile docs/BusinessApi.md docs/CarrierApi.md -docs/ESIMsApi.md docs/InformationApi.md docs/PreordersApi.md docs/PricingApi.md docs/RentalApi.md docs/SMSApi.md +docs/StatusApi.md docs/VoucherApi.md lib/smspool.rb lib/smspool/api/business_api.rb lib/smspool/api/carrier_api.rb -lib/smspool/api/esims_api.rb lib/smspool/api/information_api.rb lib/smspool/api/preorders_api.rb lib/smspool/api/pricing_api.rb lib/smspool/api/rental_api.rb lib/smspool/api/sms_api.rb +lib/smspool/api/status_api.rb lib/smspool/api/voucher_api.rb lib/smspool/api_client.rb lib/smspool/api_error.rb diff --git a/docs/BusinessApi.md b/docs/BusinessApi.md index d66cf04..308a6a4 100644 --- a/docs/BusinessApi.md +++ b/docs/BusinessApi.md @@ -156,6 +156,8 @@ end 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. + ### Examples ```ruby diff --git a/docs/CarrierApi.md b/docs/CarrierApi.md index 3d3e3ce..2d2980e 100644 --- a/docs/CarrierApi.md +++ b/docs/CarrierApi.md @@ -13,7 +13,7 @@ All URIs are relative to *https://api.smspool.net* 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. ### Examples diff --git a/docs/ESIMsApi.md b/docs/ESIMsApi.md deleted file mode 100644 index 4cb7140..0000000 --- a/docs/ESIMsApi.md +++ /dev/null @@ -1,636 +0,0 @@ -# SMSPool::ESIMsApi - -All URIs are relative to *https://api.smspool.net* - -| Method | HTTP request | Description | -| ------ | ------------ | ----------- | -| [**esim_delete**](ESIMsApi.md#esim_delete) | **POST** /esim/delete | Delete eSIM | -| [**esim_history**](ESIMsApi.md#esim_history) | **POST** /esim/history | View eSIM history | -| [**esim_label_update**](ESIMsApi.md#esim_label_update) | **POST** /esim/label/update | Update eSIM label | -| [**esim_plans**](ESIMsApi.md#esim_plans) | **POST** /esim/plans | View eSIM plans per country | -| [**esim_pricing**](ESIMsApi.md#esim_pricing) | **POST** /esim/pricing | View eSIM countries | -| [**esim_profile**](ESIMsApi.md#esim_profile) | **POST** /esim/profile | View eSIM profile | -| [**esim_purchase**](ESIMsApi.md#esim_purchase) | **POST** /esim/purchase | Purchase eSIM | -| [**esim_topup**](ESIMsApi.md#esim_topup) | **POST** /esim/topup | Top up eSIM | -| [**esim_topup_plans**](ESIMsApi.md#esim_topup_plans) | **POST** /esim/topup_plans | Top Up Plans | - - -## esim_delete - -> Object esim_delete(transaction_id) - -Delete eSIM - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -transaction_id = 'transaction_id_example' # String | transactionId retrieved from /esim/purchase - -begin - # Delete eSIM - result = api_instance.esim_delete(transaction_id) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_delete: #{e}" -end -``` - -#### Using the esim_delete_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_delete_with_http_info(transaction_id) - -```ruby -begin - # Delete eSIM - data, status_code, headers = api_instance.esim_delete_with_http_info(transaction_id) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_delete_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **transaction_id** | **String** | transactionId retrieved from /esim/purchase | | - -### Return type - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_history - -> Object esim_history(opts) - -View eSIM history - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -opts = { - start: 56, # Integer | Start page - length: 56, # Integer | Amount of rows per page - search: 'search_example' # String | Alphanumeric search -} - -begin - # View eSIM history - result = api_instance.esim_history(opts) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_history: #{e}" -end -``` - -#### Using the esim_history_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_history_with_http_info(opts) - -```ruby -begin - # View eSIM history - data, status_code, headers = api_instance.esim_history_with_http_info(opts) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_history_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **start** | **Integer** | Start page | [optional] | -| **length** | **Integer** | Amount of rows per page | [optional] | -| **search** | **String** | Alphanumeric search | [optional] | - -### Return type - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_label_update - -> Object esim_label_update(transaction_id, opts) - -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. - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -transaction_id = 'transaction_id_example' # String | transactionId retrieved from /esim/purchase -opts = { - label: 'label_example' # String | The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. -} - -begin - # Update eSIM label - result = api_instance.esim_label_update(transaction_id, opts) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_label_update: #{e}" -end -``` - -#### Using the esim_label_update_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_label_update_with_http_info(transaction_id, opts) - -```ruby -begin - # Update eSIM label - data, status_code, headers = api_instance.esim_label_update_with_http_info(transaction_id, opts) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_label_update_with_http_info: #{e}" -end -``` - -### 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 - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_plans - -> Object esim_plans(country) - -View eSIM plans per country - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -country = 'country_example' # String | ISO 3166 country code - -begin - # View eSIM plans per country - result = api_instance.esim_plans(country) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_plans: #{e}" -end -``` - -#### Using the esim_plans_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_plans_with_http_info(country) - -```ruby -begin - # View eSIM plans per country - data, status_code, headers = api_instance.esim_plans_with_http_info(country) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_plans_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **country** | **String** | ISO 3166 country code | | - -### Return type - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_pricing - -> Object esim_pricing(opts) - -View eSIM countries - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -opts = { - start: 56, # Integer | Start page - length: 56, # Integer | Amount of rows per page - search: 'search_example' # String | Search query for country -} - -begin - # View eSIM countries - result = api_instance.esim_pricing(opts) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_pricing: #{e}" -end -``` - -#### Using the esim_pricing_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_pricing_with_http_info(opts) - -```ruby -begin - # View eSIM countries - data, status_code, headers = api_instance.esim_pricing_with_http_info(opts) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_pricing_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **start** | **Integer** | Start page | [optional] | -| **length** | **Integer** | Amount of rows per page | [optional] | -| **search** | **String** | Search query for country | [optional] | - -### Return type - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_profile - -> Object esim_profile(opts) - -View eSIM profile - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -opts = { - transaction_id: 'transaction_id_example' # String | transactionId retrieved from /esim/purchase -} - -begin - # View eSIM profile - result = api_instance.esim_profile(opts) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_profile: #{e}" -end -``` - -#### Using the esim_profile_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_profile_with_http_info(opts) - -```ruby -begin - # View eSIM profile - data, status_code, headers = api_instance.esim_profile_with_http_info(opts) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_profile_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **transaction_id** | **String** | transactionId retrieved from /esim/purchase | [optional] | - -### Return type - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_purchase - -> Object esim_purchase(plan) - -Purchase eSIM - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -plan = 56 # Integer | The plan ID which is obtained from /esim/pricing - -begin - # Purchase eSIM - result = api_instance.esim_purchase(plan) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_purchase: #{e}" -end -``` - -#### Using the esim_purchase_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_purchase_with_http_info(plan) - -```ruby -begin - # Purchase eSIM - data, status_code, headers = api_instance.esim_purchase_with_http_info(plan) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_purchase_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **plan** | **Integer** | The plan ID which is obtained from /esim/pricing | | - -### Return type - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_topup - -> Object esim_topup(transaction_id, plan) - -Top up eSIM - -### Examples - -```ruby -require 'time' -require 'smspool' -# setup authorization -SMSPool.configure do |config| - # Configure Bearer authorization: bearerAuth - config.access_token = 'YOUR_BEARER_TOKEN' -end - -api_instance = SMSPool::ESIMsApi.new -transaction_id = 'transaction_id_example' # String | Transaction ID retrieved from eSIM history -plan = 56 # Integer | Topup plan retrieved from \\\"Top Up Plans\\\" - -begin - # Top up eSIM - result = api_instance.esim_topup(transaction_id, plan) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_topup: #{e}" -end -``` - -#### Using the esim_topup_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_topup_with_http_info(transaction_id, plan) - -```ruby -begin - # Top up eSIM - data, status_code, headers = api_instance.esim_topup_with_http_info(transaction_id, plan) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_topup_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **transaction_id** | **String** | Transaction ID retrieved from eSIM history | | -| **plan** | **Integer** | Topup plan retrieved from \\\"Top Up Plans\\\" | | - -### Return type - -**Object** - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - - -## esim_topup_plans - -> Object esim_topup_plans(plan) - -Top Up Plans - -### Examples - -```ruby -require 'time' -require 'smspool' - -api_instance = SMSPool::ESIMsApi.new -plan = 56 # Integer | `plan` retrieved from eSIM history - -begin - # Top Up Plans - result = api_instance.esim_topup_plans(plan) - p result -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_topup_plans: #{e}" -end -``` - -#### Using the esim_topup_plans_with_http_info variant - -This returns an Array which contains the response data, status code and headers. - -> esim_topup_plans_with_http_info(plan) - -```ruby -begin - # Top Up Plans - data, status_code, headers = api_instance.esim_topup_plans_with_http_info(plan) - p status_code # => 2xx - p headers # => { ... } - p data # => Object -rescue SMSPool::ApiError => e - puts "Error when calling ESIMsApi->esim_topup_plans_with_http_info: #{e}" -end -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | -| **plan** | **Integer** | `plan` retrieved from eSIM history | | - -### Return type - -**Object** - -### Authorization - -No authorization required - -### HTTP request headers - -- **Content-Type**: application/x-www-form-urlencoded -- **Accept**: application/json - diff --git a/docs/InformationApi.md b/docs/InformationApi.md index fda394d..c811c8b 100644 --- a/docs/InformationApi.md +++ b/docs/InformationApi.md @@ -7,6 +7,7 @@ All URIs are relative to *https://api.smspool.net* | [**country_retrieve_all**](InformationApi.md#country_retrieve_all) | **GET** /country/retrieve_all | Country list | | [**pool_retrieve_all**](InformationApi.md#pool_retrieve_all) | **POST** /pool/retrieve_all | Pool list | | [**pool_retrieve_valid**](InformationApi.md#pool_retrieve_valid) | **POST** /pool/retrieve_valid | Suggested Pools | +| [**request_auto_country**](InformationApi.md#request_auto_country) | **POST** /request/auto_country | Pick the best country for a service | | [**request_balance**](InformationApi.md#request_balance) | **POST** /request/balance | Balance | | [**request_success_rate**](InformationApi.md#request_success_rate) | **POST** /request/success_rate | Retrieve country success rates per service | | [**request_suggested_countries**](InformationApi.md#request_suggested_countries) | **POST** /request/suggested_countries | Suggested Countries | @@ -212,13 +213,81 @@ No authorization required - **Accept**: application/json +## request_auto_country + +> Object request_auto_country(service, opts) + +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. + +### Examples + +```ruby +require 'time' +require 'smspool' + +api_instance = SMSPool::InformationApi.new +service = 'service_example' # String | Service name or service ID which can be retrieved at the /service/retrieve_all endpoint +opts = { + pricing_option: 56 # Integer | Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. +} + +begin + # Pick the best country for a service + result = api_instance.request_auto_country(service, opts) + p result +rescue SMSPool::ApiError => e + puts "Error when calling InformationApi->request_auto_country: #{e}" +end +``` + +#### Using the request_auto_country_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> request_auto_country_with_http_info(service, opts) + +```ruby +begin + # Pick the best country for a service + data, status_code, headers = api_instance.request_auto_country_with_http_info(service, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => Object +rescue SMSPool::ApiError => e + puts "Error when calling InformationApi->request_auto_country_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **service** | **String** | Service name or service ID which can be retrieved at the /service/retrieve_all endpoint | | +| **pricing_option** | **Integer** | 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 + +**Object** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: application/json + + ## request_balance > Object request_balance 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\"`. ### Examples diff --git a/docs/PricingApi.md b/docs/PricingApi.md index ea1f2bb..038bcea 100644 --- a/docs/PricingApi.md +++ b/docs/PricingApi.md @@ -84,6 +84,8 @@ No authorization required 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. + ### Examples ```ruby diff --git a/docs/RentalApi.md b/docs/RentalApi.md index 553eff7..3e6d2d9 100644 --- a/docs/RentalApi.md +++ b/docs/RentalApi.md @@ -43,6 +43,7 @@ api_instance = SMSPool::RentalApi.new id = 56 # Integer | Rental ID retrieved from Retrieve Rental IDs days = 56 # Integer | opts = { + idempotency_key: '3f1c2c0e-7d5b-4a52-9a53-1f6f0f0f2b11', # String | service_id: 56, # Integer | Optional value on which service you'd purchase the rental for create_token: 56, # Integer | Create a rental token which allows you to share this specific rental city: 'city_example', # String | @@ -83,6 +84,7 @@ end | ---- | ---- | ----------- | ----- | | **id** | **Integer** | Rental ID retrieved from Retrieve Rental IDs | | | **days** | **Integer** | | | +| **idempotency_key** | **String** | | [optional] | | **service_id** | **Integer** | Optional value on which service you'd purchase the rental for | [optional] | | **create_token** | **Integer** | Create a rental token which allows you to share this specific rental | [optional] | | **city** | **String** | | [optional] | @@ -710,6 +712,8 @@ This endpoint does not need any parameter. Retrieve Rental Messages +Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. + ### Examples ```ruby @@ -907,6 +911,8 @@ No authorization required Retrieve Rental Status +Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. + ### Examples ```ruby @@ -1050,6 +1056,11 @@ Retrieve Rental Stock ```ruby require 'time' require 'smspool' +# setup authorization +SMSPool.configure do |config| + # Configure Bearer authorization: bearerAuth + config.access_token = 'YOUR_BEARER_TOKEN' +end api_instance = SMSPool::RentalApi.new id = 56 # Integer | The rental ID retrieved from `Retrieve Rental IDs` @@ -1099,7 +1110,7 @@ end ### Authorization -No authorization required +[bearerAuth](../README.md#bearerAuth) ### HTTP request headers diff --git a/docs/SMSApi.md b/docs/SMSApi.md index 16698c6..357b6ed 100644 --- a/docs/SMSApi.md +++ b/docs/SMSApi.md @@ -9,8 +9,10 @@ All URIs are relative to *https://api.smspool.net* | [**request_archive**](SMSApi.md#request_archive) | **POST** /request/archive | Archive all orders | | [**request_areacodes**](SMSApi.md#request_areacodes) | **POST** /request/areacodes | Request available areacodes | | [**request_history**](SMSApi.md#request_history) | **POST** /request/history | Order History | +| [**request_history_search**](SMSApi.md#request_history_search) | **POST** /request/history_search | Search order history | | [**sms_activate**](SMSApi.md#sms_activate) | **POST** /sms/activate | Activate SMS | | [**sms_all_stock**](SMSApi.md#sms_all_stock) | **POST** /sms/all_stock | One-time stock for all services | +| [**sms_archive**](SMSApi.md#sms_archive) | **POST** /sms/archive | Archive one order | | [**sms_cancel**](SMSApi.md#sms_cancel) | **POST** /sms/cancel | Cancel SMS | | [**sms_cancel_all**](SMSApi.md#sms_cancel_all) | **POST** /sms/cancel_all | Cancel All SMS | | [**sms_check**](SMSApi.md#sms_check) | **POST** /sms/check | Check SMS | @@ -29,6 +31,8 @@ All URIs are relative to *https://api.smspool.net* 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. + ### Examples ```ruby @@ -43,17 +47,20 @@ end api_instance = SMSPool::SMSApi.new service = 'service_example' # String | The service or number retrieved from the `Service List` endpoint opts = { + 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: 8.14, # Float | The max price you are willing to pay per number pricing_option: 56, # Integer | Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate - quantity: 56, # Integer | Quantity of numbers ordered + quantity: 56, # Integer | 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, # Integer | Set exclude to 1 if you would like to exclude all listed area codes. create_token: 56, # Integer | 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, # Integer | Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) - phonenumber: 56, # Integer | In case you want to select a specific phone number to order + phonenumber: 56, # Integer | 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, # Integer | 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 # Integer | } @@ -89,17 +96,20 @@ end | 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** | **Integer** | Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate | [optional] | -| **quantity** | **Integer** | Quantity of numbers ordered | [optional] | +| **quantity** | **Integer** | 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** | **Integer** | Set exclude to 1 if you would like to exclude all listed area codes. | [optional] | | **create_token** | **Integer** | 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** | **Integer** | Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) | [optional] | -| **phonenumber** | **Integer** | In case you want to select a specific phone number to order | [optional] | +| **phonenumber** | **Integer** | 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** | **Integer** | 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** | **Integer** | | [optional] | ### Return type @@ -259,6 +269,11 @@ Request available areacodes ```ruby require 'time' require 'smspool' +# setup authorization +SMSPool.configure do |config| + # Configure Bearer authorization: bearerAuth + config.access_token = 'YOUR_BEARER_TOKEN' +end api_instance = SMSPool::SMSApi.new service = 'service_example' # String | The service or number retrieved from the `Service List` endpoint @@ -306,7 +321,7 @@ end ### Authorization -No authorization required +[bearerAuth](../README.md#bearerAuth) ### HTTP request headers @@ -389,6 +404,81 @@ end - **Accept**: application/json +## request_history_search + +> Object request_history_search(search, opts) + +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`. + +### Examples + +```ruby +require 'time' +require 'smspool' +# setup authorization +SMSPool.configure do |config| + # Configure Bearer authorization: bearerAuth + config.access_token = 'YOUR_BEARER_TOKEN' +end + +api_instance = SMSPool::SMSApi.new +search = 'search_example' # String | The search term, as typed into the order history's search box. At most 32 characters. +opts = { + cursor: 'cursor_example', # String | `next` from the previous call. Leave out for the first call. + limit: 56 # Integer | Matches per call, 1 to 500 (default 100). +} + +begin + # Search order history + result = api_instance.request_history_search(search, opts) + p result +rescue SMSPool::ApiError => e + puts "Error when calling SMSApi->request_history_search: #{e}" +end +``` + +#### Using the request_history_search_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> request_history_search_with_http_info(search, opts) + +```ruby +begin + # Search order history + data, status_code, headers = api_instance.request_history_search_with_http_info(search, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => Object +rescue SMSPool::ApiError => e + puts "Error when calling SMSApi->request_history_search_with_http_info: #{e}" +end +``` + +### 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** | **Integer** | Matches per call, 1 to 500 (default 100). | [optional] | + +### Return type + +**Object** + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: application/json + + ## sms_activate > Object sms_activate(orderid) @@ -464,7 +554,7 @@ end 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. ### Examples @@ -528,13 +618,82 @@ No authorization required - **Accept**: application/json +## sms_archive + +> Object sms_archive(orderid) + +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. + +### Examples + +```ruby +require 'time' +require 'smspool' +# setup authorization +SMSPool.configure do |config| + # Configure Bearer authorization: bearerAuth + config.access_token = 'YOUR_BEARER_TOKEN' +end + +api_instance = SMSPool::SMSApi.new +orderid = 'orderid_example' # String | The order code from the `Order SMS` endpoint. + +begin + # Archive one order + result = api_instance.sms_archive(orderid) + p result +rescue SMSPool::ApiError => e + puts "Error when calling SMSApi->sms_archive: #{e}" +end +``` + +#### Using the sms_archive_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> sms_archive_with_http_info(orderid) + +```ruby +begin + # Archive one order + data, status_code, headers = api_instance.sms_archive_with_http_info(orderid) + p status_code # => 2xx + p headers # => { ... } + p data # => Object +rescue SMSPool::ApiError => e + puts "Error when calling SMSApi->sms_archive_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **orderid** | **String** | The order code from the `Order SMS` endpoint. | | + +### Return type + +**Object** + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: application/json + + ## sms_cancel > Object sms_cancel(opts) 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`. ### Examples @@ -881,7 +1040,7 @@ This endpoint does not need any parameter. 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. ### Examples @@ -1092,7 +1251,7 @@ end 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. ### Examples diff --git a/docs/StatusApi.md b/docs/StatusApi.md new file mode 100644 index 0000000..a07cda7 --- /dev/null +++ b/docs/StatusApi.md @@ -0,0 +1,69 @@ +# SMSPool::StatusApi + +All URIs are relative to *https://api.smspool.net* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**up**](StatusApi.md#up) | **GET** /up | Health check | + + +## up + +> Object up + +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. + +### Examples + +```ruby +require 'time' +require 'smspool' + +api_instance = SMSPool::StatusApi.new + +begin + # Health check + result = api_instance.up + p result +rescue SMSPool::ApiError => e + puts "Error when calling StatusApi->up: #{e}" +end +``` + +#### Using the up_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> up_with_http_info + +```ruby +begin + # Health check + data, status_code, headers = api_instance.up_with_http_info + p status_code # => 2xx + p headers # => { ... } + p data # => Object +rescue SMSPool::ApiError => e + puts "Error when calling StatusApi->up_with_http_info: #{e}" +end +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**Object** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/VoucherApi.md b/docs/VoucherApi.md index 0de31b5..57dd9ab 100644 --- a/docs/VoucherApi.md +++ b/docs/VoucherApi.md @@ -148,7 +148,7 @@ end ## voucher_generate -> Object voucher_generate(amount) +> Object voucher_generate(amount, opts) Generate voucher @@ -165,10 +165,13 @@ end api_instance = SMSPool::VoucherApi.new amount = 8.14 # Float | The amount per promocode +opts = { + idempotency_key: '3f1c2c0e-7d5b-4a52-9a53-1f6f0f0f2b11' # String | +} begin # Generate voucher - result = api_instance.voucher_generate(amount) + result = api_instance.voucher_generate(amount, opts) p result rescue SMSPool::ApiError => e puts "Error when calling VoucherApi->voucher_generate: #{e}" @@ -179,12 +182,12 @@ end This returns an Array which contains the response data, status code and headers. -> voucher_generate_with_http_info(amount) +> voucher_generate_with_http_info(amount, opts) ```ruby begin # Generate voucher - data, status_code, headers = api_instance.voucher_generate_with_http_info(amount) + data, status_code, headers = api_instance.voucher_generate_with_http_info(amount, opts) p status_code # => 2xx p headers # => { ... } p data # => Object @@ -198,6 +201,7 @@ end | Name | Type | Description | Notes | | ---- | ---- | ----------- | ----- | | **amount** | **Float** | The amount per promocode | | +| **idempotency_key** | **String** | | [optional] | ### Return type diff --git a/lib/smspool.rb b/lib/smspool.rb index f910c85..8466b1d 100644 --- a/lib/smspool.rb +++ b/lib/smspool.rb @@ -1,7 +1,7 @@ =begin #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 @@ -22,12 +22,12 @@ # APIs require 'smspool/api/business_api' require 'smspool/api/carrier_api' -require 'smspool/api/esims_api' require 'smspool/api/information_api' require 'smspool/api/preorders_api' require 'smspool/api/pricing_api' require 'smspool/api/rental_api' require 'smspool/api/sms_api' +require 'smspool/api/status_api' require 'smspool/api/voucher_api' module SMSPool diff --git a/lib/smspool/api/business_api.rb b/lib/smspool/api/business_api.rb index bc92dca..5387c1c 100644 --- a/lib/smspool/api/business_api.rb +++ b/lib/smspool/api/business_api.rb @@ -1,7 +1,7 @@ =begin #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 @@ -164,6 +164,7 @@ def business_user_history_with_http_info(id, opts = {}) end # 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. # @param id [Integer] User ID retrievd from `Retrieve users` endpoint # @param [Hash] opts the optional parameters # @option opts [String] :password Leave empty if you do not wish to update the password @@ -177,6 +178,7 @@ def business_user_update(id, opts = {}) end # 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. # @param id [Integer] User ID retrievd from `Retrieve users` endpoint # @param [Hash] opts the optional parameters # @option opts [String] :password Leave empty if you do not wish to update the password diff --git a/lib/smspool/api/carrier_api.rb b/lib/smspool/api/carrier_api.rb index 65dc1fc..dca1caf 100644 --- a/lib/smspool/api/carrier_api.rb +++ b/lib/smspool/api/carrier_api.rb @@ -1,7 +1,7 @@ =begin #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 @@ -20,7 +20,7 @@ def initialize(api_client = ApiClient.default) @api_client = api_client end # 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. # @param phonenumber [Integer] # @param [Hash] opts the optional parameters # @return [Object] @@ -30,7 +30,7 @@ def carrier_paid_lookup(phonenumber, opts = {}) end # 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. # @param phonenumber [Integer] # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers diff --git a/lib/smspool/api/esims_api.rb b/lib/smspool/api/esims_api.rb deleted file mode 100644 index 74691d0..0000000 --- a/lib/smspool/api/esims_api.rb +++ /dev/null @@ -1,637 +0,0 @@ -=begin -#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. - -The version of the OpenAPI document: 1.0 - -Generated by: https://openapi-generator.tech -Generator version: 7.25.0 - -=end - -require 'cgi' - -module SMSPool - class ESIMsApi - attr_accessor :api_client - - def initialize(api_client = ApiClient.default) - @api_client = api_client - end - # Delete eSIM - # @param transaction_id [String] transactionId retrieved from /esim/purchase - # @param [Hash] opts the optional parameters - # @return [Object] - def esim_delete(transaction_id, opts = {}) - data, _status_code, _headers = esim_delete_with_http_info(transaction_id, opts) - data - end - - # Delete eSIM - # @param transaction_id [String] transactionId retrieved from /esim/purchase - # @param [Hash] opts the optional parameters - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_delete_with_http_info(transaction_id, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_delete ...' - end - # verify the required parameter 'transaction_id' is set - if @api_client.config.client_side_validation && transaction_id.nil? - fail ArgumentError, "Missing the required parameter 'transaction_id' when calling ESIMsApi.esim_delete" - end - # resource path - local_var_path = '/esim/delete' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['transactionId'] = transaction_id - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_delete", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # View eSIM history - # @param [Hash] opts the optional parameters - # @option opts [Integer] :start Start page - # @option opts [Integer] :length Amount of rows per page - # @option opts [String] :search Alphanumeric search - # @return [Object] - def esim_history(opts = {}) - data, _status_code, _headers = esim_history_with_http_info(opts) - data - end - - # View eSIM history - # @param [Hash] opts the optional parameters - # @option opts [Integer] :start Start page - # @option opts [Integer] :length Amount of rows per page - # @option opts [String] :search Alphanumeric search - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_history_with_http_info(opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_history ...' - end - # resource path - local_var_path = '/esim/history' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['start'] = opts[:'start'] if !opts[:'start'].nil? - form_params['length'] = opts[:'length'] if !opts[:'length'].nil? - form_params['search'] = opts[:'search'] if !opts[:'search'].nil? - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_history", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # 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. - # @param transaction_id [String] transactionId retrieved from /esim/purchase - # @param [Hash] opts the optional parameters - # @option opts [String] :label The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. - # @return [Object] - def esim_label_update(transaction_id, opts = {}) - data, _status_code, _headers = esim_label_update_with_http_info(transaction_id, opts) - data - end - - # 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. - # @param transaction_id [String] transactionId retrieved from /esim/purchase - # @param [Hash] opts the optional parameters - # @option opts [String] :label The new label: letters, numbers and spaces, at most 30 characters. Empty or left out removes the label. - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_label_update_with_http_info(transaction_id, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_label_update ...' - end - # verify the required parameter 'transaction_id' is set - if @api_client.config.client_side_validation && transaction_id.nil? - fail ArgumentError, "Missing the required parameter 'transaction_id' when calling ESIMsApi.esim_label_update" - end - # resource path - local_var_path = '/esim/label/update' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['transactionId'] = transaction_id - form_params['label'] = opts[:'label'] if !opts[:'label'].nil? - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_label_update", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_label_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # View eSIM plans per country - # @param country [String] ISO 3166 country code - # @param [Hash] opts the optional parameters - # @return [Object] - def esim_plans(country, opts = {}) - data, _status_code, _headers = esim_plans_with_http_info(country, opts) - data - end - - # View eSIM plans per country - # @param country [String] ISO 3166 country code - # @param [Hash] opts the optional parameters - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_plans_with_http_info(country, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_plans ...' - end - # verify the required parameter 'country' is set - if @api_client.config.client_side_validation && country.nil? - fail ArgumentError, "Missing the required parameter 'country' when calling ESIMsApi.esim_plans" - end - # resource path - local_var_path = '/esim/plans' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['country'] = country - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_plans", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_plans\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # View eSIM countries - # @param [Hash] opts the optional parameters - # @option opts [Integer] :start Start page - # @option opts [Integer] :length Amount of rows per page - # @option opts [String] :search Search query for country - # @return [Object] - def esim_pricing(opts = {}) - data, _status_code, _headers = esim_pricing_with_http_info(opts) - data - end - - # View eSIM countries - # @param [Hash] opts the optional parameters - # @option opts [Integer] :start Start page - # @option opts [Integer] :length Amount of rows per page - # @option opts [String] :search Search query for country - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_pricing_with_http_info(opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_pricing ...' - end - # resource path - local_var_path = '/esim/pricing' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['start'] = opts[:'start'] if !opts[:'start'].nil? - form_params['length'] = opts[:'length'] if !opts[:'length'].nil? - form_params['search'] = opts[:'search'] if !opts[:'search'].nil? - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_pricing", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_pricing\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # View eSIM profile - # @param [Hash] opts the optional parameters - # @option opts [String] :transaction_id transactionId retrieved from /esim/purchase - # @return [Object] - def esim_profile(opts = {}) - data, _status_code, _headers = esim_profile_with_http_info(opts) - data - end - - # View eSIM profile - # @param [Hash] opts the optional parameters - # @option opts [String] :transaction_id transactionId retrieved from /esim/purchase - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_profile_with_http_info(opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_profile ...' - end - # resource path - local_var_path = '/esim/profile' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['transactionId'] = opts[:'transaction_id'] if !opts[:'transaction_id'].nil? - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_profile", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Purchase eSIM - # @param plan [Integer] The plan ID which is obtained from /esim/pricing - # @param [Hash] opts the optional parameters - # @return [Object] - def esim_purchase(plan, opts = {}) - data, _status_code, _headers = esim_purchase_with_http_info(plan, opts) - data - end - - # Purchase eSIM - # @param plan [Integer] The plan ID which is obtained from /esim/pricing - # @param [Hash] opts the optional parameters - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_purchase_with_http_info(plan, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_purchase ...' - end - # verify the required parameter 'plan' is set - if @api_client.config.client_side_validation && plan.nil? - fail ArgumentError, "Missing the required parameter 'plan' when calling ESIMsApi.esim_purchase" - end - # resource path - local_var_path = '/esim/purchase' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['plan'] = plan - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_purchase", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_purchase\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Top up eSIM - # @param transaction_id [String] Transaction ID retrieved from eSIM history - # @param plan [Integer] Topup plan retrieved from \\\"Top Up Plans\\\" - # @param [Hash] opts the optional parameters - # @return [Object] - def esim_topup(transaction_id, plan, opts = {}) - data, _status_code, _headers = esim_topup_with_http_info(transaction_id, plan, opts) - data - end - - # Top up eSIM - # @param transaction_id [String] Transaction ID retrieved from eSIM history - # @param plan [Integer] Topup plan retrieved from \\\"Top Up Plans\\\" - # @param [Hash] opts the optional parameters - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_topup_with_http_info(transaction_id, plan, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_topup ...' - end - # verify the required parameter 'transaction_id' is set - if @api_client.config.client_side_validation && transaction_id.nil? - fail ArgumentError, "Missing the required parameter 'transaction_id' when calling ESIMsApi.esim_topup" - end - # verify the required parameter 'plan' is set - if @api_client.config.client_side_validation && plan.nil? - fail ArgumentError, "Missing the required parameter 'plan' when calling ESIMsApi.esim_topup" - end - # resource path - local_var_path = '/esim/topup' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['transactionId'] = transaction_id - form_params['plan'] = plan - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearerAuth'] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_topup", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_topup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Top Up Plans - # @param plan [Integer] `plan` retrieved from eSIM history - # @param [Hash] opts the optional parameters - # @return [Object] - def esim_topup_plans(plan, opts = {}) - data, _status_code, _headers = esim_topup_plans_with_http_info(plan, opts) - data - end - - # Top Up Plans - # @param plan [Integer] `plan` retrieved from eSIM history - # @param [Hash] opts the optional parameters - # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers - def esim_topup_plans_with_http_info(plan, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ESIMsApi.esim_topup_plans ...' - end - # verify the required parameter 'plan' is set - if @api_client.config.client_side_validation && plan.nil? - fail ArgumentError, "Missing the required parameter 'plan' when calling ESIMsApi.esim_topup_plans" - end - # resource path - local_var_path = '/esim/topup_plans' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - # HTTP header 'Content-Type' - content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) - if !content_type.nil? - header_params['Content-Type'] = content_type - end - - # form parameters - form_params = opts[:form_params] || {} - form_params['plan'] = plan - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'Object' - - # auth_names - auth_names = opts[:debug_auth_names] || [] - - new_options = opts.merge( - :operation => :"ESIMsApi.esim_topup_plans", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ESIMsApi#esim_topup_plans\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - end -end diff --git a/lib/smspool/api/information_api.rb b/lib/smspool/api/information_api.rb index f2ba66e..0141546 100644 --- a/lib/smspool/api/information_api.rb +++ b/lib/smspool/api/information_api.rb @@ -1,7 +1,7 @@ =begin #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 @@ -218,8 +218,80 @@ def pool_retrieve_valid_with_http_info(service, country, opts = {}) return data, status_code, headers end + # 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. + # @param service [String] Service name or service ID which can be retrieved at the /service/retrieve_all endpoint + # @param [Hash] opts the optional parameters + # @option opts [Integer] :pricing_option Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. + # @return [Object] + def request_auto_country(service, opts = {}) + data, _status_code, _headers = request_auto_country_with_http_info(service, opts) + data + end + + # 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. + # @param service [String] Service name or service ID which can be retrieved at the /service/retrieve_all endpoint + # @param [Hash] opts the optional parameters + # @option opts [Integer] :pricing_option Set to 1 to prefer the cheapest country among those close to the best score; 0 (default) picks purely on the score. + # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers + def request_auto_country_with_http_info(service, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: InformationApi.request_auto_country ...' + end + # verify the required parameter 'service' is set + if @api_client.config.client_side_validation && service.nil? + fail ArgumentError, "Missing the required parameter 'service' when calling InformationApi.request_auto_country" + end + # resource path + local_var_path = '/request/auto_country' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['service'] = service + form_params['pricing_option'] = opts[:'pricing_option'] if !opts[:'pricing_option'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Object' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"InformationApi.request_auto_country", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: InformationApi#request_auto_country\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # 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\"`. # @param [Hash] opts the optional parameters # @return [Object] def request_balance(opts = {}) @@ -228,7 +300,7 @@ def request_balance(opts = {}) end # 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\"`. # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def request_balance_with_http_info(opts = {}) diff --git a/lib/smspool/api/preorders_api.rb b/lib/smspool/api/preorders_api.rb index b308913..13de1a7 100644 --- a/lib/smspool/api/preorders_api.rb +++ b/lib/smspool/api/preorders_api.rb @@ -1,7 +1,7 @@ =begin #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 diff --git a/lib/smspool/api/pricing_api.rb b/lib/smspool/api/pricing_api.rb index 1a0b819..0091076 100644 --- a/lib/smspool/api/pricing_api.rb +++ b/lib/smspool/api/pricing_api.rb @@ -1,7 +1,7 @@ =begin #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 @@ -100,6 +100,7 @@ def request_price_with_http_info(country, service, opts = {}) end # 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. # @param [Hash] opts the optional parameters # @option opts [String] :country Optional parameter to request services per country # @option opts [String] :service Service name or service ID which can be retrieved at the /service/retrieve_all endpoint @@ -112,6 +113,7 @@ def request_pricing(opts = {}) end # 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. # @param [Hash] opts the optional parameters # @option opts [String] :country Optional parameter to request services per country # @option opts [String] :service Service name or service ID which can be retrieved at the /service/retrieve_all endpoint diff --git a/lib/smspool/api/rental_api.rb b/lib/smspool/api/rental_api.rb index be0c324..bc5f037 100644 --- a/lib/smspool/api/rental_api.rb +++ b/lib/smspool/api/rental_api.rb @@ -1,7 +1,7 @@ =begin #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 @@ -23,6 +23,7 @@ def initialize(api_client = ApiClient.default) # @param id [Integer] Rental ID retrieved from Retrieve Rental IDs # @param days [Integer] # @param [Hash] opts the optional parameters + # @option opts [String] :idempotency_key # @option opts [Integer] :service_id Optional value on which service you'd purchase the rental for # @option opts [Integer] :create_token Create a rental token which allows you to share this specific rental # @option opts [String] :city @@ -38,6 +39,7 @@ def purchase_rental(id, days, opts = {}) # @param id [Integer] Rental ID retrieved from Retrieve Rental IDs # @param days [Integer] # @param [Hash] opts the optional parameters + # @option opts [String] :idempotency_key # @option opts [Integer] :service_id Optional value on which service you'd purchase the rental for # @option opts [Integer] :create_token Create a rental token which allows you to share this specific rental # @option opts [String] :city @@ -71,6 +73,7 @@ def purchase_rental_with_http_info(id, days, opts = {}) if !content_type.nil? header_params['Content-Type'] = content_type end + header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil? # form parameters form_params = opts[:form_params] || {} @@ -693,6 +696,7 @@ def rental_retrieve_history_with_http_info(opts = {}) end # Retrieve Rental Messages + # Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. # @param rental_code [String] The retrieved rental code from the `Order rental` endpoint. # @param [Hash] opts the optional parameters # @return [Object] @@ -702,6 +706,7 @@ def rental_retrieve_messages(rental_code, opts = {}) end # Retrieve Rental Messages + # Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. # @param rental_code [String] The retrieved rental code from the `Order rental` endpoint. # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers @@ -893,6 +898,7 @@ def rental_retrieve_services_with_http_info(opts = {}) end # Retrieve Rental Status + # Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. # @param rental_code [String] The retrieved rental code from the `Order rental` endpoint. # @param [Hash] opts the optional parameters # @return [Object] @@ -902,6 +908,7 @@ def rental_retrieve_status(rental_code, opts = {}) end # Retrieve Rental Status + # Successful answers are cached for 3 seconds per rental, so polling faster than that returns the same data. # @param rental_code [String] The retrieved rental code from the `Order rental` endpoint. # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers @@ -1093,7 +1100,7 @@ def rental_stock_with_http_info(id, days, opts = {}) return_type = opts[:debug_return_type] || 'Object' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['bearerAuth'] new_options = opts.merge( :operation => :"RentalApi.rental_stock", diff --git a/lib/smspool/api/sms_api.rb b/lib/smspool/api/sms_api.rb index 50ef153..a0d7152 100644 --- a/lib/smspool/api/sms_api.rb +++ b/lib/smspool/api/sms_api.rb @@ -1,7 +1,7 @@ =begin #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 @@ -20,19 +20,23 @@ def initialize(api_client = ApiClient.default) @api_client = api_client end # 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. # @param service [String] The service or number retrieved from the `Service List` endpoint # @param [Hash] opts the optional parameters + # @option opts [String] :idempotency_key # @option opts [String] :country The country in ISO format or number retrieved from the `Country List` endpoint - # @option opts [String] :pool The pool or number retrieved from the `Pool List` endpoint (optional) + # @option opts [String] :pool The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. # @option opts [Float] :max_price The max price you are willing to pay per number # @option opts [Integer] :pricing_option Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate - # @option opts [Integer] :quantity Quantity of numbers ordered + # @option opts [Integer] :quantity Quantity of numbers ordered, 1 to 20. Must be a whole number. # @option opts [String] :areacode Areacodes you would like to include or exclude in JSON format # @option opts [Integer] :exclude Set exclude to 1 if you would like to exclude all listed area codes. # @option opts [Integer] :create_token Optional param; set to 1 if you'd like to create a token link that anyone can access. # @option opts [String] :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. # @option opts [Integer] :carrier Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) - # @option opts [Integer] :phonenumber In case you want to select a specific phone number to order + # @option opts [Integer] :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. + # @option opts [Integer] :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. + # @option opts [String] :response Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. # @option opts [Integer] :software # @return [Object] def purchase_sms(service, opts = {}) @@ -41,19 +45,23 @@ def purchase_sms(service, opts = {}) end # 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. # @param service [String] The service or number retrieved from the `Service List` endpoint # @param [Hash] opts the optional parameters + # @option opts [String] :idempotency_key # @option opts [String] :country The country in ISO format or number retrieved from the `Country List` endpoint - # @option opts [String] :pool The pool or number retrieved from the `Pool List` endpoint (optional) + # @option opts [String] :pool The pool ID or name retrieved from the `Pool List` endpoint (optional). An unknown name answers 400 `INVALID_POOL`. # @option opts [Float] :max_price The max price you are willing to pay per number # @option opts [Integer] :pricing_option Set to 0 if you'd like the cheapest numbers, set to 1 for highest success rate - # @option opts [Integer] :quantity Quantity of numbers ordered + # @option opts [Integer] :quantity Quantity of numbers ordered, 1 to 20. Must be a whole number. # @option opts [String] :areacode Areacodes you would like to include or exclude in JSON format # @option opts [Integer] :exclude Set exclude to 1 if you would like to exclude all listed area codes. # @option opts [Integer] :create_token Optional param; set to 1 if you'd like to create a token link that anyone can access. # @option opts [String] :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. # @option opts [Integer] :carrier Options: 1 or 2. Pick a carrier (only works for pool Foxtrot US) - # @option opts [Integer] :phonenumber In case you want to select a specific phone number to order + # @option opts [Integer] :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. + # @option opts [Integer] :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. + # @option opts [String] :response Set to `v2` for one response shape whatever the quantity: `{success, orders, failed, message}`. Leave out for the legacy shapes. # @option opts [Integer] :software # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def purchase_sms_with_http_info(service, opts = {}) @@ -79,6 +87,7 @@ def purchase_sms_with_http_info(service, opts = {}) if !content_type.nil? header_params['Content-Type'] = content_type end + header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil? # form parameters form_params = opts[:form_params] || {} @@ -94,6 +103,8 @@ def purchase_sms_with_http_info(service, opts = {}) form_params['activation_type'] = opts[:'activation_type'] if !opts[:'activation_type'].nil? form_params['carrier'] = opts[:'carrier'] if !opts[:'carrier'].nil? form_params['phonenumber'] = opts[:'phonenumber'] if !opts[:'phonenumber'].nil? + form_params['auto_country'] = opts[:'auto_country'] if !opts[:'auto_country'].nil? + form_params['response'] = opts[:'response'] if !opts[:'response'].nil? form_params['software'] = opts[:'software'] if !opts[:'software'].nil? # http body (model) @@ -298,7 +309,7 @@ def request_areacodes_with_http_info(service, country, pool, opts = {}) return_type = opts[:debug_return_type] || 'Object' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['bearerAuth'] new_options = opts.merge( :operation => :"SMSApi.request_areacodes", @@ -388,6 +399,81 @@ def request_history_with_http_info(opts = {}) return data, status_code, headers end + # 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`. + # @param search [String] The search term, as typed into the order history's search box. At most 32 characters. + # @param [Hash] opts the optional parameters + # @option opts [String] :cursor `next` from the previous call. Leave out for the first call. + # @option opts [Integer] :limit Matches per call, 1 to 500 (default 100). + # @return [Object] + def request_history_search(search, opts = {}) + data, _status_code, _headers = request_history_search_with_http_info(search, opts) + data + end + + # 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`. + # @param search [String] The search term, as typed into the order history's search box. At most 32 characters. + # @param [Hash] opts the optional parameters + # @option opts [String] :cursor `next` from the previous call. Leave out for the first call. + # @option opts [Integer] :limit Matches per call, 1 to 500 (default 100). + # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers + def request_history_search_with_http_info(search, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SMSApi.request_history_search ...' + end + # verify the required parameter 'search' is set + if @api_client.config.client_side_validation && search.nil? + fail ArgumentError, "Missing the required parameter 'search' when calling SMSApi.request_history_search" + end + # resource path + local_var_path = '/request/history_search' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['search'] = search + form_params['cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil? + form_params['limit'] = opts[:'limit'] if !opts[:'limit'].nil? + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Object' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearerAuth'] + + new_options = opts.merge( + :operation => :"SMSApi.request_history_search", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SMSApi#request_history_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Activate SMS # This endpoint will forcefully activate an SMS to set it available for future resends, please keep in mind that these orders are NOT eligible for a refund after activating them. # @param orderid [String] @@ -458,7 +544,7 @@ def sms_activate_with_http_info(orderid, opts = {}) end # 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. # @param [Hash] opts the optional parameters # @option opts [String] :country Country retrieved from ''Country list\\\" endpoint (optional) # @option opts [String] :service Service retrieved from ''Service list\\\" endpoint (optional) @@ -470,7 +556,7 @@ def sms_all_stock(opts = {}) end # 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. # @param [Hash] opts the optional parameters # @option opts [String] :country Country retrieved from ''Country list\\\" endpoint (optional) # @option opts [String] :service Service retrieved from ''Service list\\\" endpoint (optional) @@ -528,8 +614,77 @@ def sms_all_stock_with_http_info(opts = {}) return data, status_code, headers end + # 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. + # @param orderid [String] The order code from the `Order SMS` endpoint. + # @param [Hash] opts the optional parameters + # @return [Object] + def sms_archive(orderid, opts = {}) + data, _status_code, _headers = sms_archive_with_http_info(orderid, opts) + data + end + + # 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. + # @param orderid [String] The order code from the `Order SMS` endpoint. + # @param [Hash] opts the optional parameters + # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers + def sms_archive_with_http_info(orderid, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SMSApi.sms_archive ...' + end + # verify the required parameter 'orderid' is set + if @api_client.config.client_side_validation && orderid.nil? + fail ArgumentError, "Missing the required parameter 'orderid' when calling SMSApi.sms_archive" + end + # resource path + local_var_path = '/sms/archive' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['orderid'] = orderid + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Object' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearerAuth'] + + new_options = opts.merge( + :operation => :"SMSApi.sms_archive", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SMSApi#sms_archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # 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`. # @param [Hash] opts the optional parameters # @option opts [String] :orderid # @option opts [String] :orderids @@ -542,7 +697,7 @@ def sms_cancel(opts = {}) end # 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`. # @param [Hash] opts the optional parameters # @option opts [String] :orderid # @option opts [String] :orderids @@ -855,7 +1010,7 @@ def sms_clear_cache_with_http_info(opts = {}) end # 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. # @param [Hash] opts the optional parameters # @option opts [Integer] :phonenumber Only return messages for this number, including the country code. Leave it out for all your numbers. # @option opts [Integer] :limit Maximum number of messages. Defaults to 100, at most 500. @@ -866,7 +1021,7 @@ def sms_missed(opts = {}) end # 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. # @param [Hash] opts the optional parameters # @option opts [Integer] :phonenumber Only return messages for this number, including the country code. Leave it out for all your numbers. # @option opts [Integer] :limit Maximum number of messages. Defaults to 100, at most 500. @@ -1061,7 +1216,7 @@ def sms_resend_with_http_info(orderid, opts = {}) end # 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. # @param country [String] Country retrieved from ''Country list\\\" endpoint # @param service [String] Service retrieved from ''Service list\\\" endpoint # @param [Hash] opts the optional parameters @@ -1074,7 +1229,7 @@ def sms_stock(country, service, opts = {}) end # 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. # @param country [String] Country retrieved from ''Country list\\\" endpoint # @param service [String] Service retrieved from ''Service list\\\" endpoint # @param [Hash] opts the optional parameters diff --git a/lib/smspool/api/status_api.rb b/lib/smspool/api/status_api.rb new file mode 100644 index 0000000..18cdbd0 --- /dev/null +++ b/lib/smspool/api/status_api.rb @@ -0,0 +1,79 @@ +=begin +#SMSPool API + +#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 +Generator version: 7.25.0 + +=end + +require 'cgi' + +module SMSPool + class StatusApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # 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. + # @param [Hash] opts the optional parameters + # @return [Object] + def up(opts = {}) + data, _status_code, _headers = up_with_http_info(opts) + data + end + + # 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. + # @param [Hash] opts the optional parameters + # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers + def up_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StatusApi.up ...' + end + # resource path + local_var_path = '/up' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Object' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"StatusApi.up", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StatusApi#up\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/smspool/api/voucher_api.rb b/lib/smspool/api/voucher_api.rb index f9e7b91..d13fcfa 100644 --- a/lib/smspool/api/voucher_api.rb +++ b/lib/smspool/api/voucher_api.rb @@ -1,7 +1,7 @@ =begin #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 @@ -163,6 +163,7 @@ def voucher_delete_with_http_info(voucher, opts = {}) # Generate voucher # @param amount [Float] The amount per promocode # @param [Hash] opts the optional parameters + # @option opts [String] :idempotency_key # @return [Object] def voucher_generate(amount, opts = {}) data, _status_code, _headers = voucher_generate_with_http_info(amount, opts) @@ -172,6 +173,7 @@ def voucher_generate(amount, opts = {}) # Generate voucher # @param amount [Float] The amount per promocode # @param [Hash] opts the optional parameters + # @option opts [String] :idempotency_key # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def voucher_generate_with_http_info(amount, opts = {}) if @api_client.config.debugging @@ -196,6 +198,7 @@ def voucher_generate_with_http_info(amount, opts = {}) if !content_type.nil? header_params['Content-Type'] = content_type end + header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil? # form parameters form_params = opts[:form_params] || {} diff --git a/lib/smspool/api_client.rb b/lib/smspool/api_client.rb index a589a61..63fbeef 100644 --- a/lib/smspool/api_client.rb +++ b/lib/smspool/api_client.rb @@ -1,7 +1,7 @@ =begin #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 diff --git a/lib/smspool/api_error.rb b/lib/smspool/api_error.rb index 6b36f24..ca207fd 100644 --- a/lib/smspool/api_error.rb +++ b/lib/smspool/api_error.rb @@ -1,7 +1,7 @@ =begin #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 diff --git a/lib/smspool/api_model_base.rb b/lib/smspool/api_model_base.rb index f7a1d90..e077c8e 100644 --- a/lib/smspool/api_model_base.rb +++ b/lib/smspool/api_model_base.rb @@ -1,7 +1,7 @@ =begin #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 diff --git a/lib/smspool/configuration.rb b/lib/smspool/configuration.rb index f0d366d..9b790ce 100644 --- a/lib/smspool/configuration.rb +++ b/lib/smspool/configuration.rb @@ -1,7 +1,7 @@ =begin #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 diff --git a/lib/smspool/version.rb b/lib/smspool/version.rb index 24a50d9..33ce5c7 100644 --- a/lib/smspool/version.rb +++ b/lib/smspool/version.rb @@ -1,7 +1,7 @@ =begin #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 diff --git a/smspool.gemspec b/smspool.gemspec index 45ef8cd..cff5409 100644 --- a/smspool.gemspec +++ b/smspool.gemspec @@ -3,7 +3,7 @@ =begin #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