diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f5726aa --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,59 @@ +name: Deploy + +on: + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['2.7', '3.0', '3.1', '3.2'] + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Install dependencies + run: bundle install + - name: Run RSpec + run: bundle exec rspec + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + - name: Install dependencies + run: bundle install + - name: Run RuboCop + run: bundle exec rubocop + + deploy: + needs: [test, lint] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + - name: Install dependencies + run: bundle install + - name: Build gem + run: gem build *.gemspec + - name: Push to RubyGems + run: | + mkdir -p $HOME/.gem + echo ":rubygems_api_key: ${{ secrets.RUBY_GEMS_TOKEN }}" > $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + gem push *.gem diff --git a/.gitignore b/.gitignore index b8bc553..595af0f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ Gemfile.lock .DS_Store pkg vendor/bundle +.yardoc +doc diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..a74005a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,66 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. + +[homepage]: https://www.contributor-covenant.org +[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html diff --git a/README.md b/README.md index 6200c95..36a219e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,15 @@ A modern, robust, and fully-featured Ruby client for the Zadarma API. This gem has been updated to support the latest Zadarma API, providing a clean and intuitive interface for all available endpoints. -## Installation +## Getting Started + +### Prerequisites + +- Ruby 2.7 or later +- A Zadarma account +- Your Zadarma API key and secret + +### Installation Add this line to your application's Gemfile: @@ -18,7 +26,7 @@ Or install it yourself as: $ gem install zadarma -## Usage +## Configuration First, configure the client with your API key and secret. You can find these in your Zadarma personal account. @@ -28,6 +36,8 @@ require 'zadarma' client = Zadarma::Client.new(api_key: 'YOUR_API_KEY', api_secret: 'YOUR_API_SECRET') ``` +## Usage + Now you can call any of the available API methods: ### Get Your Balance @@ -92,7 +102,7 @@ This client is organized into resources, mirroring the Zadarma API structure. * `statistics(start:, end_date:, sip: nil, cost_only: nil, type: nil, skip: nil, limit: nil)`: Get overall call statistics. * `pbx_statistics(start:, end_date:, version: nil, skip: nil, limit: nil, call_type: nil)`: Get PBX call statistics. -## Development & Testing +## Development To work on this gem locally, clone the repository and then run `bundle install` to install the dependencies. @@ -109,3 +119,15 @@ The test suite is configured to use `webmock` to stub out all API requests, so y 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request + +## License + +The gem is available as open source under the terms of the [MIT License](https'://opensource.org/licenses/MIT). + +## Code of Conduct + +Everyone interacting in the Zadarma project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md). + +## Version History + +* **2.0.0** - The current version. diff --git a/lib/zadarma/client.rb b/lib/zadarma/client.rb index 53b0237..2e4043b 100644 --- a/lib/zadarma/client.rb +++ b/lib/zadarma/client.rb @@ -27,140 +27,333 @@ class Client API_URL = 'https://api.zadarma.com' + # Initializes a new Client object. + # + # @param api_key [String] The Zadarma API key. + # @param api_secret [String] The Zadarma API secret. def initialize(api_key:, api_secret:) @api_key = api_key @api_secret = api_secret end + # Get the current account balance. + # + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_balance def balance info.balance end + # Get the price for a call to a specific number. + # + # @param number [String] The destination number. + # @param caller_id [String] The caller ID. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_price def price(number:, caller_id: nil) info.price(number: number, caller_id: caller_id) end + # Get a list of internal PBX numbers. + # + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_pbx_internal def internal_numbers pbx.internal end + # Enable or disable call recording for a PBX extension. + # + # @param id [String] The PBX extension ID. + # @param status [String] The recording status. + # @param email [String] The email address to send the recording to. + # @param speech_recognition [String] The speech recognition status. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_pbx_record def set_call_recording(id:, status:, email: nil, speech_recognition: nil) pbx.set_call_recording(id: id, status: status, email: email, speech_recognition: speech_recognition) end + # Request a call recording from the PBX. + # + # @param call_id [String] The call ID. + # @param pbx_call_id [String] The PBX call ID. + # @param lifetime [String] The lifetime of the recording. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_pbx_record_request def pbx_record_request(call_id: nil, pbx_call_id: nil, lifetime: nil) pbx.pbx_record_request(call_id: call_id, pbx_call_id: pbx_call_id, lifetime: lifetime) end + # Get a list of direct numbers. + # + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_direct_numbers def direct_numbers direct_numbers_resource.all end + # Get a list of countries for direct numbers. + # + # @param language [String] The language of the response. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_direct_number_countries def direct_number_countries(language: nil) direct_numbers_resource.countries(language: language) end + # Get a list of direct numbers for a specific country. + # + # @param country [String] The country code. + # @param language [String] The language of the response. + # @param direction_id [String] The direction ID. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_direct_number_country def direct_number_country(country:, language: nil, direction_id: nil) direct_numbers_resource.country(country: country, language: language, direction_id: direction_id) end + # Get a list of available direct numbers. + # + # @param direction_id [String] The direction ID. + # @param mask [String] The number mask. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_available_direct_numbers def available_direct_numbers(direction_id:, mask: nil) direct_numbers_resource.available(direction_id: direction_id, mask: mask) end + # Order a direct number. + # + # @param params [Hash] The order parameters. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_order_direct_number def order_direct_number(params) direct_numbers_resource.order(params) end + # Prolong a direct number. + # + # @param number [String] The direct number. + # @param months [String] The number of months to prolong the number for. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_prolong_direct_number def prolong_direct_number(number:, months:) direct_numbers_resource.prolong(number: number, months: months) end + # Initiate a callback between two numbers. + # + # @param from [String] The source number. + # @param to [String] The destination number. + # @param sip [String] The SIP number. + # @param predicted [String] The predicted status. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_callback def callback(from:, to:, sip: nil, predicted: nil) request_resource.callback(from: from, to: to, sip: sip, predicted: predicted) end + # Get a list of SIP numbers. + # + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_sips def sips sip.all end + # Get the status of a SIP number. + # + # @param sip [String] The SIP number. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_sip_status def sip_status(sip:) self.sip.status(sip: sip) end + # Create a SIP number. + # + # @param name [String] The SIP number name. + # @param password [String] The SIP number password. + # @param callerid [String] The SIP number caller ID. + # @param redirect_to_phone [String] The phone number to redirect to. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_create_sip def create_sip(name:, password: nil, callerid: nil, redirect_to_phone: nil) sip.create(name: name, password: password, callerid: callerid, redirect_to_phone: redirect_to_phone) end + # Set the password for a SIP number. + # + # @param sip [String] The SIP number. + # @param value [String] The new password. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_set_sip_password def set_sip_password(sip:, value:) self.sip.password(sip: sip, value: value) end + # Set the caller ID for a SIP number. + # + # @param id [String] The SIP number ID. + # @param number [String] The new caller ID. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_set_sip_caller_id def set_sip_caller_id(id:, number:) sip.set_caller_id(id: id, number: number) end + # Get call forwarding information for a SIP number. + # + # @param id [String] The SIP number ID. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_redirection def redirection(id: nil) sip.redirection(id: id) end + # Set call forwarding for a SIP number. + # + # @param id [String] The SIP number ID. + # @param status [String] The forwarding status. + # @param type [String] The forwarding type. + # @param number [String] The forwarding number. + # @param condition [String] The forwarding condition. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_set_redirection def set_redirection(id:, status:, type: nil, number: nil, condition: nil) sip.set_redirection(id: id, status: status, type: type, number: number, condition: condition) end + # Send an SMS message. + # + # @param number [String] The destination number. + # @param message [String] The message text. + # @param sender [String] The sender ID. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_send_sms def send_sms(number:, message:, sender: nil) sms.send_sms(number: number, message: message, sender: sender) end + # Get overall call statistics. + # + # @param params [Hash] The statistics parameters. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_statistics def statistics(params) statistics_resource.statistics(params) end + # Get PBX call statistics. + # + # @param params [Hash] The statistics parameters. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_pbx_statistics def pbx_statistics(params) statistics_resource.pbx_statistics(params) end + # Get speech recognition results. + # + # @param call_id [String] The call ID. + # @param lang [String] The language of the speech. + # @param return_results [String] Whether to return the results. + # @param alternatives [String] Whether to return alternative results. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_get_speech_recognition def get_speech_recognition(call_id:, lang: nil, return_results: nil, alternatives: nil) speech_recognition_resource.get(call_id: call_id, lang: lang, return_results: return_results, alternatives: alternatives) end + # Initiate speech recognition. + # + # @param call_id [String] The call ID. + # @param lang [String] The language of the speech. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_initiate_speech_recognition def initiate_speech_recognition(call_id:, lang: nil) speech_recognition_resource.initiate(call_id: call_id, lang: lang) end + # Get a list of document files. + # + # @param group_id [String] The group ID. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_document_files def document_files(group_id: nil) groups_of_documents_resource.files(group_id: group_id) end + # Get a list of document groups. + # + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_document_groups def document_groups groups_of_documents_resource.list end + # Get a document group. + # + # @param id [String] The group ID. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_get_document_group def get_document_group(id:) groups_of_documents_resource.get(id: id) end + # Create a document group. + # + # @param params [Hash] The group parameters. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_create_document_group def create_document_group(params:) groups_of_documents_resource.create(params: params) end + # Update a document group. + # + # @param id [String] The group ID. + # @param params [Hash] The group parameters. + # @return [Hash] The API response. + # @see https://zadarma.com/en/support/api/#api_update_document_group def update_document_group(id:, params:) groups_of_documents_resource.update(id: id, params: params) end + # Make a GET request to the Zadarma API. + # + # @param path [String] The API endpoint path. + # @param params [Hash] The request parameters. + # @return [Hash] The API response. def get(path, params = {}) request(:get, path, params) end + # Make a POST request to the Zadarma API. + # + # @param path [String] The API endpoint path. + # @param params [Hash] The request parameters. + # @return [Hash] The API response. def post(path, params = {}) request(:post, path, params) end + # Make a PUT request to the Zadarma API. + # + # @param path [String] The API endpoint path. + # @param params [Hash] The request parameters. + # @return [Hash] The API response. def put(path, params = {}) request(:put, path, params) end + # Make a DELETE request to the Zadarma API. + # + # @param path [String] The API endpoint path. + # @param params [Hash] The request parameters. + # @return [Hash] The API response. def delete(path, params = {}) request(:delete, path, params) end diff --git a/mkdocs/direct_numbers.md b/mkdocs/direct_numbers.md new file mode 100644 index 0000000..d922384 --- /dev/null +++ b/mkdocs/direct_numbers.md @@ -0,0 +1,111 @@ +# Direct Numbers Resource + +The Direct Numbers resource allows you to manage virtual numbers. + +## `all()` + +Get information about the user's virtual numbers. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.direct_numbers +``` + +## `countries(language: nil)` + +Get a list of countries where numbers can be ordered. + +**Parameters:** + +* `language` (String): The language for the country names. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.direct_number_countries(language: 'en') +``` + +## `country(country:, language: nil, direction_id: nil)` + +Get a list of destinations in a country where a number can be ordered. + +**Parameters:** + +* `country` (String): The ISO country code. +* `language` (String): The language for the destination names. +* `direction_id` (String): The direction ID. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.direct_number_country(country: 'US') +``` + +## `available(direction_id:, mask: nil)` + +Get a list of available numbers for a given direction. + +**Parameters:** + +* `direction_id` (String): The direction ID. +* `mask` (String): A mask for searching number matches. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.available_direct_numbers(direction_id: '123') +``` + +## `order(params)` + +Order a virtual number. + +**Parameters:** + +* `params` (Hash): The parameters for ordering a number. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.order_direct_number(direction_id: '123', number_id: '456') +``` + +## `prolong(number:, months:)` + +Prepay the number for the specified number of months. + +**Parameters:** + +* `number` (String): The number to be prolonged. +* `months` (Integer): The number of months. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.prolong_direct_number(number: '1234567890', months: 3) +``` diff --git a/mkdocs/groups_of_documents.md b/mkdocs/groups_of_documents.md new file mode 100644 index 0000000..6cfb9ed --- /dev/null +++ b/mkdocs/groups_of_documents.md @@ -0,0 +1,90 @@ +# Groups of Documents Resource + +The Groups of Documents resource allows you to manage groups of documents. + +## `files(group_id: nil)` + +Get the list of files/documents in the group of documents. + +**Parameters:** + +* `group_id` (String): The group of documents ID. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.document_files(group_id: '123') +``` + +## `list()` + +Get the list of groups of documents. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.document_groups +``` + +## `get(id:)` + +Get information on a certain group. + +**Parameters:** + +* `id` (String): The group ID. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.get_document_group(id: '123') +``` + +## `create(params:)` + +Create a new group of documents. + +**Parameters:** + +* `params` (Hash): The parameters for creating a new group of documents. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.create_document_group(params: { name: 'My Group' }) +``` + +## `update(id:, params:)` + +Update a group of documents. + +**Parameters:** + +* `id` (String): The group ID. +* `params` (Hash): The parameters for updating a group of documents. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.update_document_group(id: '123', params: { name: 'My New Group' }) +``` diff --git a/mkdocs/index.md b/mkdocs/index.md new file mode 100644 index 0000000..cc1ebff --- /dev/null +++ b/mkdocs/index.md @@ -0,0 +1,45 @@ +# Zadarma API Ruby Client Documentation + +Welcome to the developer documentation for the Zadarma API Ruby Client. This guide provides detailed information about every aspect of the gem, from installation and configuration to a complete reference of all available API methods. + +## Getting Started + +### Installation + +Add this line to your application's Gemfile: + +```ruby +gem 'zadarma' +``` + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install zadarma + +### Configuration + +First, configure the client with your API key and secret. You can find these in your Zadarma personal account. + +```ruby +require 'zadarma' + +client = Zadarma::Client.new(api_key: 'YOUR_API_KEY', api_secret: 'YOUR_API_SECRET') +``` + +## API Resources + +This client is organized into resources, mirroring the Zadarma API structure. Click on a resource below for a detailed list of its methods and parameters. + +* [Info](info.md) +* [PBX](pbx.md) +* [Direct Numbers](direct_numbers.md) +* [Request](request.md) +* [SIP](sip.md) +* [SMS](sms.md) +* [Statistics](statistics.md) +* [Speech Recognition](speech_recognition.md) +* [Groups of Documents](groups_of_documents.md) diff --git a/mkdocs/info.md b/mkdocs/info.md new file mode 100644 index 0000000..01f9e6c --- /dev/null +++ b/mkdocs/info.md @@ -0,0 +1,36 @@ +# Info Resource + +The Info resource provides access to user information, such as balance and call rates. + +## `balance()` + +Get the user's balance. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.balance +``` + +## `price(number:, caller_id: nil)` + +Get the call rate for a given number. + +**Parameters:** + +* `number` (String): The phone number. +* `caller_id` (String): The CallerID to be used for the call. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.price(number: '1234567890') +``` diff --git a/mkdocs/pbx.md b/mkdocs/pbx.md new file mode 100644 index 0000000..450312c --- /dev/null +++ b/mkdocs/pbx.md @@ -0,0 +1,58 @@ +# PBX Resource + +The PBX resource allows you to manage your Zadarma PBX. + +## `internal()` + +Get the list of PBX internal numbers. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.internal_numbers +``` + +## `set_call_recording(id:, status:, email: nil, speech_recognition: nil)` + +Set the call recording for a PBX extension. + +**Parameters:** + +* `id` (String): The PBX extension ID. +* `status` (String): The call recording status ('on', 'off', etc.). +* `email` (String): The email address to send recordings to. +* `speech_recognition` (String): The speech recognition settings. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.set_call_recording(id: '123', status: 'on') +``` + +## `pbx_record_request(call_id: nil, pbx_call_id: nil, lifetime: nil)` + +Request a call recording file. + +**Parameters:** + +* `call_id` (String): The unique call ID. +* `pbx_call_id` (String): The permanent ID of the external call to the PBX. +* `lifetime` (Integer): The link's lifetime in seconds. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.pbx_record_request(call_id: '12345') +``` diff --git a/mkdocs/request.md b/mkdocs/request.md new file mode 100644 index 0000000..44cf9f5 --- /dev/null +++ b/mkdocs/request.md @@ -0,0 +1,24 @@ +# Request Resource + +The Request resource allows you to initiate callbacks. + +## `callback(from:, to:, sip: nil, predicted: nil)` + +Request a callback. + +**Parameters:** + +* `from` (String): Your phone/SIP number, the PBX extension or the PBX scenario. +* `to` (String): The phone or SIP number that is being called. +* `sip` (String): The SIP user's number or the PBX extension. +* `predicted` (String): If specified, the request is predicted. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.callback(from: '1234567890', to: '0987654321') +``` diff --git a/mkdocs/sip.md b/mkdocs/sip.md new file mode 100644 index 0000000..5366c7a --- /dev/null +++ b/mkdocs/sip.md @@ -0,0 +1,134 @@ +# SIP Resource + +The SIP resource allows you to manage your SIP numbers. + +## `all()` + +Get the list of user's SIP-numbers. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.sips +``` + +## `set_caller_id(id:, number:)` + +Set the CallerID for a SIP number. + +**Parameters:** + +* `id` (String): The SIP ID. +* `number` (String): The new CallerID. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.set_sip_caller_id(id: '123', number: '1234567890') +``` + +## `redirection(id: nil)` + +Get call forwarding information for a SIP number. + +**Parameters:** + +* `id` (String): The SIP ID. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.redirection(id: '123') +``` + +## `set_redirection(id:, status:, type: nil, number: nil, condition: nil)` + +Set call forwarding for a SIP number. + +**Parameters:** + +* `id` (String): The SIP ID. +* `status` (String): The call forwarding status ('on' or 'off'). +* `type` (String): The call forwarding type ('phone', 'voicemail', etc.). +* `number` (String): The destination number for call forwarding. +* `condition` (String): The call forwarding condition ('always', 'noanswer', etc.). + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.set_redirection(id: '123', status: 'on', type: 'phone', number: '1234567890') +``` + +## `status(sip:)` + +Get the online status of a SIP number. + +**Parameters:** + +* `sip` (String): The SIP number. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.sip_status(sip: '123') +``` + +## `create(name:, password: nil, callerid: nil, redirect_to_phone: nil)` + +Create a new SIP number. + +**Parameters:** + +* `name` (String): The displayed name for the new SIP number. +* `password` (String): The password for the new SIP number. +* `callerid` (String): The CallerID for the new SIP number. +* `redirect_to_phone` (String): The phone number to redirect calls to. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.create_sip(name: 'My SIP') +``` + +## `password(sip:, value:)` + +Change the password for a SIP number. + +**Parameters:** + +* `sip` (String): The SIP number. +* `value` (String): The new password. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.set_sip_password(sip: '123', value: 'new_password') +``` diff --git a/mkdocs/sms.md b/mkdocs/sms.md new file mode 100644 index 0000000..dad4fc4 --- /dev/null +++ b/mkdocs/sms.md @@ -0,0 +1,23 @@ +# SMS Resource + +The SMS resource allows you to send SMS messages. + +## `send_sms(number:, message:, sender: nil)` + +Send an SMS message. + +**Parameters:** + +* `number` (String): The destination phone number. +* `message` (String): The SMS message text. +* `sender` (String): The SMS sender (virtual number or text). + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.send_sms(number: '1234567890', message: 'Hello, world!') +``` diff --git a/mkdocs/speech_recognition.md b/mkdocs/speech_recognition.md new file mode 100644 index 0000000..667b9b3 --- /dev/null +++ b/mkdocs/speech_recognition.md @@ -0,0 +1,43 @@ +# Speech Recognition Resource + +The Speech Recognition resource allows you to manage speech recognition. + +## `get(call_id:, lang: nil, return_results: nil, alternatives: nil)` + +Get recognition results. + +**Parameters:** + +* `call_id` (String): The unique call ID. +* `lang` (String): The recognition language. +* `return_results` (String): The returned result ('words' or 'phrases'). +* `alternatives` (String): Return alternative results ('0' or '1'). + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.get_speech_recognition(call_id: '12345') +``` + +## `initiate(call_id:, lang: nil)` + +Initiate call recognition. + +**Parameters:** + +* `call_id` (String): The unique call ID. +* `lang` (String): The recognition language. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.initiate_speech_recognition(call_id: '12345') +``` diff --git a/mkdocs/statistics.md b/mkdocs/statistics.md new file mode 100644 index 0000000..427bda4 --- /dev/null +++ b/mkdocs/statistics.md @@ -0,0 +1,39 @@ +# Statistics Resource + +The Statistics resource provides access to call statistics. + +## `statistics(params)` + +Get overall call statistics. + +**Parameters:** + +* `params` (Hash): The parameters for the statistics request. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.statistics(start: '2023-01-01', end: '2023-01-31') +``` + +## `pbx_statistics(params)` + +Get PBX call statistics. + +**Parameters:** + +* `params` (Hash): The parameters for the PBX statistics request. + +**Returns:** + +A `Hash` containing the API response. + +**Example:** + +```ruby +client.pbx_statistics(start: '2023-01-01', end: '2023-01-31') +``` diff --git a/zadarma.gemspec b/zadarma.gemspec index d071dee..2aff6eb 100644 --- a/zadarma.gemspec +++ b/zadarma.gemspec @@ -23,4 +23,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'rubocop', '~> 1.0' s.add_development_dependency 'rubocop-rspec', '~> 2.0' s.add_development_dependency 'webmock', '~> 3.0' + s.add_development_dependency 'yard', '~> 0.9' end