diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index eab7300fa..0b4d1b8c6 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -17,7 +17,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - ruby: [ 2.4, 2.5, 2.6, 2.7, '3.0', ruby-head, jruby-9.2 ] + ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', 'ruby-head', 'jruby-9.2' ] steps: - name: Checkout twilio-ruby uses: actions/checkout@v2 @@ -105,6 +105,11 @@ jobs: gem build *.gemspec gem push *.gem + - name: Submit metric to Datadog + uses: sendgrid/dx-automator/actions/datadog-release-metric@main + env: + DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} + notify-on-failure: name: Slack notify on failure if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') @@ -115,7 +120,7 @@ jobs: env: SLACK_COLOR: failure SLACK_ICON_EMOJI: ':github:' - SLACK_MESSAGE: ${{ format('Tests *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }} + SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }} SLACK_TITLE: Action Failure - ${{ github.repository }} SLACK_USERNAME: GitHub Actions SLACK_MSG_AUTHOR: twilio-dx diff --git a/CHANGES.md b/CHANGES.md index a141366ca..abca983fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,136 @@ twilio-ruby changelog ===================== +[2022-03-23] Version 5.66.0 +--------------------------- +**Api** +- Change `stream` url parameter to non optional +- Add `verify-totp` and `verify-whatsapp-conversations-business-initiated` categories to `usage_record` API + +**Chat** +- Added v3 Channel update endpoint to support Public to Private channel migration + +**Flex** +- Private Beta release of the Interactions API to support the upcoming release of Flex Conversations at the end of Q1 2022. +- Adding `channel_configs` object to Flex Configuration + +**Media** +- Add max_duration param to PlayerStreamer + +**Supersim** +- Remove Commands resource, use SmsCommands resource instead **(breaking change)** + +**Taskrouter** +- Add limits to `split_by_wait_time` for Cumulative Statistics Endpoint + +**Video** +- Change recording `status_callback_method` type from `enum` to `http_method` **(breaking change)** +- Add `status_callback` and `status_callback_method` to composition +- Add `status_callback` and `status_callback_method` to recording + + +[2022-03-09] Version 5.65.1 +--------------------------- +**Library - Fix** +- [PR #602](https://github.com/twilio/twilio-ruby/pull/602): don't load webhook authentication if Rack not present. Thanks to [@philnash](https://github.com/philnash)! + +**Library - Chore** +- [PR #599](https://github.com/twilio/twilio-ruby/pull/599): push Datadog Release Metric upon deploy success. Thanks to [@eshanholtz](https://github.com/eshanholtz)! + +**Api** +- Add optional boolean include_soft_deleted parameter to retrieve soft deleted recordings + +**Chat** +- Add `X-Twilio-Wehook-Enabled` header to `delete` method in UserChannel resource + +**Numbers** +- Expose `failure_reason` in the Supporting Documents resources + +**Verify** +- Add optional `metadata` parameter to "verify challenge" endpoint, so the SDK/App can attach relevant information from the device when responding to challenges. +- remove beta feature flag to list atempt api operations. +- Add `ttl` and `date_created` properties to `AccessTokens`. + + +[2022-02-23] Version 5.65.0 +--------------------------- +**Api** +- Add `uri` to `stream` resource +- Add A2P Registration Fee category (`a2p-registration-fee`) to usage records +- Detected a bug and removed optional boolean include_soft_deleted parameter to retrieve soft deleted recordings. **(breaking change)** +- Add optional boolean include_soft_deleted parameter to retrieve soft deleted recordings. + +**Numbers** +- Unrevert valid_until and sort filter params added to List Bundles resource +- Revert valid_until and sort filter params added to List Bundles resource +- Update sorting params added to List Bundles resource in the previous release + +**Preview** +- Moved `web_channels` from preview to beta under `flex-api` **(breaking change)** + +**Taskrouter** +- Add `ETag` as Response Header to List of Task, Reservation & Worker + +**Verify** +- Remove outdated documentation commentary to contact sales. Product is already in public beta. +- Add optional `metadata` to factors. + +**Twiml** +- Add new Polly Neural voices + + +[2022-02-09] Version 5.64.0 +--------------------------- +**Library - Chore** +- [PR #594](https://github.com/twilio/twilio-ruby/pull/594): upgrade supported language versions. Thanks to [@childish-sambino](https://github.com/childish-sambino)! + +**Api** +- Add `stream` resource + +**Conversations** +- Fixed DELETE request to accept "sid_like" params in Address Configuration resources **(breaking change)** +- Expose Address Configuration resource for `sms` and `whatsapp` + +**Fax** +- Removed deprecated Programmable Fax Create and Update methods **(breaking change)** + +**Insights** +- Rename `call_state` to `call_status` and remove `whisper` in conference participant summary **(breaking change)** + +**Numbers** +- Expose valid_until filters as part of provisionally-approved compliance feature on the List Bundles resource + +**Supersim** +- Fix typo in Fleet resource docs +- Updated documentation for the Fleet resource indicating that fields related to commands have been deprecated and to use sms_command fields instead. +- Add support for setting and reading `ip_commands_url` and `ip_commands_method` on Fleets resource for helper libraries +- Changed `sim` property in requests to create an SMS Command made to the /SmsCommands to accept SIM UniqueNames in addition to SIDs + +**Verify** +- Update list attempts API to include new filters and response fields. + + +[2022-01-26] Version 5.63.1 +--------------------------- +**Library - Fix** +- [PR #590](https://github.com/twilio/twilio-ruby/pull/590): Validate signatures in Rack middleware for non-form-data payloads. Thanks to [@gabrielg](https://github.com/gabrielg)! + +**Library - Chore** +- [PR #589](https://github.com/twilio/twilio-ruby/pull/589): Add sonarcloud analysis. Thanks to [@BrimmingDev](https://github.com/BrimmingDev)! +- [PR #588](https://github.com/twilio/twilio-ruby/pull/588): support for rubocop linting on ruby-head. Thanks to [@Hunga1](https://github.com/Hunga1)! + +**Insights** +- Added new endpoint to fetch Conference Participant Summary +- Added new endpoint to fetch Conference Summary + +**Messaging** +- Add government_entity parameter to brand apis + +**Verify** +- Add Access Token fetch endpoint to retrieve a previously created token. +- Add Access Token payload to the Access Token creation endpoint, including a unique Sid, so it's addressable while it's TTL is valid. + + [2022-01-12] Version 5.63.0 --------------------------- **Library - Feature** diff --git a/README.md b/README.md index a621ab986..48508e2b4 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ This library supports the following Ruby implementations: * Ruby 2.6 * Ruby 2.7 * Ruby 3.0 +* Ruby 3.1 ### Migrating from 4.x @@ -35,13 +36,13 @@ This library supports the following Ruby implementations: To install using [Bundler][bundler] grab the latest stable version: ```ruby -gem 'twilio-ruby', '~> 5.63.0' +gem 'twilio-ruby', '~> 5.66.0' ``` To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install: ```bash -gem install twilio-ruby -v 5.63.0 +gem install twilio-ruby -v 5.66.0 ``` To build and install the development branch yourself from the latest source: diff --git a/lib/rack/twilio_webhook_authentication.rb b/lib/rack/twilio_webhook_authentication.rb index 5df26ff80..ba522e500 100644 --- a/lib/rack/twilio_webhook_authentication.rb +++ b/lib/rack/twilio_webhook_authentication.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'rack/media_type' + module Rack # Middleware that authenticates webhooks from Twilio using the request # validator. @@ -19,6 +21,10 @@ module Rack # doesn't validate then the middleware responds immediately with a 403 status. class TwilioWebhookAuthentication + # Rack's FORM_DATA_MEDIA_TYPES can be modified to taste, so we're slightly + # more conservative in what we consider form data. + FORM_URLENCODED_MEDIA_TYPE = Rack::MediaType.type('application/x-www-form-urlencoded') + def initialize(app, auth_token, *paths, &auth_token_lookup) @app = app @auth_token = auth_token @@ -30,7 +36,7 @@ def call(env) return @app.call(env) unless env['PATH_INFO'].match(@path_regex) request = Rack::Request.new(env) original_url = request.url - params = request.post? ? request.POST : {} + params = extract_params!(request) auth_token = @auth_token || get_auth_token(params['AccountSid']) validator = Twilio::Security::RequestValidator.new(auth_token) signature = env['HTTP_X_TWILIO_SIGNATURE'] || '' @@ -44,5 +50,23 @@ def call(env) ] end end + + # Extract the params from the the request that we can use to determine the + # signature. This _may_ modify the passed in request since it may read/rewind + # the body. + def extract_params!(request) + return {} unless request.post? + + if request.media_type == FORM_URLENCODED_MEDIA_TYPE + request.POST + else + request.body.rewind + body = request.body.read + request.body.rewind + body + end + end + + private :extract_params! end end diff --git a/lib/twilio-ruby.rb b/lib/twilio-ruby.rb index 467f05dd7..335b4b48d 100644 --- a/lib/twilio-ruby.rb +++ b/lib/twilio-ruby.rb @@ -10,7 +10,7 @@ require 'json' require 'twilio-ruby/version' unless defined?(Twilio::VERSION) -require 'rack/twilio_webhook_authentication' +require 'rack/twilio_webhook_authentication' if defined?(Rack) require 'twilio-ruby/util' require 'twilio-ruby/security/request_validator' diff --git a/lib/twilio-ruby/rest/api/v2010/account/call.rb b/lib/twilio-ruby/rest/api/v2010/account/call.rb index 50e41391a..99d9ddf9c 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call.rb @@ -443,6 +443,7 @@ def initialize(version, account_sid, sid) @events = nil @payments = nil @siprec = nil + @streams = nil end ## @@ -617,6 +618,24 @@ def siprec(sid=:unset) @siprec end + ## + # Access the streams + # @return [StreamList] + # @return [StreamContext] if sid was passed. + def streams(sid=:unset) + raise ArgumentError, 'sid cannot be nil' if sid.nil? + + if sid != :unset + return StreamContext.new(@version, @solution[:account_sid], @solution[:sid], sid, ) + end + + unless @streams + @streams = StreamList.new(@version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], ) + end + + @streams + end + ## # Provide a user friendly representation def to_s @@ -958,6 +977,13 @@ def siprec context.siprec end + ## + # Access the streams + # @return [streams] streams + def streams + context.streams + end + ## # Provide a user friendly representation def to_s diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb b/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb index e7cca3a8f..e2cc45e2c 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb @@ -63,8 +63,8 @@ def initialize(version, account_sid: nil, call_sid: nil) # @param [String] min_postal_code_length A positive integer that is used to # validate the length of the `PostalCode` inputted by the user. User must enter # this many digits. - # @param [Hash] parameter A single level JSON string that is required when - # accepting certain information specific only to ACH payments. The information + # @param [Hash] parameter A single-level JSON object used to pass custom + # parameters to payment processors. (Required for ACH payments). The information # that has to be included here depends on the Connector. {Read # more}[https://www.twilio.com/console/voice/pay-connectors]. # @param [String] payment_connector This is the unique name corresponding to the diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb b/lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb index 53f7d589e..3fa1e6733 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb @@ -578,6 +578,7 @@ def initialize(version, payload, account_sid: nil, call_sid: nil, sid: nil) 'name' => payload['name'], 'status' => payload['status'], 'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']), + 'uri' => payload['uri'], } # Context @@ -637,6 +638,12 @@ def date_updated @properties['date_updated'] end + ## + # @return [String] The URI of the resource, relative to `https://api.twilio.com` + def uri + @properties['uri'] + end + ## # Update the SiprecInstance # @param [siprec.UpdateStatus] status The status. Must have the value `stopped` diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb b/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb new file mode 100644 index 000000000..e5e020a7c --- /dev/null +++ b/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb @@ -0,0 +1,674 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Api < Domain + class V2010 < Version + class AccountContext < InstanceContext + class CallContext < InstanceContext + class StreamList < ListResource + ## + # Initialize the StreamList + # @param [Version] version Version that contains the resource + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Stream + # resource. + # @param [String] call_sid The SID of the + # {Call}[https://www.twilio.com/docs/voice/api/call-resource] the Stream resource + # is associated with. + # @return [StreamList] StreamList + def initialize(version, account_sid: nil, call_sid: nil) + super(version) + + # Path Solution + @solution = {account_sid: account_sid, call_sid: call_sid} + @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/Streams.json" + end + + ## + # Create the StreamInstance + # @param [String] url Relative or absolute url where WebSocket connection will be + # established. + # @param [String] name The user-specified name of this Stream, if one was given + # when the Stream was created. This may be used to stop the Stream. + # @param [stream.Track] track One of `inbound_track`, `outbound_track`, + # `both_tracks`. + # @param [String] status_callback Absolute URL of the status callback. + # @param [String] status_callback_method The http method for the status_callback + # (one of GET, POST). + # @param [String] parameter1_name Parameter name + # @param [String] parameter1_value Parameter value + # @param [String] parameter2_name Parameter name + # @param [String] parameter2_value Parameter value + # @param [String] parameter3_name Parameter name + # @param [String] parameter3_value Parameter value + # @param [String] parameter4_name Parameter name + # @param [String] parameter4_value Parameter value + # @param [String] parameter5_name Parameter name + # @param [String] parameter5_value Parameter value + # @param [String] parameter6_name Parameter name + # @param [String] parameter6_value Parameter value + # @param [String] parameter7_name Parameter name + # @param [String] parameter7_value Parameter value + # @param [String] parameter8_name Parameter name + # @param [String] parameter8_value Parameter value + # @param [String] parameter9_name Parameter name + # @param [String] parameter9_value Parameter value + # @param [String] parameter10_name Parameter name + # @param [String] parameter10_value Parameter value + # @param [String] parameter11_name Parameter name + # @param [String] parameter11_value Parameter value + # @param [String] parameter12_name Parameter name + # @param [String] parameter12_value Parameter value + # @param [String] parameter13_name Parameter name + # @param [String] parameter13_value Parameter value + # @param [String] parameter14_name Parameter name + # @param [String] parameter14_value Parameter value + # @param [String] parameter15_name Parameter name + # @param [String] parameter15_value Parameter value + # @param [String] parameter16_name Parameter name + # @param [String] parameter16_value Parameter value + # @param [String] parameter17_name Parameter name + # @param [String] parameter17_value Parameter value + # @param [String] parameter18_name Parameter name + # @param [String] parameter18_value Parameter value + # @param [String] parameter19_name Parameter name + # @param [String] parameter19_value Parameter value + # @param [String] parameter20_name Parameter name + # @param [String] parameter20_value Parameter value + # @param [String] parameter21_name Parameter name + # @param [String] parameter21_value Parameter value + # @param [String] parameter22_name Parameter name + # @param [String] parameter22_value Parameter value + # @param [String] parameter23_name Parameter name + # @param [String] parameter23_value Parameter value + # @param [String] parameter24_name Parameter name + # @param [String] parameter24_value Parameter value + # @param [String] parameter25_name Parameter name + # @param [String] parameter25_value Parameter value + # @param [String] parameter26_name Parameter name + # @param [String] parameter26_value Parameter value + # @param [String] parameter27_name Parameter name + # @param [String] parameter27_value Parameter value + # @param [String] parameter28_name Parameter name + # @param [String] parameter28_value Parameter value + # @param [String] parameter29_name Parameter name + # @param [String] parameter29_value Parameter value + # @param [String] parameter30_name Parameter name + # @param [String] parameter30_value Parameter value + # @param [String] parameter31_name Parameter name + # @param [String] parameter31_value Parameter value + # @param [String] parameter32_name Parameter name + # @param [String] parameter32_value Parameter value + # @param [String] parameter33_name Parameter name + # @param [String] parameter33_value Parameter value + # @param [String] parameter34_name Parameter name + # @param [String] parameter34_value Parameter value + # @param [String] parameter35_name Parameter name + # @param [String] parameter35_value Parameter value + # @param [String] parameter36_name Parameter name + # @param [String] parameter36_value Parameter value + # @param [String] parameter37_name Parameter name + # @param [String] parameter37_value Parameter value + # @param [String] parameter38_name Parameter name + # @param [String] parameter38_value Parameter value + # @param [String] parameter39_name Parameter name + # @param [String] parameter39_value Parameter value + # @param [String] parameter40_name Parameter name + # @param [String] parameter40_value Parameter value + # @param [String] parameter41_name Parameter name + # @param [String] parameter41_value Parameter value + # @param [String] parameter42_name Parameter name + # @param [String] parameter42_value Parameter value + # @param [String] parameter43_name Parameter name + # @param [String] parameter43_value Parameter value + # @param [String] parameter44_name Parameter name + # @param [String] parameter44_value Parameter value + # @param [String] parameter45_name Parameter name + # @param [String] parameter45_value Parameter value + # @param [String] parameter46_name Parameter name + # @param [String] parameter46_value Parameter value + # @param [String] parameter47_name Parameter name + # @param [String] parameter47_value Parameter value + # @param [String] parameter48_name Parameter name + # @param [String] parameter48_value Parameter value + # @param [String] parameter49_name Parameter name + # @param [String] parameter49_value Parameter value + # @param [String] parameter50_name Parameter name + # @param [String] parameter50_value Parameter value + # @param [String] parameter51_name Parameter name + # @param [String] parameter51_value Parameter value + # @param [String] parameter52_name Parameter name + # @param [String] parameter52_value Parameter value + # @param [String] parameter53_name Parameter name + # @param [String] parameter53_value Parameter value + # @param [String] parameter54_name Parameter name + # @param [String] parameter54_value Parameter value + # @param [String] parameter55_name Parameter name + # @param [String] parameter55_value Parameter value + # @param [String] parameter56_name Parameter name + # @param [String] parameter56_value Parameter value + # @param [String] parameter57_name Parameter name + # @param [String] parameter57_value Parameter value + # @param [String] parameter58_name Parameter name + # @param [String] parameter58_value Parameter value + # @param [String] parameter59_name Parameter name + # @param [String] parameter59_value Parameter value + # @param [String] parameter60_name Parameter name + # @param [String] parameter60_value Parameter value + # @param [String] parameter61_name Parameter name + # @param [String] parameter61_value Parameter value + # @param [String] parameter62_name Parameter name + # @param [String] parameter62_value Parameter value + # @param [String] parameter63_name Parameter name + # @param [String] parameter63_value Parameter value + # @param [String] parameter64_name Parameter name + # @param [String] parameter64_value Parameter value + # @param [String] parameter65_name Parameter name + # @param [String] parameter65_value Parameter value + # @param [String] parameter66_name Parameter name + # @param [String] parameter66_value Parameter value + # @param [String] parameter67_name Parameter name + # @param [String] parameter67_value Parameter value + # @param [String] parameter68_name Parameter name + # @param [String] parameter68_value Parameter value + # @param [String] parameter69_name Parameter name + # @param [String] parameter69_value Parameter value + # @param [String] parameter70_name Parameter name + # @param [String] parameter70_value Parameter value + # @param [String] parameter71_name Parameter name + # @param [String] parameter71_value Parameter value + # @param [String] parameter72_name Parameter name + # @param [String] parameter72_value Parameter value + # @param [String] parameter73_name Parameter name + # @param [String] parameter73_value Parameter value + # @param [String] parameter74_name Parameter name + # @param [String] parameter74_value Parameter value + # @param [String] parameter75_name Parameter name + # @param [String] parameter75_value Parameter value + # @param [String] parameter76_name Parameter name + # @param [String] parameter76_value Parameter value + # @param [String] parameter77_name Parameter name + # @param [String] parameter77_value Parameter value + # @param [String] parameter78_name Parameter name + # @param [String] parameter78_value Parameter value + # @param [String] parameter79_name Parameter name + # @param [String] parameter79_value Parameter value + # @param [String] parameter80_name Parameter name + # @param [String] parameter80_value Parameter value + # @param [String] parameter81_name Parameter name + # @param [String] parameter81_value Parameter value + # @param [String] parameter82_name Parameter name + # @param [String] parameter82_value Parameter value + # @param [String] parameter83_name Parameter name + # @param [String] parameter83_value Parameter value + # @param [String] parameter84_name Parameter name + # @param [String] parameter84_value Parameter value + # @param [String] parameter85_name Parameter name + # @param [String] parameter85_value Parameter value + # @param [String] parameter86_name Parameter name + # @param [String] parameter86_value Parameter value + # @param [String] parameter87_name Parameter name + # @param [String] parameter87_value Parameter value + # @param [String] parameter88_name Parameter name + # @param [String] parameter88_value Parameter value + # @param [String] parameter89_name Parameter name + # @param [String] parameter89_value Parameter value + # @param [String] parameter90_name Parameter name + # @param [String] parameter90_value Parameter value + # @param [String] parameter91_name Parameter name + # @param [String] parameter91_value Parameter value + # @param [String] parameter92_name Parameter name + # @param [String] parameter92_value Parameter value + # @param [String] parameter93_name Parameter name + # @param [String] parameter93_value Parameter value + # @param [String] parameter94_name Parameter name + # @param [String] parameter94_value Parameter value + # @param [String] parameter95_name Parameter name + # @param [String] parameter95_value Parameter value + # @param [String] parameter96_name Parameter name + # @param [String] parameter96_value Parameter value + # @param [String] parameter97_name Parameter name + # @param [String] parameter97_value Parameter value + # @param [String] parameter98_name Parameter name + # @param [String] parameter98_value Parameter value + # @param [String] parameter99_name Parameter name + # @param [String] parameter99_value Parameter value + # @return [StreamInstance] Created StreamInstance + def create(url: nil, name: :unset, track: :unset, status_callback: :unset, status_callback_method: :unset, parameter1_name: :unset, parameter1_value: :unset, parameter2_name: :unset, parameter2_value: :unset, parameter3_name: :unset, parameter3_value: :unset, parameter4_name: :unset, parameter4_value: :unset, parameter5_name: :unset, parameter5_value: :unset, parameter6_name: :unset, parameter6_value: :unset, parameter7_name: :unset, parameter7_value: :unset, parameter8_name: :unset, parameter8_value: :unset, parameter9_name: :unset, parameter9_value: :unset, parameter10_name: :unset, parameter10_value: :unset, parameter11_name: :unset, parameter11_value: :unset, parameter12_name: :unset, parameter12_value: :unset, parameter13_name: :unset, parameter13_value: :unset, parameter14_name: :unset, parameter14_value: :unset, parameter15_name: :unset, parameter15_value: :unset, parameter16_name: :unset, parameter16_value: :unset, parameter17_name: :unset, parameter17_value: :unset, parameter18_name: :unset, parameter18_value: :unset, parameter19_name: :unset, parameter19_value: :unset, parameter20_name: :unset, parameter20_value: :unset, parameter21_name: :unset, parameter21_value: :unset, parameter22_name: :unset, parameter22_value: :unset, parameter23_name: :unset, parameter23_value: :unset, parameter24_name: :unset, parameter24_value: :unset, parameter25_name: :unset, parameter25_value: :unset, parameter26_name: :unset, parameter26_value: :unset, parameter27_name: :unset, parameter27_value: :unset, parameter28_name: :unset, parameter28_value: :unset, parameter29_name: :unset, parameter29_value: :unset, parameter30_name: :unset, parameter30_value: :unset, parameter31_name: :unset, parameter31_value: :unset, parameter32_name: :unset, parameter32_value: :unset, parameter33_name: :unset, parameter33_value: :unset, parameter34_name: :unset, parameter34_value: :unset, parameter35_name: :unset, parameter35_value: :unset, parameter36_name: :unset, parameter36_value: :unset, parameter37_name: :unset, parameter37_value: :unset, parameter38_name: :unset, parameter38_value: :unset, parameter39_name: :unset, parameter39_value: :unset, parameter40_name: :unset, parameter40_value: :unset, parameter41_name: :unset, parameter41_value: :unset, parameter42_name: :unset, parameter42_value: :unset, parameter43_name: :unset, parameter43_value: :unset, parameter44_name: :unset, parameter44_value: :unset, parameter45_name: :unset, parameter45_value: :unset, parameter46_name: :unset, parameter46_value: :unset, parameter47_name: :unset, parameter47_value: :unset, parameter48_name: :unset, parameter48_value: :unset, parameter49_name: :unset, parameter49_value: :unset, parameter50_name: :unset, parameter50_value: :unset, parameter51_name: :unset, parameter51_value: :unset, parameter52_name: :unset, parameter52_value: :unset, parameter53_name: :unset, parameter53_value: :unset, parameter54_name: :unset, parameter54_value: :unset, parameter55_name: :unset, parameter55_value: :unset, parameter56_name: :unset, parameter56_value: :unset, parameter57_name: :unset, parameter57_value: :unset, parameter58_name: :unset, parameter58_value: :unset, parameter59_name: :unset, parameter59_value: :unset, parameter60_name: :unset, parameter60_value: :unset, parameter61_name: :unset, parameter61_value: :unset, parameter62_name: :unset, parameter62_value: :unset, parameter63_name: :unset, parameter63_value: :unset, parameter64_name: :unset, parameter64_value: :unset, parameter65_name: :unset, parameter65_value: :unset, parameter66_name: :unset, parameter66_value: :unset, parameter67_name: :unset, parameter67_value: :unset, parameter68_name: :unset, parameter68_value: :unset, parameter69_name: :unset, parameter69_value: :unset, parameter70_name: :unset, parameter70_value: :unset, parameter71_name: :unset, parameter71_value: :unset, parameter72_name: :unset, parameter72_value: :unset, parameter73_name: :unset, parameter73_value: :unset, parameter74_name: :unset, parameter74_value: :unset, parameter75_name: :unset, parameter75_value: :unset, parameter76_name: :unset, parameter76_value: :unset, parameter77_name: :unset, parameter77_value: :unset, parameter78_name: :unset, parameter78_value: :unset, parameter79_name: :unset, parameter79_value: :unset, parameter80_name: :unset, parameter80_value: :unset, parameter81_name: :unset, parameter81_value: :unset, parameter82_name: :unset, parameter82_value: :unset, parameter83_name: :unset, parameter83_value: :unset, parameter84_name: :unset, parameter84_value: :unset, parameter85_name: :unset, parameter85_value: :unset, parameter86_name: :unset, parameter86_value: :unset, parameter87_name: :unset, parameter87_value: :unset, parameter88_name: :unset, parameter88_value: :unset, parameter89_name: :unset, parameter89_value: :unset, parameter90_name: :unset, parameter90_value: :unset, parameter91_name: :unset, parameter91_value: :unset, parameter92_name: :unset, parameter92_value: :unset, parameter93_name: :unset, parameter93_value: :unset, parameter94_name: :unset, parameter94_value: :unset, parameter95_name: :unset, parameter95_value: :unset, parameter96_name: :unset, parameter96_value: :unset, parameter97_name: :unset, parameter97_value: :unset, parameter98_name: :unset, parameter98_value: :unset, parameter99_name: :unset, parameter99_value: :unset) + data = Twilio::Values.of({ + 'Url' => url, + 'Name' => name, + 'Track' => track, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'Parameter1.Name' => parameter1_name, + 'Parameter1.Value' => parameter1_value, + 'Parameter2.Name' => parameter2_name, + 'Parameter2.Value' => parameter2_value, + 'Parameter3.Name' => parameter3_name, + 'Parameter3.Value' => parameter3_value, + 'Parameter4.Name' => parameter4_name, + 'Parameter4.Value' => parameter4_value, + 'Parameter5.Name' => parameter5_name, + 'Parameter5.Value' => parameter5_value, + 'Parameter6.Name' => parameter6_name, + 'Parameter6.Value' => parameter6_value, + 'Parameter7.Name' => parameter7_name, + 'Parameter7.Value' => parameter7_value, + 'Parameter8.Name' => parameter8_name, + 'Parameter8.Value' => parameter8_value, + 'Parameter9.Name' => parameter9_name, + 'Parameter9.Value' => parameter9_value, + 'Parameter10.Name' => parameter10_name, + 'Parameter10.Value' => parameter10_value, + 'Parameter11.Name' => parameter11_name, + 'Parameter11.Value' => parameter11_value, + 'Parameter12.Name' => parameter12_name, + 'Parameter12.Value' => parameter12_value, + 'Parameter13.Name' => parameter13_name, + 'Parameter13.Value' => parameter13_value, + 'Parameter14.Name' => parameter14_name, + 'Parameter14.Value' => parameter14_value, + 'Parameter15.Name' => parameter15_name, + 'Parameter15.Value' => parameter15_value, + 'Parameter16.Name' => parameter16_name, + 'Parameter16.Value' => parameter16_value, + 'Parameter17.Name' => parameter17_name, + 'Parameter17.Value' => parameter17_value, + 'Parameter18.Name' => parameter18_name, + 'Parameter18.Value' => parameter18_value, + 'Parameter19.Name' => parameter19_name, + 'Parameter19.Value' => parameter19_value, + 'Parameter20.Name' => parameter20_name, + 'Parameter20.Value' => parameter20_value, + 'Parameter21.Name' => parameter21_name, + 'Parameter21.Value' => parameter21_value, + 'Parameter22.Name' => parameter22_name, + 'Parameter22.Value' => parameter22_value, + 'Parameter23.Name' => parameter23_name, + 'Parameter23.Value' => parameter23_value, + 'Parameter24.Name' => parameter24_name, + 'Parameter24.Value' => parameter24_value, + 'Parameter25.Name' => parameter25_name, + 'Parameter25.Value' => parameter25_value, + 'Parameter26.Name' => parameter26_name, + 'Parameter26.Value' => parameter26_value, + 'Parameter27.Name' => parameter27_name, + 'Parameter27.Value' => parameter27_value, + 'Parameter28.Name' => parameter28_name, + 'Parameter28.Value' => parameter28_value, + 'Parameter29.Name' => parameter29_name, + 'Parameter29.Value' => parameter29_value, + 'Parameter30.Name' => parameter30_name, + 'Parameter30.Value' => parameter30_value, + 'Parameter31.Name' => parameter31_name, + 'Parameter31.Value' => parameter31_value, + 'Parameter32.Name' => parameter32_name, + 'Parameter32.Value' => parameter32_value, + 'Parameter33.Name' => parameter33_name, + 'Parameter33.Value' => parameter33_value, + 'Parameter34.Name' => parameter34_name, + 'Parameter34.Value' => parameter34_value, + 'Parameter35.Name' => parameter35_name, + 'Parameter35.Value' => parameter35_value, + 'Parameter36.Name' => parameter36_name, + 'Parameter36.Value' => parameter36_value, + 'Parameter37.Name' => parameter37_name, + 'Parameter37.Value' => parameter37_value, + 'Parameter38.Name' => parameter38_name, + 'Parameter38.Value' => parameter38_value, + 'Parameter39.Name' => parameter39_name, + 'Parameter39.Value' => parameter39_value, + 'Parameter40.Name' => parameter40_name, + 'Parameter40.Value' => parameter40_value, + 'Parameter41.Name' => parameter41_name, + 'Parameter41.Value' => parameter41_value, + 'Parameter42.Name' => parameter42_name, + 'Parameter42.Value' => parameter42_value, + 'Parameter43.Name' => parameter43_name, + 'Parameter43.Value' => parameter43_value, + 'Parameter44.Name' => parameter44_name, + 'Parameter44.Value' => parameter44_value, + 'Parameter45.Name' => parameter45_name, + 'Parameter45.Value' => parameter45_value, + 'Parameter46.Name' => parameter46_name, + 'Parameter46.Value' => parameter46_value, + 'Parameter47.Name' => parameter47_name, + 'Parameter47.Value' => parameter47_value, + 'Parameter48.Name' => parameter48_name, + 'Parameter48.Value' => parameter48_value, + 'Parameter49.Name' => parameter49_name, + 'Parameter49.Value' => parameter49_value, + 'Parameter50.Name' => parameter50_name, + 'Parameter50.Value' => parameter50_value, + 'Parameter51.Name' => parameter51_name, + 'Parameter51.Value' => parameter51_value, + 'Parameter52.Name' => parameter52_name, + 'Parameter52.Value' => parameter52_value, + 'Parameter53.Name' => parameter53_name, + 'Parameter53.Value' => parameter53_value, + 'Parameter54.Name' => parameter54_name, + 'Parameter54.Value' => parameter54_value, + 'Parameter55.Name' => parameter55_name, + 'Parameter55.Value' => parameter55_value, + 'Parameter56.Name' => parameter56_name, + 'Parameter56.Value' => parameter56_value, + 'Parameter57.Name' => parameter57_name, + 'Parameter57.Value' => parameter57_value, + 'Parameter58.Name' => parameter58_name, + 'Parameter58.Value' => parameter58_value, + 'Parameter59.Name' => parameter59_name, + 'Parameter59.Value' => parameter59_value, + 'Parameter60.Name' => parameter60_name, + 'Parameter60.Value' => parameter60_value, + 'Parameter61.Name' => parameter61_name, + 'Parameter61.Value' => parameter61_value, + 'Parameter62.Name' => parameter62_name, + 'Parameter62.Value' => parameter62_value, + 'Parameter63.Name' => parameter63_name, + 'Parameter63.Value' => parameter63_value, + 'Parameter64.Name' => parameter64_name, + 'Parameter64.Value' => parameter64_value, + 'Parameter65.Name' => parameter65_name, + 'Parameter65.Value' => parameter65_value, + 'Parameter66.Name' => parameter66_name, + 'Parameter66.Value' => parameter66_value, + 'Parameter67.Name' => parameter67_name, + 'Parameter67.Value' => parameter67_value, + 'Parameter68.Name' => parameter68_name, + 'Parameter68.Value' => parameter68_value, + 'Parameter69.Name' => parameter69_name, + 'Parameter69.Value' => parameter69_value, + 'Parameter70.Name' => parameter70_name, + 'Parameter70.Value' => parameter70_value, + 'Parameter71.Name' => parameter71_name, + 'Parameter71.Value' => parameter71_value, + 'Parameter72.Name' => parameter72_name, + 'Parameter72.Value' => parameter72_value, + 'Parameter73.Name' => parameter73_name, + 'Parameter73.Value' => parameter73_value, + 'Parameter74.Name' => parameter74_name, + 'Parameter74.Value' => parameter74_value, + 'Parameter75.Name' => parameter75_name, + 'Parameter75.Value' => parameter75_value, + 'Parameter76.Name' => parameter76_name, + 'Parameter76.Value' => parameter76_value, + 'Parameter77.Name' => parameter77_name, + 'Parameter77.Value' => parameter77_value, + 'Parameter78.Name' => parameter78_name, + 'Parameter78.Value' => parameter78_value, + 'Parameter79.Name' => parameter79_name, + 'Parameter79.Value' => parameter79_value, + 'Parameter80.Name' => parameter80_name, + 'Parameter80.Value' => parameter80_value, + 'Parameter81.Name' => parameter81_name, + 'Parameter81.Value' => parameter81_value, + 'Parameter82.Name' => parameter82_name, + 'Parameter82.Value' => parameter82_value, + 'Parameter83.Name' => parameter83_name, + 'Parameter83.Value' => parameter83_value, + 'Parameter84.Name' => parameter84_name, + 'Parameter84.Value' => parameter84_value, + 'Parameter85.Name' => parameter85_name, + 'Parameter85.Value' => parameter85_value, + 'Parameter86.Name' => parameter86_name, + 'Parameter86.Value' => parameter86_value, + 'Parameter87.Name' => parameter87_name, + 'Parameter87.Value' => parameter87_value, + 'Parameter88.Name' => parameter88_name, + 'Parameter88.Value' => parameter88_value, + 'Parameter89.Name' => parameter89_name, + 'Parameter89.Value' => parameter89_value, + 'Parameter90.Name' => parameter90_name, + 'Parameter90.Value' => parameter90_value, + 'Parameter91.Name' => parameter91_name, + 'Parameter91.Value' => parameter91_value, + 'Parameter92.Name' => parameter92_name, + 'Parameter92.Value' => parameter92_value, + 'Parameter93.Name' => parameter93_name, + 'Parameter93.Value' => parameter93_value, + 'Parameter94.Name' => parameter94_name, + 'Parameter94.Value' => parameter94_value, + 'Parameter95.Name' => parameter95_name, + 'Parameter95.Value' => parameter95_value, + 'Parameter96.Name' => parameter96_name, + 'Parameter96.Value' => parameter96_value, + 'Parameter97.Name' => parameter97_name, + 'Parameter97.Value' => parameter97_value, + 'Parameter98.Name' => parameter98_name, + 'Parameter98.Value' => parameter98_value, + 'Parameter99.Name' => parameter99_name, + 'Parameter99.Value' => parameter99_value, + }) + + payload = @version.create('POST', @uri, data: data) + + StreamInstance.new( + @version, + payload, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class StreamPage < Page + ## + # Initialize the StreamPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [StreamPage] StreamPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of StreamInstance + # @param [Hash] payload Payload response from the API + # @return [StreamInstance] StreamInstance + def get_instance(payload) + StreamInstance.new( + @version, + payload, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class StreamContext < InstanceContext + ## + # Initialize the StreamContext + # @param [Version] version Version that contains the resource + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Stream + # resource. + # @param [String] call_sid The SID of the + # {Call}[https://www.twilio.com/docs/voice/api/call-resource] the Stream resource + # is associated with. + # @param [String] sid The SID of the Stream resource, or the `name` used when + # creating the resource + # @return [StreamContext] StreamContext + def initialize(version, account_sid, call_sid, sid) + super(version) + + # Path Solution + @solution = {account_sid: account_sid, call_sid: call_sid, sid: sid, } + @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/Streams/#{@solution[:sid]}.json" + end + + ## + # Update the StreamInstance + # @param [stream.UpdateStatus] status The status. Must have the value `stopped` + # @return [StreamInstance] Updated StreamInstance + def update(status: nil) + data = Twilio::Values.of({'Status' => status, }) + + payload = @version.update('POST', @uri, data: data) + + StreamInstance.new( + @version, + payload, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class StreamInstance < InstanceResource + ## + # Initialize the StreamInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Stream + # resource. + # @param [String] call_sid The SID of the + # {Call}[https://www.twilio.com/docs/voice/api/call-resource] the Stream resource + # is associated with. + # @param [String] sid The SID of the Stream resource, or the `name` used when + # creating the resource + # @return [StreamInstance] StreamInstance + def initialize(version, payload, account_sid: nil, call_sid: nil, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'account_sid' => payload['account_sid'], + 'call_sid' => payload['call_sid'], + 'name' => payload['name'], + 'status' => payload['status'], + 'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']), + 'uri' => payload['uri'], + } + + # Context + @instance_context = nil + @params = {'account_sid' => account_sid, 'call_sid' => call_sid, 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [StreamContext] StreamContext for this StreamInstance + def context + unless @instance_context + @instance_context = StreamContext.new( + @version, + @params['account_sid'], + @params['call_sid'], + @params['sid'], + ) + end + @instance_context + end + + ## + # @return [String] The SID of the Stream resource. + def sid + @properties['sid'] + end + + ## + # @return [String] The SID of the Account that created this resource + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] The SID of the Call the resource is associated with + def call_sid + @properties['call_sid'] + end + + ## + # @return [String] The name of this resource + def name + @properties['name'] + end + + ## + # @return [stream.Status] The status - one of `stopped`, `in-progress` + def status + @properties['status'] + end + + ## + # @return [Time] The RFC 2822 date and time in GMT that this resource was last updated + def date_updated + @properties['date_updated'] + end + + ## + # @return [String] The URI of the resource, relative to `https://api.twilio.com` + def uri + @properties['uri'] + end + + ## + # Update the StreamInstance + # @param [stream.UpdateStatus] status The status. Must have the value `stopped` + # @return [StreamInstance] Updated StreamInstance + def update(status: nil) + context.update(status: status, ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/api/v2010/account/recording.rb b/lib/twilio-ruby/rest/api/v2010/account/recording.rb index b7588b090..ab3f780c5 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/recording.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/recording.rb @@ -39,6 +39,9 @@ def initialize(version, account_sid: nil) # to read. # @param [String] conference_sid The Conference SID that identifies the conference # associated with the recording to read. + # @param [Boolean] include_soft_deleted A boolean parameter indicating whether to + # retrieve soft deleted recordings or not. Recordings metadata are kept after + # deletion for a retention period of 40 days. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size Number of records to fetch per request, when @@ -46,13 +49,14 @@ def initialize(version, account_sid: nil) # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Array] Array of up to limit results - def list(date_created_before: :unset, date_created: :unset, date_created_after: :unset, call_sid: :unset, conference_sid: :unset, limit: nil, page_size: nil) + def list(date_created_before: :unset, date_created: :unset, date_created_after: :unset, call_sid: :unset, conference_sid: :unset, include_soft_deleted: :unset, limit: nil, page_size: nil) self.stream( date_created_before: date_created_before, date_created: date_created, date_created_after: date_created_after, call_sid: call_sid, conference_sid: conference_sid, + include_soft_deleted: include_soft_deleted, limit: limit, page_size: page_size ).entries @@ -70,6 +74,9 @@ def list(date_created_before: :unset, date_created: :unset, date_created_after: # to read. # @param [String] conference_sid The Conference SID that identifies the conference # associated with the recording to read. + # @param [Boolean] include_soft_deleted A boolean parameter indicating whether to + # retrieve soft deleted recordings or not. Recordings metadata are kept after + # deletion for a retention period of 40 days. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit. # @param [Integer] page_size Number of records to fetch per request, when @@ -77,7 +84,7 @@ def list(date_created_before: :unset, date_created: :unset, date_created_after: # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Enumerable] Enumerable that will yield up to limit results - def stream(date_created_before: :unset, date_created: :unset, date_created_after: :unset, call_sid: :unset, conference_sid: :unset, limit: nil, page_size: nil) + def stream(date_created_before: :unset, date_created: :unset, date_created_after: :unset, call_sid: :unset, conference_sid: :unset, include_soft_deleted: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( @@ -86,6 +93,7 @@ def stream(date_created_before: :unset, date_created: :unset, date_created_after date_created_after: date_created_after, call_sid: call_sid, conference_sid: conference_sid, + include_soft_deleted: include_soft_deleted, page_size: limits[:page_size], ) @@ -117,17 +125,21 @@ def each # to read. # @param [String] conference_sid The Conference SID that identifies the conference # associated with the recording to read. + # @param [Boolean] include_soft_deleted A boolean parameter indicating whether to + # retrieve soft deleted recordings or not. Recordings metadata are kept after + # deletion for a retention period of 40 days. # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 # @return [Page] Page of RecordingInstance - def page(date_created_before: :unset, date_created: :unset, date_created_after: :unset, call_sid: :unset, conference_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + def page(date_created_before: :unset, date_created: :unset, date_created_after: :unset, call_sid: :unset, conference_sid: :unset, include_soft_deleted: :unset, page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'DateCreated<' => Twilio.serialize_iso8601_datetime(date_created_before), 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 'DateCreated>' => Twilio.serialize_iso8601_datetime(date_created_after), 'CallSid' => call_sid, 'ConferenceSid' => conference_sid, + 'IncludeSoftDeleted' => include_soft_deleted, 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, @@ -211,9 +223,14 @@ def initialize(version, account_sid, sid) ## # Fetch the RecordingInstance + # @param [Boolean] include_soft_deleted A boolean parameter indicating whether to + # retrieve soft deleted recordings or not. Recordings metadata are kept after + # deletion for a retention period of 40 days. # @return [RecordingInstance] Fetched RecordingInstance - def fetch - payload = @version.fetch('GET', @uri) + def fetch(include_soft_deleted: :unset) + params = Twilio::Values.of({'IncludeSoftDeleted' => include_soft_deleted, }) + + payload = @version.fetch('GET', @uri, params: params) RecordingInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], ) end @@ -446,9 +463,12 @@ def subresource_uris ## # Fetch the RecordingInstance + # @param [Boolean] include_soft_deleted A boolean parameter indicating whether to + # retrieve soft deleted recordings or not. Recordings metadata are kept after + # deletion for a retention period of 40 days. # @return [RecordingInstance] Fetched RecordingInstance - def fetch - context.fetch + def fetch(include_soft_deleted: :unset) + context.fetch(include_soft_deleted: include_soft_deleted, ) end ## diff --git a/lib/twilio-ruby/rest/chat.rb b/lib/twilio-ruby/rest/chat.rb index 3ac3efe24..1753f5419 100644 --- a/lib/twilio-ruby/rest/chat.rb +++ b/lib/twilio-ruby/rest/chat.rb @@ -21,6 +21,7 @@ def initialize(twilio) # Versions @v1 = nil @v2 = nil + @v3 = nil end ## @@ -35,6 +36,12 @@ def v2 @v2 ||= V2.new self end + ## + # Version v3 of chat + def v3 + @v3 ||= V3.new self + end + ## # @param [String] sid The unique string that we created to identify the Credential # resource. @@ -53,6 +60,15 @@ def services(sid=:unset) self.v2.services(sid) end + ## + # @param [String] sid The unique string that we created to identify the Channel + # resource. + # @return [Twilio::REST::Chat::V3::ChannelInstance] if sid was passed. + # @return [Twilio::REST::Chat::V3::ChannelList] + def channels(service_sid=:unset, sid=:unset) + self.v3.channels(service_sid, sid) + end + ## # Provide a user friendly representation def to_s diff --git a/lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb b/lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb index 2a5c3ee2b..712a166bf 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb @@ -193,9 +193,13 @@ def fetch ## # Delete the UserChannelInstance + # @param [user_channel.WebhookEnabledType] x_twilio_webhook_enabled The + # X-Twilio-Webhook-Enabled HTTP request header # @return [Boolean] true if delete succeeds, false otherwise - def delete - @version.delete('DELETE', @uri) + def delete(x_twilio_webhook_enabled: :unset) + headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + @version.delete('DELETE', @uri, headers: headers) end ## @@ -377,9 +381,11 @@ def fetch ## # Delete the UserChannelInstance + # @param [user_channel.WebhookEnabledType] x_twilio_webhook_enabled The + # X-Twilio-Webhook-Enabled HTTP request header # @return [Boolean] true if delete succeeds, false otherwise - def delete - context.delete + def delete(x_twilio_webhook_enabled: :unset) + context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, ) end ## diff --git a/lib/twilio-ruby/rest/chat/v3.rb b/lib/twilio-ruby/rest/chat/v3.rb new file mode 100644 index 000000000..c06a0a324 --- /dev/null +++ b/lib/twilio-ruby/rest/chat/v3.rb @@ -0,0 +1,48 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Chat + class V3 < Version + ## + # Initialize the V3 version of Chat + def initialize(domain) + super + @version = 'v3' + @channels = nil + end + + ## + # @param [String] service_sid The unique SID identifier of the Service. + # @param [String] sid A 34 character string that uniquely identifies this Channel. + # @return [Twilio::REST::Chat::V3::ChannelContext] if sid was passed. + # @return [Twilio::REST::Chat::V3::ChannelList] + def channels(service_sid=:unset, sid=:unset) + if service_sid.nil? + raise ArgumentError, 'service_sid cannot be nil' + end + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + if service_sid == :unset && sid == :unset + @channels ||= ChannelList.new self + else + ChannelContext.new(self, service_sid, sid) + end + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/chat/v3/channel.rb b/lib/twilio-ruby/rest/chat/v3/channel.rb new file mode 100644 index 000000000..3fca5f9f5 --- /dev/null +++ b/lib/twilio-ruby/rest/chat/v3/channel.rb @@ -0,0 +1,275 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Chat < Domain + class V3 < Version + class ChannelList < ListResource + ## + # Initialize the ChannelList + # @param [Version] version Version that contains the resource + # @return [ChannelList] ChannelList + def initialize(version) + super(version) + + # Path Solution + @solution = {} + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class ChannelPage < Page + ## + # Initialize the ChannelPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [ChannelPage] ChannelPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of ChannelInstance + # @param [Hash] payload Payload response from the API + # @return [ChannelInstance] ChannelInstance + def get_instance(payload) + ChannelInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class ChannelContext < InstanceContext + ## + # Initialize the ChannelContext + # @param [Version] version Version that contains the resource + # @param [String] service_sid The unique SID identifier of the Service. + # @param [String] sid A 34 character string that uniquely identifies this Channel. + # @return [ChannelContext] ChannelContext + def initialize(version, service_sid, sid) + super(version) + + # Path Solution + @solution = {service_sid: service_sid, sid: sid, } + @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:sid]}" + end + + ## + # Update the ChannelInstance + # @param [channel.ChannelType] type TThe Type for this Channel to migrate to. Can + # only be `private`. Migration to 'public' is not allowed. + # @param [String] messaging_service_sid The unique ID of the {Messaging + # Service}[https://www.twilio.com/docs/sms/services/api] this channel belongs to. + # @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The + # X-Twilio-Webhook-Enabled HTTP request header + # @return [ChannelInstance] Updated ChannelInstance + def update(type: :unset, messaging_service_sid: :unset, x_twilio_webhook_enabled: :unset) + data = Twilio::Values.of({'Type' => type, 'MessagingServiceSid' => messaging_service_sid, }) + headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + payload = @version.update('POST', @uri, data: data, headers: headers) + + ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class ChannelInstance < InstanceResource + ## + # Initialize the ChannelInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] service_sid The unique SID identifier of the Service. + # @param [String] sid A 34 character string that uniquely identifies this Channel. + # @return [ChannelInstance] ChannelInstance + def initialize(version, payload, service_sid: nil, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'account_sid' => payload['account_sid'], + 'service_sid' => payload['service_sid'], + 'friendly_name' => payload['friendly_name'], + 'unique_name' => payload['unique_name'], + 'attributes' => payload['attributes'], + 'type' => payload['type'], + 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), + 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), + 'created_by' => payload['created_by'], + 'members_count' => payload['members_count'].to_i, + 'messages_count' => payload['messages_count'].to_i, + 'messaging_service_sid' => payload['messaging_service_sid'], + 'url' => payload['url'], + } + + # Context + @instance_context = nil + @params = { + 'service_sid' => service_sid || @properties['service_sid'], + 'sid' => sid || @properties['sid'], + } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [ChannelContext] ChannelContext for this ChannelInstance + def context + unless @instance_context + @instance_context = ChannelContext.new(@version, @params['service_sid'], @params['sid'], ) + end + @instance_context + end + + ## + # @return [String] The unique string that identifies the resource + def sid + @properties['sid'] + end + + ## + # @return [String] The SID of the Account that created the resource + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] The SID of the Service that the resource is associated with + def service_sid + @properties['service_sid'] + end + + ## + # @return [String] The string that you assigned to describe the resource + def friendly_name + @properties['friendly_name'] + end + + ## + # @return [String] An application-defined string that uniquely identifies the resource + def unique_name + @properties['unique_name'] + end + + ## + # @return [String] The JSON string that stores application-specific data + def attributes + @properties['attributes'] + end + + ## + # @return [channel.ChannelType] The visibility of the channel. Can be: `public` or `private` + def type + @properties['type'] + end + + ## + # @return [Time] The ISO 8601 date and time in GMT when the resource was created + def date_created + @properties['date_created'] + end + + ## + # @return [Time] The ISO 8601 date and time in GMT when the resource was last updated + def date_updated + @properties['date_updated'] + end + + ## + # @return [String] The identity of the User that created the channel + def created_by + @properties['created_by'] + end + + ## + # @return [String] The number of Members in the Channel + def members_count + @properties['members_count'] + end + + ## + # @return [String] The number of Messages that have been passed in the Channel + def messages_count + @properties['messages_count'] + end + + ## + # @return [String] The unique ID of the Messaging Service this channel belongs to. + def messaging_service_sid + @properties['messaging_service_sid'] + end + + ## + # @return [String] The absolute URL of the Channel resource + def url + @properties['url'] + end + + ## + # Update the ChannelInstance + # @param [channel.ChannelType] type TThe Type for this Channel to migrate to. Can + # only be `private`. Migration to 'public' is not allowed. + # @param [String] messaging_service_sid The unique ID of the {Messaging + # Service}[https://www.twilio.com/docs/sms/services/api] this channel belongs to. + # @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The + # X-Twilio-Webhook-Enabled HTTP request header + # @return [ChannelInstance] Updated ChannelInstance + def update(type: :unset, messaging_service_sid: :unset, x_twilio_webhook_enabled: :unset) + context.update( + type: type, + messaging_service_sid: messaging_service_sid, + x_twilio_webhook_enabled: x_twilio_webhook_enabled, + ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/conversations.rb b/lib/twilio-ruby/rest/conversations.rb index 34156075d..9147d86b9 100644 --- a/lib/twilio-ruby/rest/conversations.rb +++ b/lib/twilio-ruby/rest/conversations.rb @@ -34,6 +34,15 @@ def configuration self.v1.configuration() end + ## + # @param [String] sid A 34 character string that uniquely identifies this + # resource. + # @return [Twilio::REST::Conversations::V1::AddressConfigurationInstance] if sid was passed. + # @return [Twilio::REST::Conversations::V1::AddressConfigurationList] + def address_configurations(sid=:unset) + self.v1.address_configurations(sid) + end + ## # @param [String] sid A 34 character string that uniquely identifies this # resource. diff --git a/lib/twilio-ruby/rest/conversations/v1.rb b/lib/twilio-ruby/rest/conversations/v1.rb index 7af750233..696fafd20 100644 --- a/lib/twilio-ruby/rest/conversations/v1.rb +++ b/lib/twilio-ruby/rest/conversations/v1.rb @@ -16,6 +16,7 @@ def initialize(domain) super @version = 'v1' @configuration = nil + @address_configurations = nil @conversations = nil @credentials = nil @participant_conversations = nil @@ -30,6 +31,22 @@ def configuration @configuration ||= ConfigurationContext.new self end + ## + # @param [String] sid The SID of the Address Configuration resource. This value + # can be either the `sid` or the `address` of the configuration + # @return [Twilio::REST::Conversations::V1::AddressConfigurationContext] if sid was passed. + # @return [Twilio::REST::Conversations::V1::AddressConfigurationList] + def address_configurations(sid=:unset) + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + if sid == :unset + @address_configurations ||= AddressConfigurationList.new self + else + AddressConfigurationContext.new(self, sid) + end + end + ## # @param [String] sid A 34 character string that uniquely identifies this # resource. Can also be the `unique_name` of the Conversation. diff --git a/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb b/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb new file mode 100644 index 000000000..2a34a274a --- /dev/null +++ b/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb @@ -0,0 +1,447 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Conversations < Domain + class V1 < Version + class AddressConfigurationList < ListResource + ## + # Initialize the AddressConfigurationList + # @param [Version] version Version that contains the resource + # @return [AddressConfigurationList] AddressConfigurationList + def initialize(version) + super(version) + + # Path Solution + @solution = {} + @uri = "/Configuration/Addresses" + end + + ## + # Lists AddressConfigurationInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Array] Array of up to limit results + def list(limit: nil, page_size: nil) + self.stream(limit: limit, page_size: page_size).entries + end + + ## + # Streams AddressConfigurationInstance records from the API as an Enumerable. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit. + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Enumerable] Enumerable that will yield up to limit results + def stream(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields AddressConfigurationInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of AddressConfigurationInstance records from the API. + # Request is executed immediately. + # @param [String] page_token PageToken provided by the API + # @param [Integer] page_number Page Number, this value is simply for client state + # @param [Integer] page_size Number of records to return, defaults to 50 + # @return [Page] Page of AddressConfigurationInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + AddressConfigurationPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of AddressConfigurationInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of AddressConfigurationInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + AddressConfigurationPage.new(@version, response, @solution) + end + + ## + # Create the AddressConfigurationInstance + # @param [address_configuration.Type] type Type of Address. Value can be + # `whatsapp` or `sms`. + # @param [String] address The unique address to be configured. The address can be + # a whatsapp address or phone number + # @param [String] friendly_name The human-readable name of this configuration, + # limited to 256 characters. Optional. + # @param [Boolean] auto_creation_enabled Enable/Disable auto-creating + # conversations for messages to this address + # @param [address_configuration.AutoCreationType] auto_creation_type Type of Auto + # Creation. Value can be one of `webhook`, `studio` or `default`. + # @param [String] auto_creation_conversation_service_sid Conversation Service for + # the auto-created conversation. If not set, the conversation is created in the + # default service. + # @param [String] auto_creation_webhook_url For type `webhook`, the url for the + # webhook request. + # @param [address_configuration.Method] auto_creation_webhook_method For type + # `webhook`, the HTTP method to be used when sending a webhook request. + # @param [Array[String]] auto_creation_webhook_filters The list of events, firing + # webhook event for this Conversation. Values can be any of the following: + # `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, + # `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, + # `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, + # `onDeliveryUpdated` + # @param [String] auto_creation_studio_flow_sid For type `studio`, the studio flow + # SID where the webhook should be sent to. + # @param [String] auto_creation_studio_retry_count For type `studio`, number of + # times to retry the webhook request + # @return [AddressConfigurationInstance] Created AddressConfigurationInstance + def create(type: nil, address: nil, friendly_name: :unset, auto_creation_enabled: :unset, auto_creation_type: :unset, auto_creation_conversation_service_sid: :unset, auto_creation_webhook_url: :unset, auto_creation_webhook_method: :unset, auto_creation_webhook_filters: :unset, auto_creation_studio_flow_sid: :unset, auto_creation_studio_retry_count: :unset) + data = Twilio::Values.of({ + 'Type' => type, + 'Address' => address, + 'FriendlyName' => friendly_name, + 'AutoCreation.Enabled' => auto_creation_enabled, + 'AutoCreation.Type' => auto_creation_type, + 'AutoCreation.ConversationServiceSid' => auto_creation_conversation_service_sid, + 'AutoCreation.WebhookUrl' => auto_creation_webhook_url, + 'AutoCreation.WebhookMethod' => auto_creation_webhook_method, + 'AutoCreation.WebhookFilters' => Twilio.serialize_list(auto_creation_webhook_filters) { |e| e }, + 'AutoCreation.StudioFlowSid' => auto_creation_studio_flow_sid, + 'AutoCreation.StudioRetryCount' => auto_creation_studio_retry_count, + }) + + payload = @version.create('POST', @uri, data: data) + + AddressConfigurationInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class AddressConfigurationPage < Page + ## + # Initialize the AddressConfigurationPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [AddressConfigurationPage] AddressConfigurationPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of AddressConfigurationInstance + # @param [Hash] payload Payload response from the API + # @return [AddressConfigurationInstance] AddressConfigurationInstance + def get_instance(payload) + AddressConfigurationInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class AddressConfigurationContext < InstanceContext + ## + # Initialize the AddressConfigurationContext + # @param [Version] version Version that contains the resource + # @param [String] sid The SID of the Address Configuration resource. This value + # can be either the `sid` or the `address` of the configuration + # @return [AddressConfigurationContext] AddressConfigurationContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = {sid: sid, } + @uri = "/Configuration/Addresses/#{@solution[:sid]}" + end + + ## + # Fetch the AddressConfigurationInstance + # @return [AddressConfigurationInstance] Fetched AddressConfigurationInstance + def fetch + payload = @version.fetch('GET', @uri) + + AddressConfigurationInstance.new(@version, payload, sid: @solution[:sid], ) + end + + ## + # Update the AddressConfigurationInstance + # @param [String] friendly_name The human-readable name of this configuration, + # limited to 256 characters. Optional. + # @param [Boolean] auto_creation_enabled Enable/Disable auto-creating + # conversations for messages to this address + # @param [address_configuration.AutoCreationType] auto_creation_type Type of Auto + # Creation. Value can be one of `webhook`, `studio` or `default`. + # @param [String] auto_creation_conversation_service_sid Conversation Service for + # the auto-created conversation. If not set, the conversation is created in the + # default service. + # @param [String] auto_creation_webhook_url For type `webhook`, the url for the + # webhook request. + # @param [address_configuration.Method] auto_creation_webhook_method For type + # `webhook`, the HTTP method to be used when sending a webhook request. + # @param [Array[String]] auto_creation_webhook_filters The list of events, firing + # webhook event for this Conversation. Values can be any of the following: + # `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, + # `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, + # `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, + # `onDeliveryUpdated` + # @param [String] auto_creation_studio_flow_sid For type `studio`, the studio flow + # SID where the webhook should be sent to. + # @param [String] auto_creation_studio_retry_count For type `studio`, number of + # times to retry the webhook request + # @return [AddressConfigurationInstance] Updated AddressConfigurationInstance + def update(friendly_name: :unset, auto_creation_enabled: :unset, auto_creation_type: :unset, auto_creation_conversation_service_sid: :unset, auto_creation_webhook_url: :unset, auto_creation_webhook_method: :unset, auto_creation_webhook_filters: :unset, auto_creation_studio_flow_sid: :unset, auto_creation_studio_retry_count: :unset) + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'AutoCreation.Enabled' => auto_creation_enabled, + 'AutoCreation.Type' => auto_creation_type, + 'AutoCreation.ConversationServiceSid' => auto_creation_conversation_service_sid, + 'AutoCreation.WebhookUrl' => auto_creation_webhook_url, + 'AutoCreation.WebhookMethod' => auto_creation_webhook_method, + 'AutoCreation.WebhookFilters' => Twilio.serialize_list(auto_creation_webhook_filters) { |e| e }, + 'AutoCreation.StudioFlowSid' => auto_creation_studio_flow_sid, + 'AutoCreation.StudioRetryCount' => auto_creation_studio_retry_count, + }) + + payload = @version.update('POST', @uri, data: data) + + AddressConfigurationInstance.new(@version, payload, sid: @solution[:sid], ) + end + + ## + # Delete the AddressConfigurationInstance + # @return [Boolean] true if delete succeeds, false otherwise + def delete + @version.delete('DELETE', @uri) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class AddressConfigurationInstance < InstanceResource + ## + # Initialize the AddressConfigurationInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] sid The SID of the Address Configuration resource. This value + # can be either the `sid` or the `address` of the configuration + # @return [AddressConfigurationInstance] AddressConfigurationInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'account_sid' => payload['account_sid'], + 'type' => payload['type'], + 'address' => payload['address'], + 'friendly_name' => payload['friendly_name'], + 'auto_creation' => payload['auto_creation'], + 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), + 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), + 'url' => payload['url'], + } + + # Context + @instance_context = nil + @params = {'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [AddressConfigurationContext] AddressConfigurationContext for this AddressConfigurationInstance + def context + unless @instance_context + @instance_context = AddressConfigurationContext.new(@version, @params['sid'], ) + end + @instance_context + end + + ## + # @return [String] A 34 character string that uniquely identifies this resource. + def sid + @properties['sid'] + end + + ## + # @return [String] The unique ID of the Account the address belongs to. + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] Type of Address. + def type + @properties['type'] + end + + ## + # @return [String] The unique address to be configured. + def address + @properties['address'] + end + + ## + # @return [String] The human-readable name of this configuration. + def friendly_name + @properties['friendly_name'] + end + + ## + # @return [Hash] Auto Creation configuration for the address. + def auto_creation + @properties['auto_creation'] + end + + ## + # @return [Time] The date that this resource was created. + def date_created + @properties['date_created'] + end + + ## + # @return [Time] The date that this resource was last updated. + def date_updated + @properties['date_updated'] + end + + ## + # @return [String] An absolute URL for this address configuration. + def url + @properties['url'] + end + + ## + # Fetch the AddressConfigurationInstance + # @return [AddressConfigurationInstance] Fetched AddressConfigurationInstance + def fetch + context.fetch + end + + ## + # Update the AddressConfigurationInstance + # @param [String] friendly_name The human-readable name of this configuration, + # limited to 256 characters. Optional. + # @param [Boolean] auto_creation_enabled Enable/Disable auto-creating + # conversations for messages to this address + # @param [address_configuration.AutoCreationType] auto_creation_type Type of Auto + # Creation. Value can be one of `webhook`, `studio` or `default`. + # @param [String] auto_creation_conversation_service_sid Conversation Service for + # the auto-created conversation. If not set, the conversation is created in the + # default service. + # @param [String] auto_creation_webhook_url For type `webhook`, the url for the + # webhook request. + # @param [address_configuration.Method] auto_creation_webhook_method For type + # `webhook`, the HTTP method to be used when sending a webhook request. + # @param [Array[String]] auto_creation_webhook_filters The list of events, firing + # webhook event for this Conversation. Values can be any of the following: + # `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, + # `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, + # `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, + # `onDeliveryUpdated` + # @param [String] auto_creation_studio_flow_sid For type `studio`, the studio flow + # SID where the webhook should be sent to. + # @param [String] auto_creation_studio_retry_count For type `studio`, number of + # times to retry the webhook request + # @return [AddressConfigurationInstance] Updated AddressConfigurationInstance + def update(friendly_name: :unset, auto_creation_enabled: :unset, auto_creation_type: :unset, auto_creation_conversation_service_sid: :unset, auto_creation_webhook_url: :unset, auto_creation_webhook_method: :unset, auto_creation_webhook_filters: :unset, auto_creation_studio_flow_sid: :unset, auto_creation_studio_retry_count: :unset) + context.update( + friendly_name: friendly_name, + auto_creation_enabled: auto_creation_enabled, + auto_creation_type: auto_creation_type, + auto_creation_conversation_service_sid: auto_creation_conversation_service_sid, + auto_creation_webhook_url: auto_creation_webhook_url, + auto_creation_webhook_method: auto_creation_webhook_method, + auto_creation_webhook_filters: auto_creation_webhook_filters, + auto_creation_studio_flow_sid: auto_creation_studio_flow_sid, + auto_creation_studio_retry_count: auto_creation_studio_retry_count, + ) + end + + ## + # Delete the AddressConfigurationInstance + # @return [Boolean] true if delete succeeds, false otherwise + def delete + context.delete + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/fax/v1/fax.rb b/lib/twilio-ruby/rest/fax/v1/fax.rb index 704b394aa..bec120336 100644 --- a/lib/twilio-ruby/rest/fax/v1/fax.rb +++ b/lib/twilio-ruby/rest/fax/v1/fax.rb @@ -152,57 +152,6 @@ def get_page(target_url) FaxPage.new(@version, response, @solution) end - ## - # Create the FaxInstance - # @param [String] to The phone number to receive the fax in - # {E.164}[https://www.twilio.com/docs/glossary/what-e164] format or the - # recipient's SIP URI. - # @param [String] media_url The URL of the PDF that contains the fax. See our - # {security}[https://www.twilio.com/docs/usage/security] page for information on - # how to ensure the request for your media comes from Twilio. - # @param [fax.Quality] quality The {Fax Quality - # value}[https://www.twilio.com/docs/fax/api/fax-resource#fax-quality-values] that - # describes the fax quality. Can be: `standard`, `fine`, or `superfine` and - # defaults to `fine`. - # @param [String] status_callback The URL we should call using the `POST` method - # to send {status - # information}[https://www.twilio.com/docs/fax/api/fax-resource#fax-status-callback] - # to your application when the status of the fax changes. - # @param [String] from The number the fax was sent from. Can be the phone number - # in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format or the SIP - # `from` value. The caller ID displayed to the recipient uses this value. If this - # is a phone number, it must be a Twilio number or a verified outgoing caller id - # from your account. If `to` is a SIP address, this can be any alphanumeric string - # (and also the characters `+`, `_`, `.`, and `-`), which will be used in the - # `from` header of the SIP request. - # @param [String] sip_auth_username The username to use with the - # `sip_auth_password` to authenticate faxes sent to a SIP address. - # @param [String] sip_auth_password The password to use with `sip_auth_username` - # to authenticate faxes sent to a SIP address. - # @param [Boolean] store_media Whether to store a copy of the sent media on our - # servers for later retrieval. Can be: `true` or `false` and the default is - # `true`. - # @param [String] ttl How long in minutes from when the fax is initiated that we - # should try to send the fax. - # @return [FaxInstance] Created FaxInstance - def create(to: nil, media_url: nil, quality: :unset, status_callback: :unset, from: :unset, sip_auth_username: :unset, sip_auth_password: :unset, store_media: :unset, ttl: :unset) - data = Twilio::Values.of({ - 'To' => to, - 'MediaUrl' => media_url, - 'Quality' => quality, - 'StatusCallback' => status_callback, - 'From' => from, - 'SipAuthUsername' => sip_auth_username, - 'SipAuthPassword' => sip_auth_password, - 'StoreMedia' => store_media, - 'Ttl' => ttl, - }) - - payload = @version.create('POST', @uri, data: data) - - FaxInstance.new(@version, payload, ) - end - ## # Provide a user friendly representation def to_s @@ -270,21 +219,6 @@ def fetch FaxInstance.new(@version, payload, sid: @solution[:sid], ) end - ## - # Update the FaxInstance - # @param [fax.UpdateStatus] status The new - # {status}[https://www.twilio.com/docs/fax/api/fax-resource#fax-status-values] of - # the resource. Can be only `canceled`. This may fail if transmission has already - # started. - # @return [FaxInstance] Updated FaxInstance - def update(status: :unset) - data = Twilio::Values.of({'Status' => status, }) - - payload = @version.update('POST', @uri, data: data) - - FaxInstance.new(@version, payload, sid: @solution[:sid], ) - end - ## # Delete the FaxInstance # @return [Boolean] true if delete succeeds, false otherwise @@ -491,17 +425,6 @@ def fetch context.fetch end - ## - # Update the FaxInstance - # @param [fax.UpdateStatus] status The new - # {status}[https://www.twilio.com/docs/fax/api/fax-resource#fax-status-values] of - # the resource. Can be only `canceled`. This may fail if transmission has already - # started. - # @return [FaxInstance] Updated FaxInstance - def update(status: :unset) - context.update(status: status, ) - end - ## # Delete the FaxInstance # @return [Boolean] true if delete succeeds, false otherwise diff --git a/lib/twilio-ruby/rest/flex_api.rb b/lib/twilio-ruby/rest/flex_api.rb index 8cdeb42d8..7dd218fa9 100644 --- a/lib/twilio-ruby/rest/flex_api.rb +++ b/lib/twilio-ruby/rest/flex_api.rb @@ -52,6 +52,15 @@ def flex_flow(sid=:unset) self.v1.flex_flow(sid) end + ## + # @param [String] sid The unique string created by Twilio to identify an + # Interaction resource. + # @return [Twilio::REST::Flex_api::V1::InteractionInstance] if sid was passed. + # @return [Twilio::REST::Flex_api::V1::InteractionList] + def interaction(sid=:unset) + self.v1.interaction(sid) + end + ## # @param [String] sid The unique string that we created to identify the WebChannel # resource. diff --git a/lib/twilio-ruby/rest/flex_api/v1.rb b/lib/twilio-ruby/rest/flex_api/v1.rb index e3128ee2f..5ddfdee07 100644 --- a/lib/twilio-ruby/rest/flex_api/v1.rb +++ b/lib/twilio-ruby/rest/flex_api/v1.rb @@ -18,6 +18,7 @@ def initialize(domain) @channel = nil @configuration = nil @flex_flow = nil + @interaction = nil @web_channel = nil end @@ -57,6 +58,21 @@ def flex_flow(sid=:unset) end end + ## + # @param [String] sid The SID of the Interaction resource to fetch. + # @return [Twilio::REST::Flex_api::V1::InteractionContext] if sid was passed. + # @return [Twilio::REST::Flex_api::V1::InteractionList] + def interaction(sid=:unset) + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + if sid == :unset + @interaction ||= InteractionList.new self + else + InteractionContext.new(self, sid) + end + end + ## # @param [String] sid The SID of the WebChannel resource to fetch. # @return [Twilio::REST::Flex_api::V1::WebChannelContext] if sid was passed. diff --git a/lib/twilio-ruby/rest/flex_api/v1/configuration.rb b/lib/twilio-ruby/rest/flex_api/v1/configuration.rb index 346f5b154..1ba774207 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/configuration.rb @@ -170,6 +170,7 @@ def initialize(version, payload) 'flex_insights_hr' => payload['flex_insights_hr'], 'flex_insights_drilldown' => payload['flex_insights_drilldown'], 'flex_url' => payload['flex_url'], + 'channel_configs' => payload['channel_configs'], } # Context @@ -440,6 +441,12 @@ def flex_url @properties['flex_url'] end + ## + # @return [Array[Hash]] Flex Conversations channels' attachments configurations + def channel_configs + @properties['channel_configs'] + end + ## # Fetch the ConfigurationInstance # @param [String] ui_version The Pinned UI version of the Configuration resource diff --git a/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb b/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb index f60acf2a0..69a3e9543 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb @@ -115,8 +115,13 @@ def get_page(target_url) # @param [String] friendly_name A descriptive string that you create to describe # the Flex Flow resource. # @param [String] chat_service_sid The SID of the chat service. - # @param [flex_flow.ChannelType] channel_type The channel type. Can be: `web`, - # `facebook`, `sms`, `whatsapp`, `line` or `custom`. + # @param [flex_flow.ChannelType] channel_type The channel type. One of `web`, + # `facebook`, `sms`, `whatsapp`, `line` or `custom`. By default, Studio’s Send to + # Flex widget passes it on to the Task attributes for Tasks created based on this + # Flex Flow. The Task attributes will be used by the Flex UI to render the + # respective Task as appropriate (applying channel-specific design and length + # limits). If `channelType` is `facebook`, `whatsapp` or `line`, the Send to Flex + # widget should set the Task Channel to Programmable Chat. # @param [String] contact_identity The channel contact's Identity. # @param [Boolean] enabled Whether the new Flex Flow is enabled. # @param [flex_flow.IntegrationType] integration_type The software that will @@ -151,10 +156,10 @@ def get_page(target_url) # @param [Boolean] janitor_enabled When enabled, the Messaging Channel Janitor # will remove active Proxy sessions if the associated Task is deleted outside of # the Flex UI. Defaults to `false`. - # @param [String] integration_retry_count The number of times to retry the webhook - # if the first attempt fails. Can be an integer between 0 and 3 (inclusive), - # default is 3. Optional when `integrationType` is `external`, not applicable - # otherwise. + # @param [String] integration_retry_count The number of times to retry the Studio + # Flow or webhook in case of failure. Takes integer values from 0 to 3 with the + # default being 3. Optional when `integrationType` is `studio` or `external`, not + # applicable otherwise. # @return [FlexFlowInstance] Created FlexFlowInstance def create(friendly_name: nil, chat_service_sid: nil, channel_type: nil, contact_identity: :unset, enabled: :unset, integration_type: :unset, integration_flow_sid: :unset, integration_url: :unset, integration_workspace_sid: :unset, integration_workflow_sid: :unset, integration_channel: :unset, integration_timeout: :unset, integration_priority: :unset, integration_creation_on_message: :unset, long_lived: :unset, janitor_enabled: :unset, integration_retry_count: :unset) data = Twilio::Values.of({ @@ -246,8 +251,13 @@ def fetch # @param [String] friendly_name A descriptive string that you create to describe # the Flex Flow resource. # @param [String] chat_service_sid The SID of the chat service. - # @param [flex_flow.ChannelType] channel_type The channel type. Can be: `web`, - # `facebook`, `sms`, `whatsapp`, `line` or `custom`. + # @param [flex_flow.ChannelType] channel_type The channel type. One of `web`, + # `facebook`, `sms`, `whatsapp`, `line` or `custom`. By default, Studio’s Send to + # Flex widget passes it on to the Task attributes for Tasks created based on this + # Flex Flow. The Task attributes will be used by the Flex UI to render the + # respective Task as appropriate (applying channel-specific design and length + # limits). If `channelType` is `facebook`, `whatsapp` or `line`, the Send to Flex + # widget should set the Task Channel to Programmable Chat. # @param [String] contact_identity The channel contact's Identity. # @param [Boolean] enabled Whether the new Flex Flow is enabled. # @param [flex_flow.IntegrationType] integration_type The software that will @@ -282,10 +292,10 @@ def fetch # @param [Boolean] janitor_enabled When enabled, the Messaging Channel Janitor # will remove active Proxy sessions if the associated Task is deleted outside of # the Flex UI. Defaults to `false`. - # @param [String] integration_retry_count The number of times to retry the webhook - # if the first attempt fails. Can be an integer between 0 and 3 (inclusive), - # default is 3. Optional when `integrationType` is `external`, not applicable - # otherwise. + # @param [String] integration_retry_count The number of times to retry the Studio + # Flow or webhook in case of failure. Takes integer values from 0 to 3 with the + # default being 3. Optional when `integrationType` is `studio` or `external`, not + # applicable otherwise. # @return [FlexFlowInstance] Updated FlexFlowInstance def update(friendly_name: :unset, chat_service_sid: :unset, channel_type: :unset, contact_identity: :unset, enabled: :unset, integration_type: :unset, integration_flow_sid: :unset, integration_url: :unset, integration_workspace_sid: :unset, integration_workflow_sid: :unset, integration_channel: :unset, integration_timeout: :unset, integration_priority: :unset, integration_creation_on_message: :unset, long_lived: :unset, janitor_enabled: :unset, integration_retry_count: :unset) data = Twilio::Values.of({ @@ -475,8 +485,13 @@ def fetch # @param [String] friendly_name A descriptive string that you create to describe # the Flex Flow resource. # @param [String] chat_service_sid The SID of the chat service. - # @param [flex_flow.ChannelType] channel_type The channel type. Can be: `web`, - # `facebook`, `sms`, `whatsapp`, `line` or `custom`. + # @param [flex_flow.ChannelType] channel_type The channel type. One of `web`, + # `facebook`, `sms`, `whatsapp`, `line` or `custom`. By default, Studio’s Send to + # Flex widget passes it on to the Task attributes for Tasks created based on this + # Flex Flow. The Task attributes will be used by the Flex UI to render the + # respective Task as appropriate (applying channel-specific design and length + # limits). If `channelType` is `facebook`, `whatsapp` or `line`, the Send to Flex + # widget should set the Task Channel to Programmable Chat. # @param [String] contact_identity The channel contact's Identity. # @param [Boolean] enabled Whether the new Flex Flow is enabled. # @param [flex_flow.IntegrationType] integration_type The software that will @@ -511,10 +526,10 @@ def fetch # @param [Boolean] janitor_enabled When enabled, the Messaging Channel Janitor # will remove active Proxy sessions if the associated Task is deleted outside of # the Flex UI. Defaults to `false`. - # @param [String] integration_retry_count The number of times to retry the webhook - # if the first attempt fails. Can be an integer between 0 and 3 (inclusive), - # default is 3. Optional when `integrationType` is `external`, not applicable - # otherwise. + # @param [String] integration_retry_count The number of times to retry the Studio + # Flow or webhook in case of failure. Takes integer values from 0 to 3 with the + # default being 3. Optional when `integrationType` is `studio` or `external`, not + # applicable otherwise. # @return [FlexFlowInstance] Updated FlexFlowInstance def update(friendly_name: :unset, chat_service_sid: :unset, channel_type: :unset, contact_identity: :unset, enabled: :unset, integration_type: :unset, integration_flow_sid: :unset, integration_url: :unset, integration_workspace_sid: :unset, integration_workflow_sid: :unset, integration_channel: :unset, integration_timeout: :unset, integration_priority: :unset, integration_creation_on_message: :unset, long_lived: :unset, janitor_enabled: :unset, integration_retry_count: :unset) context.update( diff --git a/lib/twilio-ruby/rest/flex_api/v1/interaction.rb b/lib/twilio-ruby/rest/flex_api/v1/interaction.rb new file mode 100644 index 000000000..bf4e1fd1a --- /dev/null +++ b/lib/twilio-ruby/rest/flex_api/v1/interaction.rb @@ -0,0 +1,233 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class FlexApi < Domain + class V1 < Version + class InteractionList < ListResource + ## + # Initialize the InteractionList + # @param [Version] version Version that contains the resource + # @return [InteractionList] InteractionList + def initialize(version) + super(version) + + # Path Solution + @solution = {} + @uri = "/Interactions" + end + + ## + # Create the InteractionInstance + # @param [Hash] channel The Interaction's channel. + # @param [Hash] routing The Interaction's routing logic. + # @return [InteractionInstance] Created InteractionInstance + def create(channel: nil, routing: nil) + data = Twilio::Values.of({ + 'Channel' => Twilio.serialize_object(channel), + 'Routing' => Twilio.serialize_object(routing), + }) + + payload = @version.create('POST', @uri, data: data) + + InteractionInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class InteractionPage < Page + ## + # Initialize the InteractionPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [InteractionPage] InteractionPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of InteractionInstance + # @param [Hash] payload Payload response from the API + # @return [InteractionInstance] InteractionInstance + def get_instance(payload) + InteractionInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class InteractionContext < InstanceContext + ## + # Initialize the InteractionContext + # @param [Version] version Version that contains the resource + # @param [String] sid The SID of the Interaction resource to fetch. + # @return [InteractionContext] InteractionContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = {sid: sid, } + @uri = "/Interactions/#{@solution[:sid]}" + + # Dependents + @channels = nil + end + + ## + # Fetch the InteractionInstance + # @return [InteractionInstance] Fetched InteractionInstance + def fetch + payload = @version.fetch('GET', @uri) + + InteractionInstance.new(@version, payload, sid: @solution[:sid], ) + end + + ## + # Access the channels + # @return [InteractionChannelList] + # @return [InteractionChannelContext] if sid was passed. + def channels(sid=:unset) + raise ArgumentError, 'sid cannot be nil' if sid.nil? + + if sid != :unset + return InteractionChannelContext.new(@version, @solution[:sid], sid, ) + end + + unless @channels + @channels = InteractionChannelList.new(@version, interaction_sid: @solution[:sid], ) + end + + @channels + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class InteractionInstance < InstanceResource + ## + # Initialize the InteractionInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] sid The SID of the Interaction resource to fetch. + # @return [InteractionInstance] InteractionInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'channel' => payload['channel'], + 'routing' => payload['routing'], + 'url' => payload['url'], + 'links' => payload['links'], + } + + # Context + @instance_context = nil + @params = {'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [InteractionContext] InteractionContext for this InteractionInstance + def context + unless @instance_context + @instance_context = InteractionContext.new(@version, @params['sid'], ) + end + @instance_context + end + + ## + # @return [String] The unique string that identifies the resource + def sid + @properties['sid'] + end + + ## + # @return [Hash] The Interaction's channel + def channel + @properties['channel'] + end + + ## + # @return [Hash] The Interaction's routing logic + def routing + @properties['routing'] + end + + ## + # @return [String] The url + def url + @properties['url'] + end + + ## + # @return [String] The links + def links + @properties['links'] + end + + ## + # Fetch the InteractionInstance + # @return [InteractionInstance] Fetched InteractionInstance + def fetch + context.fetch + end + + ## + # Access the channels + # @return [channels] channels + def channels + context.channels + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb new file mode 100644 index 000000000..a7c05f711 --- /dev/null +++ b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb @@ -0,0 +1,377 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class FlexApi < Domain + class V1 < Version + class InteractionContext < InstanceContext + class InteractionChannelList < ListResource + ## + # Initialize the InteractionChannelList + # @param [Version] version Version that contains the resource + # @param [String] interaction_sid The Interaction Sid for this channel. + # @return [InteractionChannelList] InteractionChannelList + def initialize(version, interaction_sid: nil) + super(version) + + # Path Solution + @solution = {interaction_sid: interaction_sid} + @uri = "/Interactions/#{@solution[:interaction_sid]}/Channels" + end + + ## + # Lists InteractionChannelInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Array] Array of up to limit results + def list(limit: nil, page_size: nil) + self.stream(limit: limit, page_size: page_size).entries + end + + ## + # Streams InteractionChannelInstance records from the API as an Enumerable. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit. + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Enumerable] Enumerable that will yield up to limit results + def stream(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields InteractionChannelInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of InteractionChannelInstance records from the API. + # Request is executed immediately. + # @param [String] page_token PageToken provided by the API + # @param [Integer] page_number Page Number, this value is simply for client state + # @param [Integer] page_size Number of records to return, defaults to 50 + # @return [Page] Page of InteractionChannelInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + InteractionChannelPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of InteractionChannelInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of InteractionChannelInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + InteractionChannelPage.new(@version, response, @solution) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class InteractionChannelPage < Page + ## + # Initialize the InteractionChannelPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [InteractionChannelPage] InteractionChannelPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of InteractionChannelInstance + # @param [Hash] payload Payload response from the API + # @return [InteractionChannelInstance] InteractionChannelInstance + def get_instance(payload) + InteractionChannelInstance.new(@version, payload, interaction_sid: @solution[:interaction_sid], ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class InteractionChannelContext < InstanceContext + ## + # Initialize the InteractionChannelContext + # @param [Version] version Version that contains the resource + # @param [String] interaction_sid The Interaction Sid for this channel. + # @param [String] sid The Channel Sid for this Participant. + # @return [InteractionChannelContext] InteractionChannelContext + def initialize(version, interaction_sid, sid) + super(version) + + # Path Solution + @solution = {interaction_sid: interaction_sid, sid: sid, } + @uri = "/Interactions/#{@solution[:interaction_sid]}/Channels/#{@solution[:sid]}" + + # Dependents + @invites = nil + @participants = nil + end + + ## + # Fetch the InteractionChannelInstance + # @return [InteractionChannelInstance] Fetched InteractionChannelInstance + def fetch + payload = @version.fetch('GET', @uri) + + InteractionChannelInstance.new( + @version, + payload, + interaction_sid: @solution[:interaction_sid], + sid: @solution[:sid], + ) + end + + ## + # Update the InteractionChannelInstance + # @param [interaction_channel.Status] status The Interaction Channel's status. Can + # be: `closed` or `wrapup`. + # @param [Hash] routing The Interaction Channel's routing parameters. Optional, + # may contain `status` to set the agent's Reservation state to either `closed` or + # `wrapup`. Default is `wrapup` if unspecified. + # @return [InteractionChannelInstance] Updated InteractionChannelInstance + def update(status: nil, routing: :unset) + data = Twilio::Values.of({'Status' => status, 'Routing' => Twilio.serialize_object(routing), }) + + payload = @version.update('POST', @uri, data: data) + + InteractionChannelInstance.new( + @version, + payload, + interaction_sid: @solution[:interaction_sid], + sid: @solution[:sid], + ) + end + + ## + # Access the invites + # @return [InteractionChannelInviteList] + # @return [InteractionChannelInviteContext] + def invites + unless @invites + @invites = InteractionChannelInviteList.new( + @version, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:sid], + ) + end + + @invites + end + + ## + # Access the participants + # @return [InteractionChannelParticipantList] + # @return [InteractionChannelParticipantContext] if sid was passed. + def participants(sid=:unset) + raise ArgumentError, 'sid cannot be nil' if sid.nil? + + if sid != :unset + return InteractionChannelParticipantContext.new( + @version, + @solution[:interaction_sid], + @solution[:sid], + sid, + ) + end + + unless @participants + @participants = InteractionChannelParticipantList.new( + @version, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:sid], + ) + end + + @participants + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class InteractionChannelInstance < InstanceResource + ## + # Initialize the InteractionChannelInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] interaction_sid The Interaction Sid for this channel. + # @param [String] sid The Channel Sid for this Participant. + # @return [InteractionChannelInstance] InteractionChannelInstance + def initialize(version, payload, interaction_sid: nil, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'interaction_sid' => payload['interaction_sid'], + 'type' => payload['type'], + 'url' => payload['url'], + 'links' => payload['links'], + } + + # Context + @instance_context = nil + @params = {'interaction_sid' => interaction_sid, 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [InteractionChannelContext] InteractionChannelContext for this InteractionChannelInstance + def context + unless @instance_context + @instance_context = InteractionChannelContext.new( + @version, + @params['interaction_sid'], + @params['sid'], + ) + end + @instance_context + end + + ## + # @return [String] The unique string that identifies the resource + def sid + @properties['sid'] + end + + ## + # @return [String] The Interaction Sid for this channel. + def interaction_sid + @properties['interaction_sid'] + end + + ## + # @return [interaction_channel.Type] The Interaction Channel's type. + def type + @properties['type'] + end + + ## + # @return [String] The url + def url + @properties['url'] + end + + ## + # @return [String] The links + def links + @properties['links'] + end + + ## + # Fetch the InteractionChannelInstance + # @return [InteractionChannelInstance] Fetched InteractionChannelInstance + def fetch + context.fetch + end + + ## + # Update the InteractionChannelInstance + # @param [interaction_channel.Status] status The Interaction Channel's status. Can + # be: `closed` or `wrapup`. + # @param [Hash] routing The Interaction Channel's routing parameters. Optional, + # may contain `status` to set the agent's Reservation state to either `closed` or + # `wrapup`. Default is `wrapup` if unspecified. + # @return [InteractionChannelInstance] Updated InteractionChannelInstance + def update(status: nil, routing: :unset) + context.update(status: status, routing: routing, ) + end + + ## + # Access the invites + # @return [invites] invites + def invites + context.invites + end + + ## + # Access the participants + # @return [participants] participants + def participants + context.participants + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.rb b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.rb new file mode 100644 index 000000000..01fff781a --- /dev/null +++ b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.rb @@ -0,0 +1,236 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class FlexApi < Domain + class V1 < Version + class InteractionContext < InstanceContext + class InteractionChannelContext < InstanceContext + class InteractionChannelInviteList < ListResource + ## + # Initialize the InteractionChannelInviteList + # @param [Version] version Version that contains the resource + # @param [String] interaction_sid The interaction_sid + # @param [String] channel_sid The channel_sid + # @return [InteractionChannelInviteList] InteractionChannelInviteList + def initialize(version, interaction_sid: nil, channel_sid: nil) + super(version) + + # Path Solution + @solution = {interaction_sid: interaction_sid, channel_sid: channel_sid} + @uri = "/Interactions/#{@solution[:interaction_sid]}/Channels/#{@solution[:channel_sid]}/Invites" + end + + ## + # Create the InteractionChannelInviteInstance + # @param [Hash] routing The routing + # @return [InteractionChannelInviteInstance] Created InteractionChannelInviteInstance + def create(routing: nil) + data = Twilio::Values.of({'Routing' => Twilio.serialize_object(routing), }) + + payload = @version.create('POST', @uri, data: data) + + InteractionChannelInviteInstance.new( + @version, + payload, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + ) + end + + ## + # Lists InteractionChannelInviteInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Array] Array of up to limit results + def list(limit: nil, page_size: nil) + self.stream(limit: limit, page_size: page_size).entries + end + + ## + # Streams InteractionChannelInviteInstance records from the API as an Enumerable. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit. + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Enumerable] Enumerable that will yield up to limit results + def stream(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields InteractionChannelInviteInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of InteractionChannelInviteInstance records from the API. + # Request is executed immediately. + # @param [String] page_token PageToken provided by the API + # @param [Integer] page_number Page Number, this value is simply for client state + # @param [Integer] page_size Number of records to return, defaults to 50 + # @return [Page] Page of InteractionChannelInviteInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + InteractionChannelInvitePage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of InteractionChannelInviteInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of InteractionChannelInviteInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + InteractionChannelInvitePage.new(@version, response, @solution) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class InteractionChannelInvitePage < Page + ## + # Initialize the InteractionChannelInvitePage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [InteractionChannelInvitePage] InteractionChannelInvitePage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of InteractionChannelInviteInstance + # @param [Hash] payload Payload response from the API + # @return [InteractionChannelInviteInstance] InteractionChannelInviteInstance + def get_instance(payload) + InteractionChannelInviteInstance.new( + @version, + payload, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class InteractionChannelInviteInstance < InstanceResource + ## + # Initialize the InteractionChannelInviteInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] interaction_sid The interaction_sid + # @param [String] channel_sid The channel_sid + # @return [InteractionChannelInviteInstance] InteractionChannelInviteInstance + def initialize(version, payload, interaction_sid: nil, channel_sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'interaction_sid' => payload['interaction_sid'], + 'channel_sid' => payload['channel_sid'], + 'routing' => payload['routing'], + 'url' => payload['url'], + } + end + + ## + # @return [String] The sid + def sid + @properties['sid'] + end + + ## + # @return [String] The interaction_sid + def interaction_sid + @properties['interaction_sid'] + end + + ## + # @return [String] The channel_sid + def channel_sid + @properties['channel_sid'] + end + + ## + # @return [Hash] The routing + def routing + @properties['routing'] + end + + ## + # @return [String] The url + def url + @properties['url'] + end + + ## + # Provide a user friendly representation + def to_s + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + "" + end + end + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.rb b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.rb new file mode 100644 index 000000000..f11a497ae --- /dev/null +++ b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.rb @@ -0,0 +1,330 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class FlexApi < Domain + class V1 < Version + class InteractionContext < InstanceContext + class InteractionChannelContext < InstanceContext + class InteractionChannelParticipantList < ListResource + ## + # Initialize the InteractionChannelParticipantList + # @param [Version] version Version that contains the resource + # @param [String] interaction_sid The Interaction Sid for this channel. + # @param [String] channel_sid The Channel Sid for this Participant. + # @return [InteractionChannelParticipantList] InteractionChannelParticipantList + def initialize(version, interaction_sid: nil, channel_sid: nil) + super(version) + + # Path Solution + @solution = {interaction_sid: interaction_sid, channel_sid: channel_sid} + @uri = "/Interactions/#{@solution[:interaction_sid]}/Channels/#{@solution[:channel_sid]}/Participants" + end + + ## + # Create the InteractionChannelParticipantInstance + # @param [interaction_channel_participant.Type] type Participant type. Can be: + # `agent`, `customer`, `supervisor`, `external` or `unknown`. + # @param [Hash] media_properties JSON representing the Media Properties for the + # new Participant. + # @return [InteractionChannelParticipantInstance] Created InteractionChannelParticipantInstance + def create(type: nil, media_properties: nil) + data = Twilio::Values.of({ + 'Type' => type, + 'MediaProperties' => Twilio.serialize_object(media_properties), + }) + + payload = @version.create('POST', @uri, data: data) + + InteractionChannelParticipantInstance.new( + @version, + payload, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + ) + end + + ## + # Lists InteractionChannelParticipantInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Array] Array of up to limit results + def list(limit: nil, page_size: nil) + self.stream(limit: limit, page_size: page_size).entries + end + + ## + # Streams InteractionChannelParticipantInstance records from the API as an Enumerable. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit. + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Enumerable] Enumerable that will yield up to limit results + def stream(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields InteractionChannelParticipantInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of InteractionChannelParticipantInstance records from the API. + # Request is executed immediately. + # @param [String] page_token PageToken provided by the API + # @param [Integer] page_number Page Number, this value is simply for client state + # @param [Integer] page_size Number of records to return, defaults to 50 + # @return [Page] Page of InteractionChannelParticipantInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + InteractionChannelParticipantPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of InteractionChannelParticipantInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of InteractionChannelParticipantInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + InteractionChannelParticipantPage.new(@version, response, @solution) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class InteractionChannelParticipantPage < Page + ## + # Initialize the InteractionChannelParticipantPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [InteractionChannelParticipantPage] InteractionChannelParticipantPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of InteractionChannelParticipantInstance + # @param [Hash] payload Payload response from the API + # @return [InteractionChannelParticipantInstance] InteractionChannelParticipantInstance + def get_instance(payload) + InteractionChannelParticipantInstance.new( + @version, + payload, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class InteractionChannelParticipantContext < InstanceContext + ## + # Initialize the InteractionChannelParticipantContext + # @param [Version] version Version that contains the resource + # @param [String] interaction_sid The Interaction Sid for this channel. + # @param [String] channel_sid The Channel Sid for this Participant. + # @param [String] sid The unique string created by Twilio to identify an + # Interaction Channel resource. + # @return [InteractionChannelParticipantContext] InteractionChannelParticipantContext + def initialize(version, interaction_sid, channel_sid, sid) + super(version) + + # Path Solution + @solution = {interaction_sid: interaction_sid, channel_sid: channel_sid, sid: sid, } + @uri = "/Interactions/#{@solution[:interaction_sid]}/Channels/#{@solution[:channel_sid]}/Participants/#{@solution[:sid]}" + end + + ## + # Update the InteractionChannelParticipantInstance + # @param [interaction_channel_participant.Status] status The Participant's status. + # Can be: `closed` or `wrapup`. Participant must be an agent. + # @return [InteractionChannelParticipantInstance] Updated InteractionChannelParticipantInstance + def update(status: nil) + data = Twilio::Values.of({'Status' => status, }) + + payload = @version.update('POST', @uri, data: data) + + InteractionChannelParticipantInstance.new( + @version, + payload, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class InteractionChannelParticipantInstance < InstanceResource + ## + # Initialize the InteractionChannelParticipantInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] interaction_sid The Interaction Sid for this channel. + # @param [String] channel_sid The Channel Sid for this Participant. + # @param [String] sid The unique string created by Twilio to identify an + # Interaction Channel resource. + # @return [InteractionChannelParticipantInstance] InteractionChannelParticipantInstance + def initialize(version, payload, interaction_sid: nil, channel_sid: nil, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'type' => payload['type'], + 'interaction_sid' => payload['interaction_sid'], + 'channel_sid' => payload['channel_sid'], + 'url' => payload['url'], + } + + # Context + @instance_context = nil + @params = { + 'interaction_sid' => interaction_sid, + 'channel_sid' => channel_sid, + 'sid' => sid || @properties['sid'], + } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [InteractionChannelParticipantContext] InteractionChannelParticipantContext for this InteractionChannelParticipantInstance + def context + unless @instance_context + @instance_context = InteractionChannelParticipantContext.new( + @version, + @params['interaction_sid'], + @params['channel_sid'], + @params['sid'], + ) + end + @instance_context + end + + ## + # @return [String] The unique string that identifies the resource + def sid + @properties['sid'] + end + + ## + # @return [interaction_channel_participant.Type] Participant type. + def type + @properties['type'] + end + + ## + # @return [String] The Interaction Sid for this channel. + def interaction_sid + @properties['interaction_sid'] + end + + ## + # @return [String] The Channel Sid for this Participant. + def channel_sid + @properties['channel_sid'] + end + + ## + # @return [String] The url + def url + @properties['url'] + end + + ## + # Update the InteractionChannelParticipantInstance + # @param [interaction_channel_participant.Status] status The Participant's status. + # Can be: `closed` or `wrapup`. Participant must be an agent. + # @return [InteractionChannelParticipantInstance] Updated InteractionChannelParticipantInstance + def update(status: nil) + context.update(status: status, ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/insights.rb b/lib/twilio-ruby/rest/insights.rb index d6b3d5543..10e1421be 100644 --- a/lib/twilio-ruby/rest/insights.rb +++ b/lib/twilio-ruby/rest/insights.rb @@ -34,6 +34,14 @@ def settings self.v1.settings() end + ## + # @param [String] call_sid The call_sid + # @return [Twilio::REST::Insights::V1::AnnotationInstance] if call_sid was passed. + # @return [Twilio::REST::Insights::V1::AnnotationList] + def annotation(call_sid=:unset) + self.v1.annotation(call_sid) + end + ## # @param [String] sid The sid # @return [Twilio::REST::Insights::V1::CallInstance] if sid was passed. @@ -48,6 +56,14 @@ def call_summaries self.v1.call_summaries() end + ## + # @param [String] conference_sid The unique SID identifier of the Conference. + # @return [Twilio::REST::Insights::V1::ConferenceInstance] if conference_sid was passed. + # @return [Twilio::REST::Insights::V1::ConferenceList] + def conferences(conference_sid=:unset) + self.v1.conferences(conference_sid) + end + ## # @param [String] room_sid Unique identifier for the room. # @return [Twilio::REST::Insights::V1::RoomInstance] if room_sid was passed. diff --git a/lib/twilio-ruby/rest/insights/v1.rb b/lib/twilio-ruby/rest/insights/v1.rb index 78a237478..a8777d32d 100644 --- a/lib/twilio-ruby/rest/insights/v1.rb +++ b/lib/twilio-ruby/rest/insights/v1.rb @@ -16,8 +16,10 @@ def initialize(domain) super @version = 'v1' @settings = nil + @annotation = nil @calls = nil @call_summaries = nil + @conferences = nil @rooms = nil end @@ -27,6 +29,21 @@ def settings @settings ||= SettingContext.new self end + ## + # @param [String] call_sid The call_sid + # @return [Twilio::REST::Insights::V1::AnnotationContext] if call_sid was passed. + # @return [Twilio::REST::Insights::V1::AnnotationList] + def annotation(call_sid=:unset) + if call_sid.nil? + raise ArgumentError, 'call_sid cannot be nil' + end + if call_sid == :unset + @annotation ||= AnnotationList.new self + else + AnnotationContext.new(self, call_sid) + end + end + ## # @param [String] sid The sid # @return [Twilio::REST::Insights::V1::CallContext] if sid was passed. @@ -48,6 +65,21 @@ def call_summaries @call_summaries ||= CallSummariesList.new self end + ## + # @param [String] conference_sid The unique SID identifier of the Conference. + # @return [Twilio::REST::Insights::V1::ConferenceContext] if conference_sid was passed. + # @return [Twilio::REST::Insights::V1::ConferenceList] + def conferences(conference_sid=:unset) + if conference_sid.nil? + raise ArgumentError, 'conference_sid cannot be nil' + end + if conference_sid == :unset + @conferences ||= ConferenceList.new self + else + ConferenceContext.new(self, conference_sid) + end + end + ## # @param [String] room_sid The SID of the Room resource. # @return [Twilio::REST::Insights::V1::RoomContext] if room_sid was passed. diff --git a/lib/twilio-ruby/rest/insights/v1/annotation.rb b/lib/twilio-ruby/rest/insights/v1/annotation.rb new file mode 100644 index 000000000..88f50a2e5 --- /dev/null +++ b/lib/twilio-ruby/rest/insights/v1/annotation.rb @@ -0,0 +1,271 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Insights < Domain + class V1 < Version + class AnnotationList < ListResource + ## + # Initialize the AnnotationList + # @param [Version] version Version that contains the resource + # @return [AnnotationList] AnnotationList + def initialize(version) + super(version) + + # Path Solution + @solution = {} + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class AnnotationPage < Page + ## + # Initialize the AnnotationPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [AnnotationPage] AnnotationPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of AnnotationInstance + # @param [Hash] payload Payload response from the API + # @return [AnnotationInstance] AnnotationInstance + def get_instance(payload) + AnnotationInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class AnnotationContext < InstanceContext + ## + # Initialize the AnnotationContext + # @param [Version] version Version that contains the resource + # @param [String] call_sid The call_sid + # @return [AnnotationContext] AnnotationContext + def initialize(version, call_sid) + super(version) + + # Path Solution + @solution = {call_sid: call_sid, } + @uri = "/Voice/#{@solution[:call_sid]}/Annotation" + end + + ## + # Update the AnnotationInstance + # @param [annotation.AnsweredBy] answered_by The answered_by + # @param [annotation.ConnectivityIssue] connectivity_issue The connectivity_issue + # @param [String] quality_issues The quality_issues + # @param [Boolean] spam The spam + # @param [String] call_score The call_score + # @param [String] comment The comment + # @param [String] incident The incident + # @return [AnnotationInstance] Updated AnnotationInstance + def update(answered_by: :unset, connectivity_issue: :unset, quality_issues: :unset, spam: :unset, call_score: :unset, comment: :unset, incident: :unset) + data = Twilio::Values.of({ + 'AnsweredBy' => answered_by, + 'ConnectivityIssue' => connectivity_issue, + 'QualityIssues' => quality_issues, + 'Spam' => spam, + 'CallScore' => call_score, + 'Comment' => comment, + 'Incident' => incident, + }) + + payload = @version.update('POST', @uri, data: data) + + AnnotationInstance.new(@version, payload, call_sid: @solution[:call_sid], ) + end + + ## + # Fetch the AnnotationInstance + # @return [AnnotationInstance] Fetched AnnotationInstance + def fetch + payload = @version.fetch('GET', @uri) + + AnnotationInstance.new(@version, payload, call_sid: @solution[:call_sid], ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class AnnotationInstance < InstanceResource + ## + # Initialize the AnnotationInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] call_sid The call_sid + # @return [AnnotationInstance] AnnotationInstance + def initialize(version, payload, call_sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'call_sid' => payload['call_sid'], + 'account_sid' => payload['account_sid'], + 'answered_by' => payload['answered_by'], + 'connectivity_issue' => payload['connectivity_issue'], + 'quality_issues' => payload['quality_issues'], + 'spam' => payload['spam'], + 'call_score' => payload['call_score'] == nil ? payload['call_score'] : payload['call_score'].to_i, + 'comment' => payload['comment'], + 'incident' => payload['incident'], + 'url' => payload['url'], + } + + # Context + @instance_context = nil + @params = {'call_sid' => call_sid || @properties['call_sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [AnnotationContext] AnnotationContext for this AnnotationInstance + def context + unless @instance_context + @instance_context = AnnotationContext.new(@version, @params['call_sid'], ) + end + @instance_context + end + + ## + # @return [String] The call_sid + def call_sid + @properties['call_sid'] + end + + ## + # @return [String] The account_sid + def account_sid + @properties['account_sid'] + end + + ## + # @return [annotation.AnsweredBy] The answered_by + def answered_by + @properties['answered_by'] + end + + ## + # @return [annotation.ConnectivityIssue] The connectivity_issue + def connectivity_issue + @properties['connectivity_issue'] + end + + ## + # @return [Array[String]] The quality_issues + def quality_issues + @properties['quality_issues'] + end + + ## + # @return [Boolean] The spam + def spam + @properties['spam'] + end + + ## + # @return [String] The call_score + def call_score + @properties['call_score'] + end + + ## + # @return [String] The comment + def comment + @properties['comment'] + end + + ## + # @return [String] The incident + def incident + @properties['incident'] + end + + ## + # @return [String] The url + def url + @properties['url'] + end + + ## + # Update the AnnotationInstance + # @param [annotation.AnsweredBy] answered_by The answered_by + # @param [annotation.ConnectivityIssue] connectivity_issue The connectivity_issue + # @param [String] quality_issues The quality_issues + # @param [Boolean] spam The spam + # @param [String] call_score The call_score + # @param [String] comment The comment + # @param [String] incident The incident + # @return [AnnotationInstance] Updated AnnotationInstance + def update(answered_by: :unset, connectivity_issue: :unset, quality_issues: :unset, spam: :unset, call_score: :unset, comment: :unset, incident: :unset) + context.update( + answered_by: answered_by, + connectivity_issue: connectivity_issue, + quality_issues: quality_issues, + spam: spam, + call_score: call_score, + comment: comment, + incident: incident, + ) + end + + ## + # Fetch the AnnotationInstance + # @return [AnnotationInstance] Fetched AnnotationInstance + def fetch + context.fetch + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/insights/v1/conference.rb b/lib/twilio-ruby/rest/insights/v1/conference.rb new file mode 100644 index 000000000..c2570e2a6 --- /dev/null +++ b/lib/twilio-ruby/rest/insights/v1/conference.rb @@ -0,0 +1,512 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Insights < Domain + class V1 < Version + class ConferenceList < ListResource + ## + # Initialize the ConferenceList + # @param [Version] version Version that contains the resource + # @return [ConferenceList] ConferenceList + def initialize(version) + super(version) + + # Path Solution + @solution = {} + @uri = "/Conferences" + end + + ## + # Lists ConferenceInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @param [String] conference_sid The SID of the conference. + # @param [String] friendly_name Custom label for the conference resource, up to 64 + # characters. + # @param [String] status Conference status. + # @param [String] created_after Conferences created after the provided timestamp + # specified in ISO 8601 format + # @param [String] created_before Conferences created before the provided timestamp + # specified in ISO 8601 format. + # @param [String] mixer_region Twilio region where the conference media was mixed. + # @param [String] tags Tags applied by Twilio for common potential configuration, + # quality, or performance issues. + # @param [String] subaccount Account SID for the subaccount whose resources you + # wish to retrieve. + # @param [String] detected_issues Potential configuration, behavior, or + # performance issues detected during the conference. + # @param [String] end_reason Conference end reason; e.g. last participant left, + # modified by API, etc. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Array] Array of up to limit results + def list(conference_sid: :unset, friendly_name: :unset, status: :unset, created_after: :unset, created_before: :unset, mixer_region: :unset, tags: :unset, subaccount: :unset, detected_issues: :unset, end_reason: :unset, limit: nil, page_size: nil) + self.stream( + conference_sid: conference_sid, + friendly_name: friendly_name, + status: status, + created_after: created_after, + created_before: created_before, + mixer_region: mixer_region, + tags: tags, + subaccount: subaccount, + detected_issues: detected_issues, + end_reason: end_reason, + limit: limit, + page_size: page_size + ).entries + end + + ## + # Streams ConferenceInstance records from the API as an Enumerable. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + # @param [String] conference_sid The SID of the conference. + # @param [String] friendly_name Custom label for the conference resource, up to 64 + # characters. + # @param [String] status Conference status. + # @param [String] created_after Conferences created after the provided timestamp + # specified in ISO 8601 format + # @param [String] created_before Conferences created before the provided timestamp + # specified in ISO 8601 format. + # @param [String] mixer_region Twilio region where the conference media was mixed. + # @param [String] tags Tags applied by Twilio for common potential configuration, + # quality, or performance issues. + # @param [String] subaccount Account SID for the subaccount whose resources you + # wish to retrieve. + # @param [String] detected_issues Potential configuration, behavior, or + # performance issues detected during the conference. + # @param [String] end_reason Conference end reason; e.g. last participant left, + # modified by API, etc. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit. + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Enumerable] Enumerable that will yield up to limit results + def stream(conference_sid: :unset, friendly_name: :unset, status: :unset, created_after: :unset, created_before: :unset, mixer_region: :unset, tags: :unset, subaccount: :unset, detected_issues: :unset, end_reason: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page( + conference_sid: conference_sid, + friendly_name: friendly_name, + status: status, + created_after: created_after, + created_before: created_before, + mixer_region: mixer_region, + tags: tags, + subaccount: subaccount, + detected_issues: detected_issues, + end_reason: end_reason, + page_size: limits[:page_size], + ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields ConferenceInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of ConferenceInstance records from the API. + # Request is executed immediately. + # @param [String] conference_sid The SID of the conference. + # @param [String] friendly_name Custom label for the conference resource, up to 64 + # characters. + # @param [String] status Conference status. + # @param [String] created_after Conferences created after the provided timestamp + # specified in ISO 8601 format + # @param [String] created_before Conferences created before the provided timestamp + # specified in ISO 8601 format. + # @param [String] mixer_region Twilio region where the conference media was mixed. + # @param [String] tags Tags applied by Twilio for common potential configuration, + # quality, or performance issues. + # @param [String] subaccount Account SID for the subaccount whose resources you + # wish to retrieve. + # @param [String] detected_issues Potential configuration, behavior, or + # performance issues detected during the conference. + # @param [String] end_reason Conference end reason; e.g. last participant left, + # modified by API, etc. + # @param [String] page_token PageToken provided by the API + # @param [Integer] page_number Page Number, this value is simply for client state + # @param [Integer] page_size Number of records to return, defaults to 50 + # @return [Page] Page of ConferenceInstance + def page(conference_sid: :unset, friendly_name: :unset, status: :unset, created_after: :unset, created_before: :unset, mixer_region: :unset, tags: :unset, subaccount: :unset, detected_issues: :unset, end_reason: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'ConferenceSid' => conference_sid, + 'FriendlyName' => friendly_name, + 'Status' => status, + 'CreatedAfter' => created_after, + 'CreatedBefore' => created_before, + 'MixerRegion' => mixer_region, + 'Tags' => tags, + 'Subaccount' => subaccount, + 'DetectedIssues' => detected_issues, + 'EndReason' => end_reason, + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + ConferencePage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of ConferenceInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of ConferenceInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + ConferencePage.new(@version, response, @solution) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class ConferencePage < Page + ## + # Initialize the ConferencePage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [ConferencePage] ConferencePage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of ConferenceInstance + # @param [Hash] payload Payload response from the API + # @return [ConferenceInstance] ConferenceInstance + def get_instance(payload) + ConferenceInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class ConferenceContext < InstanceContext + ## + # Initialize the ConferenceContext + # @param [Version] version Version that contains the resource + # @param [String] conference_sid The unique SID identifier of the Conference. + # @return [ConferenceContext] ConferenceContext + def initialize(version, conference_sid) + super(version) + + # Path Solution + @solution = {conference_sid: conference_sid, } + @uri = "/Conferences/#{@solution[:conference_sid]}" + + # Dependents + @conference_participants = nil + end + + ## + # Fetch the ConferenceInstance + # @return [ConferenceInstance] Fetched ConferenceInstance + def fetch + payload = @version.fetch('GET', @uri) + + ConferenceInstance.new(@version, payload, conference_sid: @solution[:conference_sid], ) + end + + ## + # Access the conference_participants + # @return [ConferenceParticipantList] + # @return [ConferenceParticipantContext] if participant_sid was passed. + def conference_participants(participant_sid=:unset) + raise ArgumentError, 'participant_sid cannot be nil' if participant_sid.nil? + + if participant_sid != :unset + return ConferenceParticipantContext.new(@version, @solution[:conference_sid], participant_sid, ) + end + + unless @conference_participants + @conference_participants = ConferenceParticipantList.new( + @version, + conference_sid: @solution[:conference_sid], + ) + end + + @conference_participants + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class ConferenceInstance < InstanceResource + ## + # Initialize the ConferenceInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] conference_sid The unique SID identifier of the Conference. + # @return [ConferenceInstance] ConferenceInstance + def initialize(version, payload, conference_sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'conference_sid' => payload['conference_sid'], + 'account_sid' => payload['account_sid'], + 'friendly_name' => payload['friendly_name'], + 'create_time' => Twilio.deserialize_iso8601_datetime(payload['create_time']), + 'start_time' => Twilio.deserialize_iso8601_datetime(payload['start_time']), + 'end_time' => Twilio.deserialize_iso8601_datetime(payload['end_time']), + 'duration_seconds' => payload['duration_seconds'] == nil ? payload['duration_seconds'] : payload['duration_seconds'].to_i, + 'connect_duration_seconds' => payload['connect_duration_seconds'] == nil ? payload['connect_duration_seconds'] : payload['connect_duration_seconds'].to_i, + 'status' => payload['status'], + 'max_participants' => payload['max_participants'] == nil ? payload['max_participants'] : payload['max_participants'].to_i, + 'max_concurrent_participants' => payload['max_concurrent_participants'] == nil ? payload['max_concurrent_participants'] : payload['max_concurrent_participants'].to_i, + 'unique_participants' => payload['unique_participants'] == nil ? payload['unique_participants'] : payload['unique_participants'].to_i, + 'end_reason' => payload['end_reason'], + 'ended_by' => payload['ended_by'], + 'mixer_region' => payload['mixer_region'], + 'mixer_region_requested' => payload['mixer_region_requested'], + 'recording_enabled' => payload['recording_enabled'], + 'detected_issues' => payload['detected_issues'], + 'tags' => payload['tags'], + 'tag_info' => payload['tag_info'], + 'processing_state' => payload['processing_state'], + 'url' => payload['url'], + 'links' => payload['links'], + } + + # Context + @instance_context = nil + @params = {'conference_sid' => conference_sid || @properties['conference_sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [ConferenceContext] ConferenceContext for this ConferenceInstance + def context + unless @instance_context + @instance_context = ConferenceContext.new(@version, @params['conference_sid'], ) + end + @instance_context + end + + ## + # @return [String] Conference SID. + def conference_sid + @properties['conference_sid'] + end + + ## + # @return [String] Account SID. + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] Custom label for the conference. + def friendly_name + @properties['friendly_name'] + end + + ## + # @return [Time] Conference creation date/time. + def create_time + @properties['create_time'] + end + + ## + # @return [Time] Timestamp in ISO 8601 format when the conference started. + def start_time + @properties['start_time'] + end + + ## + # @return [Time] Conference end date/time. + def end_time + @properties['end_time'] + end + + ## + # @return [String] Conference duration in seconds. + def duration_seconds + @properties['duration_seconds'] + end + + ## + # @return [String] Duration of the conference in seconds. + def connect_duration_seconds + @properties['connect_duration_seconds'] + end + + ## + # @return [conference.ConferenceStatus] Status of conference + def status + @properties['status'] + end + + ## + # @return [String] Max participants specified in config. + def max_participants + @properties['max_participants'] + end + + ## + # @return [String] Actual maximum concurrent participants. + def max_concurrent_participants + @properties['max_concurrent_participants'] + end + + ## + # @return [String] Unique conference participants. + def unique_participants + @properties['unique_participants'] + end + + ## + # @return [conference.ConferenceEndReason] Conference end reason. + def end_reason + @properties['end_reason'] + end + + ## + # @return [String] Call SID that ended the conference. + def ended_by + @properties['ended_by'] + end + + ## + # @return [conference.Region] Region where the conference was mixed. + def mixer_region + @properties['mixer_region'] + end + + ## + # @return [conference.Region] Configuration-requested conference mixer region. + def mixer_region_requested + @properties['mixer_region_requested'] + end + + ## + # @return [Boolean] Boolean. Indicates whether recording was enabled. + def recording_enabled + @properties['recording_enabled'] + end + + ## + # @return [Hash] Potential issues detected during the conference. + def detected_issues + @properties['detected_issues'] + end + + ## + # @return [Array[conference.Tag]] Tags for detected conference conditions and participant behaviors. + def tags + @properties['tags'] + end + + ## + # @return [Hash] Object. Contains details about conference tags. + def tag_info + @properties['tag_info'] + end + + ## + # @return [conference.ProcessingState] Processing state for the Conference Summary resource. + def processing_state + @properties['processing_state'] + end + + ## + # @return [String] The URL of this resource. + def url + @properties['url'] + end + + ## + # @return [String] Nested resource URLs. + def links + @properties['links'] + end + + ## + # Fetch the ConferenceInstance + # @return [ConferenceInstance] Fetched ConferenceInstance + def fetch + context.fetch + end + + ## + # Access the conference_participants + # @return [conference_participants] conference_participants + def conference_participants + context.conference_participants + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb b/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb new file mode 100644 index 000000000..21ba0cce7 --- /dev/null +++ b/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb @@ -0,0 +1,474 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Insights < Domain + class V1 < Version + class ConferenceContext < InstanceContext + class ConferenceParticipantList < ListResource + ## + # Initialize the ConferenceParticipantList + # @param [Version] version Version that contains the resource + # @param [String] conference_sid The unique SID identifier of the Conference. + # @return [ConferenceParticipantList] ConferenceParticipantList + def initialize(version, conference_sid: nil) + super(version) + + # Path Solution + @solution = {conference_sid: conference_sid} + @uri = "/Conferences/#{@solution[:conference_sid]}/Participants" + end + + ## + # Lists ConferenceParticipantInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @param [String] participant_sid The unique SID identifier of the Participant. + # @param [String] label User-specified label for a participant. + # @param [String] events Conference events generated by application or participant + # activity; e.g. `hold`, `mute`, etc. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Array] Array of up to limit results + def list(participant_sid: :unset, label: :unset, events: :unset, limit: nil, page_size: nil) + self.stream( + participant_sid: participant_sid, + label: label, + events: events, + limit: limit, + page_size: page_size + ).entries + end + + ## + # Streams ConferenceParticipantInstance records from the API as an Enumerable. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + # @param [String] participant_sid The unique SID identifier of the Participant. + # @param [String] label User-specified label for a participant. + # @param [String] events Conference events generated by application or participant + # activity; e.g. `hold`, `mute`, etc. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit. + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Enumerable] Enumerable that will yield up to limit results + def stream(participant_sid: :unset, label: :unset, events: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page( + participant_sid: participant_sid, + label: label, + events: events, + page_size: limits[:page_size], + ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields ConferenceParticipantInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of ConferenceParticipantInstance records from the API. + # Request is executed immediately. + # @param [String] participant_sid The unique SID identifier of the Participant. + # @param [String] label User-specified label for a participant. + # @param [String] events Conference events generated by application or participant + # activity; e.g. `hold`, `mute`, etc. + # @param [String] page_token PageToken provided by the API + # @param [Integer] page_number Page Number, this value is simply for client state + # @param [Integer] page_size Number of records to return, defaults to 50 + # @return [Page] Page of ConferenceParticipantInstance + def page(participant_sid: :unset, label: :unset, events: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'ParticipantSid' => participant_sid, + 'Label' => label, + 'Events' => events, + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + ConferenceParticipantPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of ConferenceParticipantInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of ConferenceParticipantInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + ConferenceParticipantPage.new(@version, response, @solution) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + class ConferenceParticipantPage < Page + ## + # Initialize the ConferenceParticipantPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [ConferenceParticipantPage] ConferenceParticipantPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of ConferenceParticipantInstance + # @param [Hash] payload Payload response from the API + # @return [ConferenceParticipantInstance] ConferenceParticipantInstance + def get_instance(payload) + ConferenceParticipantInstance.new(@version, payload, conference_sid: @solution[:conference_sid], ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + class ConferenceParticipantContext < InstanceContext + ## + # Initialize the ConferenceParticipantContext + # @param [Version] version Version that contains the resource + # @param [String] conference_sid The unique SID identifier of the Conference. + # @param [String] participant_sid The unique SID identifier of the Participant. + # @return [ConferenceParticipantContext] ConferenceParticipantContext + def initialize(version, conference_sid, participant_sid) + super(version) + + # Path Solution + @solution = {conference_sid: conference_sid, participant_sid: participant_sid, } + @uri = "/Conferences/#{@solution[:conference_sid]}/Participants/#{@solution[:participant_sid]}" + end + + ## + # Fetch the ConferenceParticipantInstance + # @param [String] events Conference events generated by application or participant + # activity; e.g. `hold`, `mute`, etc. + # @param [String] metrics Object. Contains participant call quality metrics. + # @return [ConferenceParticipantInstance] Fetched ConferenceParticipantInstance + def fetch(events: :unset, metrics: :unset) + params = Twilio::Values.of({'Events' => events, 'Metrics' => metrics, }) + + payload = @version.fetch('GET', @uri, params: params) + + ConferenceParticipantInstance.new( + @version, + payload, + conference_sid: @solution[:conference_sid], + participant_sid: @solution[:participant_sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + class ConferenceParticipantInstance < InstanceResource + ## + # Initialize the ConferenceParticipantInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] conference_sid The unique SID identifier of the Conference. + # @param [String] participant_sid The unique SID identifier of the Participant. + # @return [ConferenceParticipantInstance] ConferenceParticipantInstance + def initialize(version, payload, conference_sid: nil, participant_sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'participant_sid' => payload['participant_sid'], + 'label' => payload['label'], + 'conference_sid' => payload['conference_sid'], + 'call_sid' => payload['call_sid'], + 'account_sid' => payload['account_sid'], + 'call_direction' => payload['call_direction'], + 'from' => payload['from'], + 'to' => payload['to'], + 'call_status' => payload['call_status'], + 'country_code' => payload['country_code'], + 'is_moderator' => payload['is_moderator'], + 'join_time' => Twilio.deserialize_iso8601_datetime(payload['join_time']), + 'leave_time' => Twilio.deserialize_iso8601_datetime(payload['leave_time']), + 'duration_seconds' => payload['duration_seconds'] == nil ? payload['duration_seconds'] : payload['duration_seconds'].to_i, + 'outbound_queue_length' => payload['outbound_queue_length'] == nil ? payload['outbound_queue_length'] : payload['outbound_queue_length'].to_i, + 'outbound_time_in_queue' => payload['outbound_time_in_queue'] == nil ? payload['outbound_time_in_queue'] : payload['outbound_time_in_queue'].to_i, + 'jitter_buffer_size' => payload['jitter_buffer_size'], + 'is_coach' => payload['is_coach'], + 'coached_participants' => payload['coached_participants'], + 'participant_region' => payload['participant_region'], + 'conference_region' => payload['conference_region'], + 'call_type' => payload['call_type'], + 'processing_state' => payload['processing_state'], + 'properties' => payload['properties'], + 'events' => payload['events'], + 'metrics' => payload['metrics'], + 'url' => payload['url'], + } + + # Context + @instance_context = nil + @params = { + 'conference_sid' => conference_sid, + 'participant_sid' => participant_sid || @properties['participant_sid'], + } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [ConferenceParticipantContext] ConferenceParticipantContext for this ConferenceParticipantInstance + def context + unless @instance_context + @instance_context = ConferenceParticipantContext.new( + @version, + @params['conference_sid'], + @params['participant_sid'], + ) + end + @instance_context + end + + ## + # @return [String] SID for this participant. + def participant_sid + @properties['participant_sid'] + end + + ## + # @return [String] The user-specified label of this participant. + def label + @properties['label'] + end + + ## + # @return [String] Conference SID. + def conference_sid + @properties['conference_sid'] + end + + ## + # @return [String] Unique SID identifier of the call. + def call_sid + @properties['call_sid'] + end + + ## + # @return [String] Account SID. + def account_sid + @properties['account_sid'] + end + + ## + # @return [conference_participant.CallDirection] Call direction of the participant. + def call_direction + @properties['call_direction'] + end + + ## + # @return [String] Caller ID of the calling party. + def from + @properties['from'] + end + + ## + # @return [String] Called party. + def to + @properties['to'] + end + + ## + # @return [conference_participant.CallStatus] Call status of the call that generated the participant. + def call_status + @properties['call_status'] + end + + ## + # @return [String] ISO alpha-2 country code of the participant. + def country_code + @properties['country_code'] + end + + ## + # @return [Boolean] Boolean. Indicates whether participant had startConferenceOnEnter=true or endConferenceOnExit=true. + def is_moderator + @properties['is_moderator'] + end + + ## + # @return [Time] ISO 8601 timestamp of participant join event. + def join_time + @properties['join_time'] + end + + ## + # @return [Time] ISO 8601 timestamp of participant leave event. + def leave_time + @properties['leave_time'] + end + + ## + # @return [String] Participant durations in seconds. + def duration_seconds + @properties['duration_seconds'] + end + + ## + # @return [String] Estimated time in queue at call creation. + def outbound_queue_length + @properties['outbound_queue_length'] + end + + ## + # @return [String] Actual time in queue (seconds). + def outbound_time_in_queue + @properties['outbound_time_in_queue'] + end + + ## + # @return [conference_participant.JitterBufferSize] The Jitter Buffer Size of this Conference Participant. + def jitter_buffer_size + @properties['jitter_buffer_size'] + end + + ## + # @return [Boolean] Boolean. Indicated whether participant was a coach. + def is_coach + @properties['is_coach'] + end + + ## + # @return [Array[String]] Call SIDs coached by this participant. + def coached_participants + @properties['coached_participants'] + end + + ## + # @return [conference_participant.Region] Twilio region where the participant media originates. + def participant_region + @properties['participant_region'] + end + + ## + # @return [conference_participant.Region] The Conference Region of this Conference Participant. + def conference_region + @properties['conference_region'] + end + + ## + # @return [conference_participant.CallType] The Call Type of this Conference Participant. + def call_type + @properties['call_type'] + end + + ## + # @return [conference_participant.ProcessingState] Processing state of the Participant Summary. + def processing_state + @properties['processing_state'] + end + + ## + # @return [Hash] Participant properties and metadata. + def properties + @properties['properties'] + end + + ## + # @return [Hash] Object containing information of actions taken by participants. Nested resource URLs. + def events + @properties['events'] + end + + ## + # @return [Hash] Object. Contains participant quality metrics. + def metrics + @properties['metrics'] + end + + ## + # @return [String] The URL of this resource. + def url + @properties['url'] + end + + ## + # Fetch the ConferenceParticipantInstance + # @param [String] events Conference events generated by application or participant + # activity; e.g. `hold`, `mute`, etc. + # @param [String] metrics Object. Contains participant call quality metrics. + # @return [ConferenceParticipantInstance] Fetched ConferenceParticipantInstance + def fetch(events: :unset, metrics: :unset) + context.fetch(events: events, metrics: metrics, ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/media.rb b/lib/twilio-ruby/rest/media.rb index 69b15ce1a..4289e8563 100644 --- a/lib/twilio-ruby/rest/media.rb +++ b/lib/twilio-ruby/rest/media.rb @@ -37,6 +37,15 @@ def media_processor(sid=:unset) self.v1.media_processor(sid) end + ## + # @param [String] sid The unique string generated to identify the MediaRecording + # resource. + # @return [Twilio::REST::Media::V1::MediaRecordingInstance] if sid was passed. + # @return [Twilio::REST::Media::V1::MediaRecordingList] + def media_recording(sid=:unset) + self.v1.media_recording(sid) + end + ## # @param [String] sid The unique string generated to identify the PlayerStreamer # resource. diff --git a/lib/twilio-ruby/rest/media/v1.rb b/lib/twilio-ruby/rest/media/v1.rb index 165670bb1..da9ff334b 100644 --- a/lib/twilio-ruby/rest/media/v1.rb +++ b/lib/twilio-ruby/rest/media/v1.rb @@ -16,6 +16,7 @@ def initialize(domain) super @version = 'v1' @media_processor = nil + @media_recording = nil @player_streamer = nil end @@ -34,6 +35,21 @@ def media_processor(sid=:unset) end end + ## + # @param [String] sid The SID of the MediaRecording resource to fetch. + # @return [Twilio::REST::Media::V1::MediaRecordingContext] if sid was passed. + # @return [Twilio::REST::Media::V1::MediaRecordingList] + def media_recording(sid=:unset) + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + if sid == :unset + @media_recording ||= MediaRecordingList.new self + else + MediaRecordingContext.new(self, sid) + end + end + ## # @param [String] sid The SID of the PlayerStreamer resource to fetch. # @return [Twilio::REST::Media::V1::PlayerStreamerContext] if sid was passed. diff --git a/lib/twilio-ruby/rest/media/v1/media_processor.rb b/lib/twilio-ruby/rest/media/v1/media_processor.rb index a0a371da9..bafadb8e3 100644 --- a/lib/twilio-ruby/rest/media/v1/media_processor.rb +++ b/lib/twilio-ruby/rest/media/v1/media_processor.rb @@ -356,7 +356,7 @@ def status_callback_method end ## - # @return [String] Maximum MediaProcessor duration in minutes + # @return [String] Maximum MediaProcessor duration in seconds def max_duration @properties['max_duration'] end diff --git a/lib/twilio-ruby/rest/media/v1/media_recording.rb b/lib/twilio-ruby/rest/media/v1/media_recording.rb new file mode 100644 index 000000000..aef3aa5fc --- /dev/null +++ b/lib/twilio-ruby/rest/media/v1/media_recording.rb @@ -0,0 +1,406 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +module Twilio + module REST + class Media < Domain + class V1 < Version + ## + # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. + class MediaRecordingList < ListResource + ## + # Initialize the MediaRecordingList + # @param [Version] version Version that contains the resource + # @return [MediaRecordingList] MediaRecordingList + def initialize(version) + super(version) + + # Path Solution + @solution = {} + @uri = "/MediaRecordings" + end + + ## + # Lists MediaRecordingInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @param [media_recording.Order] order The sort order of the list by + # `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as + # the default. + # @param [media_recording.Status] status Status to filter by, with possible values + # `processing`, `completed`, `deleted`, or `failed`. + # @param [String] processor_sid SID of a MediaProcessor to filter by. + # @param [String] source_sid SID of a MediaRecording source to filter by. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Array] Array of up to limit results + def list(order: :unset, status: :unset, processor_sid: :unset, source_sid: :unset, limit: nil, page_size: nil) + self.stream( + order: order, + status: status, + processor_sid: processor_sid, + source_sid: source_sid, + limit: limit, + page_size: page_size + ).entries + end + + ## + # Streams MediaRecordingInstance records from the API as an Enumerable. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + # @param [media_recording.Order] order The sort order of the list by + # `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as + # the default. + # @param [media_recording.Status] status Status to filter by, with possible values + # `processing`, `completed`, `deleted`, or `failed`. + # @param [String] processor_sid SID of a MediaProcessor to filter by. + # @param [String] source_sid SID of a MediaRecording source to filter by. + # @param [Integer] limit Upper limit for the number of records to return. stream() + # guarantees to never return more than limit. Default is no limit. + # @param [Integer] page_size Number of records to fetch per request, when + # not set will use the default value of 50 records. If no page_size is defined + # but a limit is defined, stream() will attempt to read the limit with the most + # efficient page size, i.e. min(limit, 1000) + # @return [Enumerable] Enumerable that will yield up to limit results + def stream(order: :unset, status: :unset, processor_sid: :unset, source_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page( + order: order, + status: status, + processor_sid: processor_sid, + source_sid: source_sid, + page_size: limits[:page_size], + ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields MediaRecordingInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits + + page = self.page(page_size: limits[:page_size], ) + + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of MediaRecordingInstance records from the API. + # Request is executed immediately. + # @param [media_recording.Order] order The sort order of the list by + # `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as + # the default. + # @param [media_recording.Status] status Status to filter by, with possible values + # `processing`, `completed`, `deleted`, or `failed`. + # @param [String] processor_sid SID of a MediaProcessor to filter by. + # @param [String] source_sid SID of a MediaRecording source to filter by. + # @param [String] page_token PageToken provided by the API + # @param [Integer] page_number Page Number, this value is simply for client state + # @param [Integer] page_size Number of records to return, defaults to 50 + # @return [Page] Page of MediaRecordingInstance + def page(order: :unset, status: :unset, processor_sid: :unset, source_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'Order' => order, + 'Status' => status, + 'ProcessorSid' => processor_sid, + 'SourceSid' => source_sid, + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + MediaRecordingPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of MediaRecordingInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of MediaRecordingInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + MediaRecordingPage.new(@version, response, @solution) + end + + ## + # Provide a user friendly representation + def to_s + '#' + end + end + + ## + # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. + class MediaRecordingPage < Page + ## + # Initialize the MediaRecordingPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [MediaRecordingPage] MediaRecordingPage + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of MediaRecordingInstance + # @param [Hash] payload Payload response from the API + # @return [MediaRecordingInstance] MediaRecordingInstance + def get_instance(payload) + MediaRecordingInstance.new(@version, payload, ) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end + + ## + # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. + class MediaRecordingContext < InstanceContext + ## + # Initialize the MediaRecordingContext + # @param [Version] version Version that contains the resource + # @param [String] sid The SID of the MediaRecording resource to fetch. + # @return [MediaRecordingContext] MediaRecordingContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = {sid: sid, } + @uri = "/MediaRecordings/#{@solution[:sid]}" + end + + ## + # Delete the MediaRecordingInstance + # @return [Boolean] true if delete succeeds, false otherwise + def delete + @version.delete('DELETE', @uri) + end + + ## + # Fetch the MediaRecordingInstance + # @return [MediaRecordingInstance] Fetched MediaRecordingInstance + def fetch + payload = @version.fetch('GET', @uri) + + MediaRecordingInstance.new(@version, payload, sid: @solution[:sid], ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + + ## + # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. + class MediaRecordingInstance < InstanceResource + ## + # Initialize the MediaRecordingInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] sid The SID of the MediaRecording resource to fetch. + # @return [MediaRecordingInstance] MediaRecordingInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'bitrate' => payload['bitrate'].to_i, + 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), + 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), + 'duration' => payload['duration'].to_i, + 'format' => payload['format'], + 'links' => payload['links'], + 'processor_sid' => payload['processor_sid'], + 'resolution' => payload['resolution'], + 'source_sid' => payload['source_sid'], + 'sid' => payload['sid'], + 'size' => payload['size'].to_i, + 'status' => payload['status'], + 'status_callback' => payload['status_callback'], + 'status_callback_method' => payload['status_callback_method'], + 'url' => payload['url'], + } + + # Context + @instance_context = nil + @params = {'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [MediaRecordingContext] MediaRecordingContext for this MediaRecordingInstance + def context + unless @instance_context + @instance_context = MediaRecordingContext.new(@version, @params['sid'], ) + end + @instance_context + end + + ## + # @return [String] The SID of the Account that created the resource + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] The bitrate of the media + def bitrate + @properties['bitrate'] + end + + ## + # @return [Time] The ISO 8601 date and time in GMT when the resource was created + def date_created + @properties['date_created'] + end + + ## + # @return [Time] The ISO 8601 date and time in GMT when the resource was last updated + def date_updated + @properties['date_updated'] + end + + ## + # @return [String] The duration of the MediaRecording + def duration + @properties['duration'] + end + + ## + # @return [media_recording.Format] The format of the MediaRecording + def format + @properties['format'] + end + + ## + # @return [String] The URLs of related resources + def links + @properties['links'] + end + + ## + # @return [String] The SID of the MediaProcessor + def processor_sid + @properties['processor_sid'] + end + + ## + # @return [String] The dimensions of the video image in pixels + def resolution + @properties['resolution'] + end + + ## + # @return [String] The SID of the resource that generated the original media + def source_sid + @properties['source_sid'] + end + + ## + # @return [String] The unique string that identifies the resource + def sid + @properties['sid'] + end + + ## + # @return [String] The size of the recording + def size + @properties['size'] + end + + ## + # @return [media_recording.Status] The status of the MediaRecording + def status + @properties['status'] + end + + ## + # @return [String] The URL to which Twilio will send MediaRecording event updates + def status_callback + @properties['status_callback'] + end + + ## + # @return [String] The HTTP method Twilio should use to call the `status_callback` URL + def status_callback_method + @properties['status_callback_method'] + end + + ## + # @return [String] The absolute URL of the resource + def url + @properties['url'] + end + + ## + # Delete the MediaRecordingInstance + # @return [Boolean] true if delete succeeds, false otherwise + def delete + context.delete + end + + ## + # Fetch the MediaRecordingInstance + # @return [MediaRecordingInstance] Fetched MediaRecordingInstance + def fetch + context.fetch + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/twilio-ruby/rest/media/v1/player_streamer.rb b/lib/twilio-ruby/rest/media/v1/player_streamer.rb index 613a7777a..12d9648e6 100644 --- a/lib/twilio-ruby/rest/media/v1/player_streamer.rb +++ b/lib/twilio-ruby/rest/media/v1/player_streamer.rb @@ -32,12 +32,18 @@ def initialize(version) # Callbacks}[/docs/live/status-callbacks] for more details. # @param [String] status_callback_method The HTTP method Twilio should use to call # the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. + # @param [String] max_duration The maximum time, in seconds, that the + # PlayerStreamer can run before automatically ends. The default value is 300 + # seconds, and the maximum value is 90000 seconds. Once this maximum duration is + # reached, Twilio will end the PlayerStreamer, regardless of whether media is + # still streaming. # @return [PlayerStreamerInstance] Created PlayerStreamerInstance - def create(video: :unset, status_callback: :unset, status_callback_method: :unset) + def create(video: :unset, status_callback: :unset, status_callback_method: :unset, max_duration: :unset) data = Twilio::Values.of({ 'Video' => video, 'StatusCallback' => status_callback, 'StatusCallbackMethod' => status_callback_method, + 'MaxDuration' => max_duration, }) payload = @version.create('POST', @uri, data: data) @@ -263,6 +269,7 @@ def initialize(version, payload, sid: nil) 'status_callback' => payload['status_callback'], 'status_callback_method' => payload['status_callback_method'], 'ended_reason' => payload['ended_reason'], + 'max_duration' => payload['max_duration'].to_i, } # Context @@ -347,6 +354,12 @@ def ended_reason @properties['ended_reason'] end + ## + # @return [String] Maximum PlayerStreamer duration in seconds + def max_duration + @properties['max_duration'] + end + ## # Fetch the PlayerStreamerInstance # @return [PlayerStreamerInstance] Fetched PlayerStreamerInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb b/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb index 938346a5b..eae5a54fb 100644 --- a/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb +++ b/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb @@ -269,6 +269,7 @@ def initialize(version, payload, sid: nil) 'brand_feedback' => payload['brand_feedback'], 'identity_status' => payload['identity_status'], 'russell_3000' => payload['russell_3000'], + 'government_entity' => payload['government_entity'], 'tax_exempt_status' => payload['tax_exempt_status'], 'skip_automatic_sec_vet' => payload['skip_automatic_sec_vet'], 'mock' => payload['mock'], @@ -381,6 +382,12 @@ def russell_3000 @properties['russell_3000'] end + ## + # @return [Boolean] Government Entity + def government_entity + @properties['government_entity'] + end + ## # @return [String] Tax Exempt Status def tax_exempt_status diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb index 36b0fbf7b..94fdbea2a 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb @@ -64,15 +64,28 @@ def create(friendly_name: nil, email: nil, status_callback: :unset, regulation_s # Unlike stream(), this operation is eager and will load `limit` records into # memory before returning. # @param [bundle.Status] status The verification status of the Bundle resource. + # Please refer to {Bundle + # Statuses}[https://www.twilio.com/docs/phone-numbers/regulatory/api/bundles#bundle-statuses] + # for more details. # @param [String] friendly_name The string that you assigned to describe the - # resource. - # @param [String] regulation_sid The unique string of a regulation that is - # associated to the Bundle resource. - # @param [String] iso_country The {ISO country + # resource. The column can contain 255 variable characters. + # @param [String] regulation_sid The unique string of a {Regulation + # resource}[https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations] + # that is associated to the Bundle resource. + # @param [String] iso_country The 2-digit {ISO country # code}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2] of the Bundle's phone # number country ownership request. # @param [String] number_type The type of phone number of the Bundle's ownership - # request. Can be `local`, `mobile`, `national`, or `toll free`. + # request. Can be `local`, `mobile`, `national`, or `tollfree`. + # @param [Boolean] has_valid_until_date Indicates that the Bundle is a valid + # Bundle until a specified expiration date. + # @param [bundle.SortBy] sort_by Can be `valid-until` or `date-updated`. Defaults + # to `date-created`. + # @param [bundle.SortDirection] sort_direction Default is `DESC`. Can be `ASC` or + # `DESC`. + # @param [Time] valid_until_date_before Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. + # @param [Time] valid_until_date Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. + # @param [Time] valid_until_date_after Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size Number of records to fetch per request, when @@ -80,13 +93,19 @@ def create(friendly_name: nil, email: nil, status_callback: :unset, regulation_s # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Array] Array of up to limit results - def list(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_country: :unset, number_type: :unset, limit: nil, page_size: nil) + def list(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_country: :unset, number_type: :unset, has_valid_until_date: :unset, sort_by: :unset, sort_direction: :unset, valid_until_date_before: :unset, valid_until_date: :unset, valid_until_date_after: :unset, limit: nil, page_size: nil) self.stream( status: status, friendly_name: friendly_name, regulation_sid: regulation_sid, iso_country: iso_country, number_type: number_type, + has_valid_until_date: has_valid_until_date, + sort_by: sort_by, + sort_direction: sort_direction, + valid_until_date_before: valid_until_date_before, + valid_until_date: valid_until_date, + valid_until_date_after: valid_until_date_after, limit: limit, page_size: page_size ).entries @@ -97,15 +116,28 @@ def list(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_coun # This operation lazily loads records as efficiently as possible until the limit # is reached. # @param [bundle.Status] status The verification status of the Bundle resource. + # Please refer to {Bundle + # Statuses}[https://www.twilio.com/docs/phone-numbers/regulatory/api/bundles#bundle-statuses] + # for more details. # @param [String] friendly_name The string that you assigned to describe the - # resource. - # @param [String] regulation_sid The unique string of a regulation that is - # associated to the Bundle resource. - # @param [String] iso_country The {ISO country + # resource. The column can contain 255 variable characters. + # @param [String] regulation_sid The unique string of a {Regulation + # resource}[https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations] + # that is associated to the Bundle resource. + # @param [String] iso_country The 2-digit {ISO country # code}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2] of the Bundle's phone # number country ownership request. # @param [String] number_type The type of phone number of the Bundle's ownership - # request. Can be `local`, `mobile`, `national`, or `toll free`. + # request. Can be `local`, `mobile`, `national`, or `tollfree`. + # @param [Boolean] has_valid_until_date Indicates that the Bundle is a valid + # Bundle until a specified expiration date. + # @param [bundle.SortBy] sort_by Can be `valid-until` or `date-updated`. Defaults + # to `date-created`. + # @param [bundle.SortDirection] sort_direction Default is `DESC`. Can be `ASC` or + # `DESC`. + # @param [Time] valid_until_date_before Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. + # @param [Time] valid_until_date Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. + # @param [Time] valid_until_date_after Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit. # @param [Integer] page_size Number of records to fetch per request, when @@ -113,7 +145,7 @@ def list(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_coun # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Enumerable] Enumerable that will yield up to limit results - def stream(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_country: :unset, number_type: :unset, limit: nil, page_size: nil) + def stream(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_country: :unset, number_type: :unset, has_valid_until_date: :unset, sort_by: :unset, sort_direction: :unset, valid_until_date_before: :unset, valid_until_date: :unset, valid_until_date_after: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( @@ -122,6 +154,12 @@ def stream(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_co regulation_sid: regulation_sid, iso_country: iso_country, number_type: number_type, + has_valid_until_date: has_valid_until_date, + sort_by: sort_by, + sort_direction: sort_direction, + valid_until_date_before: valid_until_date_before, + valid_until_date: valid_until_date, + valid_until_date_after: valid_until_date_after, page_size: limits[:page_size], ) @@ -146,26 +184,45 @@ def each # Retrieve a single page of BundleInstance records from the API. # Request is executed immediately. # @param [bundle.Status] status The verification status of the Bundle resource. + # Please refer to {Bundle + # Statuses}[https://www.twilio.com/docs/phone-numbers/regulatory/api/bundles#bundle-statuses] + # for more details. # @param [String] friendly_name The string that you assigned to describe the - # resource. - # @param [String] regulation_sid The unique string of a regulation that is - # associated to the Bundle resource. - # @param [String] iso_country The {ISO country + # resource. The column can contain 255 variable characters. + # @param [String] regulation_sid The unique string of a {Regulation + # resource}[https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations] + # that is associated to the Bundle resource. + # @param [String] iso_country The 2-digit {ISO country # code}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2] of the Bundle's phone # number country ownership request. # @param [String] number_type The type of phone number of the Bundle's ownership - # request. Can be `local`, `mobile`, `national`, or `toll free`. + # request. Can be `local`, `mobile`, `national`, or `tollfree`. + # @param [Boolean] has_valid_until_date Indicates that the Bundle is a valid + # Bundle until a specified expiration date. + # @param [bundle.SortBy] sort_by Can be `valid-until` or `date-updated`. Defaults + # to `date-created`. + # @param [bundle.SortDirection] sort_direction Default is `DESC`. Can be `ASC` or + # `DESC`. + # @param [Time] valid_until_date_before Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. + # @param [Time] valid_until_date Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. + # @param [Time] valid_until_date_after Date to filter Bundles having their `valid_until_date` before or after the specified date. Can be `ValidUntilDate>=` or `ValidUntilDate<=`. Both can be used in conjunction as well. # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 # @return [Page] Page of BundleInstance - def page(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_country: :unset, number_type: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + def page(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_country: :unset, number_type: :unset, has_valid_until_date: :unset, sort_by: :unset, sort_direction: :unset, valid_until_date_before: :unset, valid_until_date: :unset, valid_until_date_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'Status' => status, 'FriendlyName' => friendly_name, 'RegulationSid' => regulation_sid, 'IsoCountry' => iso_country, 'NumberType' => number_type, + 'HasValidUntilDate' => has_valid_until_date, + 'SortBy' => sort_by, + 'SortDirection' => sort_direction, + 'ValidUntilDate<' => Twilio.serialize_iso8601_datetime(valid_until_date_before), + 'ValidUntilDate' => Twilio.serialize_iso8601_datetime(valid_until_date), + 'ValidUntilDate>' => Twilio.serialize_iso8601_datetime(valid_until_date_after), 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb index 2ac514c4f..aa7b318e1 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb @@ -242,6 +242,7 @@ def initialize(version, payload, sid: nil) 'friendly_name' => payload['friendly_name'], 'mime_type' => payload['mime_type'], 'status' => payload['status'], + 'failure_reason' => payload['failure_reason'], 'type' => payload['type'], 'attributes' => payload['attributes'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), @@ -295,6 +296,12 @@ def status @properties['status'] end + ## + # @return [String] The failure reason of the Supporting Document Resource. + def failure_reason + @properties['failure_reason'] + end + ## # @return [String] The type of the Supporting Document def type diff --git a/lib/twilio-ruby/rest/supersim.rb b/lib/twilio-ruby/rest/supersim.rb index 18ea419fa..b013dc3ca 100644 --- a/lib/twilio-ruby/rest/supersim.rb +++ b/lib/twilio-ruby/rest/supersim.rb @@ -29,12 +29,12 @@ def v1 end ## - # @param [String] sid The unique string that we created to identify the Command - # resource. - # @return [Twilio::REST::Supersim::V1::CommandInstance] if sid was passed. - # @return [Twilio::REST::Supersim::V1::CommandList] - def commands(sid=:unset) - self.v1.commands(sid) + # @param [String] sid The unique string that we created to identify the eSIM + # Profile resource. + # @return [Twilio::REST::Supersim::V1::EsimProfileInstance] if sid was passed. + # @return [Twilio::REST::Supersim::V1::EsimProfileList] + def esim_profiles(sid=:unset) + self.v1.esim_profiles(sid) end ## diff --git a/lib/twilio-ruby/rest/supersim/v1.rb b/lib/twilio-ruby/rest/supersim/v1.rb index 82b4bb3a5..9109a1449 100644 --- a/lib/twilio-ruby/rest/supersim/v1.rb +++ b/lib/twilio-ruby/rest/supersim/v1.rb @@ -15,7 +15,7 @@ class V1 < Version def initialize(domain) super @version = 'v1' - @commands = nil + @esim_profiles = nil @fleets = nil @ip_commands = nil @networks = nil @@ -26,17 +26,17 @@ def initialize(domain) end ## - # @param [String] sid The SID of the Command resource to fetch. - # @return [Twilio::REST::Supersim::V1::CommandContext] if sid was passed. - # @return [Twilio::REST::Supersim::V1::CommandList] - def commands(sid=:unset) + # @param [String] sid The SID of the eSIM Profile resource to fetch. + # @return [Twilio::REST::Supersim::V1::EsimProfileContext] if sid was passed. + # @return [Twilio::REST::Supersim::V1::EsimProfileList] + def esim_profiles(sid=:unset) if sid.nil? raise ArgumentError, 'sid cannot be nil' end if sid == :unset - @commands ||= CommandList.new self + @esim_profiles ||= EsimProfileList.new self else - CommandContext.new(self, sid) + EsimProfileContext.new(self, sid) end end diff --git a/lib/twilio-ruby/rest/supersim/v1/command.rb b/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb similarity index 56% rename from lib/twilio-ruby/rest/supersim/v1/command.rb rename to lib/twilio-ruby/rest/supersim/v1/esim_profile.rb index afa9a8739..8d8e1cc5b 100644 --- a/lib/twilio-ruby/rest/supersim/v1/command.rb +++ b/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb @@ -12,57 +12,52 @@ class Supersim < Domain class V1 < Version ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - class CommandList < ListResource + class EsimProfileList < ListResource ## - # Initialize the CommandList + # Initialize the EsimProfileList # @param [Version] version Version that contains the resource - # @return [CommandList] CommandList + # @return [EsimProfileList] EsimProfileList def initialize(version) super(version) # Path Solution @solution = {} - @uri = "/Commands" + @uri = "/ESimProfiles" end ## - # Create the CommandInstance - # @param [String] sim The `sid` or `unique_name` of the - # {SIM}[https://www.twilio.com/docs/wireless/api/sim-resource] to send the Command - # to. - # @param [String] command The message body of the command. + # Create the EsimProfileInstance + # @param [String] eid Identifier of the eUICC that will claim the eSIM Profile. + # @param [String] callback_url The URL we should call using the `callback_method` + # when the status of the eSIM Profile changes. At this stage of the eSIM Profile + # pilot, the a request to the URL will only be called when the ESimProfile + # resource changes from `reserving` to `available`. # @param [String] callback_method The HTTP method we should use to call # `callback_url`. Can be: `GET` or `POST` and the default is POST. - # @param [String] callback_url The URL we should call using the `callback_method` - # after we have sent the command. - # @return [CommandInstance] Created CommandInstance - def create(sim: nil, command: nil, callback_method: :unset, callback_url: :unset) + # @return [EsimProfileInstance] Created EsimProfileInstance + def create(eid: nil, callback_url: :unset, callback_method: :unset) data = Twilio::Values.of({ - 'Sim' => sim, - 'Command' => command, - 'CallbackMethod' => callback_method, + 'Eid' => eid, 'CallbackUrl' => callback_url, + 'CallbackMethod' => callback_method, }) payload = @version.create('POST', @uri, data: data) - CommandInstance.new(@version, payload, ) + EsimProfileInstance.new(@version, payload, ) end ## - # Lists CommandInstance records from the API as a list. + # Lists EsimProfileInstance records from the API as a list. # Unlike stream(), this operation is eager and will load `limit` records into # memory before returning. - # @param [String] sim The SID or unique name of the Sim that Command was sent to - # or from. - # @param [command.Status] status The status of the Command. Can be: `queued`, - # `sent`, `delivered`, `received` or `failed`. See the {Command Status - # Values}[https://www.twilio.com/docs/wireless/api/command-resource#status-values] - # for a description of each. - # @param [command.Direction] direction The direction of the Command. Can be - # `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term - # `mobile terminated`, and `from_sim` is synonymous with the term `mobile - # originated`. + # @param [String] eid List the eSIM Profiles that have been associated with an + # EId. + # @param [String] sim_sid Find the eSIM Profile resource related to a + # {Sim}[https://www.twilio.com/docs/wireless/api/sim-resource] resource by + # providing the SIM SID. Will always return an array with either 1 or 0 records. + # @param [esim_profile.Status] status List the eSIM Profiles that are in a given + # status. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size Number of records to fetch per request, when @@ -70,30 +65,21 @@ def create(sim: nil, command: nil, callback_method: :unset, callback_url: :unset # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Array] Array of up to limit results - def list(sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) - self.stream( - sim: sim, - status: status, - direction: direction, - limit: limit, - page_size: page_size - ).entries + def list(eid: :unset, sim_sid: :unset, status: :unset, limit: nil, page_size: nil) + self.stream(eid: eid, sim_sid: sim_sid, status: status, limit: limit, page_size: page_size).entries end ## - # Streams CommandInstance records from the API as an Enumerable. + # Streams EsimProfileInstance records from the API as an Enumerable. # This operation lazily loads records as efficiently as possible until the limit # is reached. - # @param [String] sim The SID or unique name of the Sim that Command was sent to - # or from. - # @param [command.Status] status The status of the Command. Can be: `queued`, - # `sent`, `delivered`, `received` or `failed`. See the {Command Status - # Values}[https://www.twilio.com/docs/wireless/api/command-resource#status-values] - # for a description of each. - # @param [command.Direction] direction The direction of the Command. Can be - # `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term - # `mobile terminated`, and `from_sim` is synonymous with the term `mobile - # originated`. + # @param [String] eid List the eSIM Profiles that have been associated with an + # EId. + # @param [String] sim_sid Find the eSIM Profile resource related to a + # {Sim}[https://www.twilio.com/docs/wireless/api/sim-resource] resource by + # providing the SIM SID. Will always return an array with either 1 or 0 records. + # @param [esim_profile.Status] status List the eSIM Profiles that are in a given + # status. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit. # @param [Integer] page_size Number of records to fetch per request, when @@ -101,16 +87,16 @@ def list(sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Enumerable] Enumerable that will yield up to limit results - def stream(sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) + def stream(eid: :unset, sim_sid: :unset, status: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) - page = self.page(sim: sim, status: status, direction: direction, page_size: limits[:page_size], ) + page = self.page(eid: eid, sim_sid: sim_sid, status: status, page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end ## - # When passed a block, yields CommandInstance records from the API. + # When passed a block, yields EsimProfileInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit # is reached. def each @@ -124,27 +110,24 @@ def each end ## - # Retrieve a single page of CommandInstance records from the API. + # Retrieve a single page of EsimProfileInstance records from the API. # Request is executed immediately. - # @param [String] sim The SID or unique name of the Sim that Command was sent to - # or from. - # @param [command.Status] status The status of the Command. Can be: `queued`, - # `sent`, `delivered`, `received` or `failed`. See the {Command Status - # Values}[https://www.twilio.com/docs/wireless/api/command-resource#status-values] - # for a description of each. - # @param [command.Direction] direction The direction of the Command. Can be - # `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term - # `mobile terminated`, and `from_sim` is synonymous with the term `mobile - # originated`. + # @param [String] eid List the eSIM Profiles that have been associated with an + # EId. + # @param [String] sim_sid Find the eSIM Profile resource related to a + # {Sim}[https://www.twilio.com/docs/wireless/api/sim-resource] resource by + # providing the SIM SID. Will always return an array with either 1 or 0 records. + # @param [esim_profile.Status] status List the eSIM Profiles that are in a given + # status. # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 - # @return [Page] Page of CommandInstance - def page(sim: :unset, status: :unset, direction: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + # @return [Page] Page of EsimProfileInstance + def page(eid: :unset, sim_sid: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ - 'Sim' => sim, + 'Eid' => eid, + 'SimSid' => sim_sid, 'Status' => status, - 'Direction' => direction, 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, @@ -152,38 +135,38 @@ def page(sim: :unset, status: :unset, direction: :unset, page_token: :unset, pag response = @version.page('GET', @uri, params: params) - CommandPage.new(@version, response, @solution) + EsimProfilePage.new(@version, response, @solution) end ## - # Retrieve a single page of CommandInstance records from the API. + # Retrieve a single page of EsimProfileInstance records from the API. # Request is executed immediately. # @param [String] target_url API-generated URL for the requested results page - # @return [Page] Page of CommandInstance + # @return [Page] Page of EsimProfileInstance def get_page(target_url) response = @version.domain.request( 'GET', target_url ) - CommandPage.new(@version, response, @solution) + EsimProfilePage.new(@version, response, @solution) end ## # Provide a user friendly representation def to_s - '#' + '#' end end ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - class CommandPage < Page + class EsimProfilePage < Page ## - # Initialize the CommandPage + # Initialize the EsimProfilePage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource - # @return [CommandPage] CommandPage + # @return [EsimProfilePage] EsimProfilePage def initialize(version, response, solution) super(version, response) @@ -192,69 +175,69 @@ def initialize(version, response, solution) end ## - # Build an instance of CommandInstance + # Build an instance of EsimProfileInstance # @param [Hash] payload Payload response from the API - # @return [CommandInstance] CommandInstance + # @return [EsimProfileInstance] EsimProfileInstance def get_instance(payload) - CommandInstance.new(@version, payload, ) + EsimProfileInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s - '' + '' end end ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - class CommandContext < InstanceContext + class EsimProfileContext < InstanceContext ## - # Initialize the CommandContext + # Initialize the EsimProfileContext # @param [Version] version Version that contains the resource - # @param [String] sid The SID of the Command resource to fetch. - # @return [CommandContext] CommandContext + # @param [String] sid The SID of the eSIM Profile resource to fetch. + # @return [EsimProfileContext] EsimProfileContext def initialize(version, sid) super(version) # Path Solution @solution = {sid: sid, } - @uri = "/Commands/#{@solution[:sid]}" + @uri = "/ESimProfiles/#{@solution[:sid]}" end ## - # Fetch the CommandInstance - # @return [CommandInstance] Fetched CommandInstance + # Fetch the EsimProfileInstance + # @return [EsimProfileInstance] Fetched EsimProfileInstance def fetch payload = @version.fetch('GET', @uri) - CommandInstance.new(@version, payload, sid: @solution[:sid], ) + EsimProfileInstance.new(@version, payload, sid: @solution[:sid], ) end ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') - "#" + "#" end ## # Provide a detailed, user friendly representation def inspect context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') - "#" + "#" end end ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - class CommandInstance < InstanceResource + class EsimProfileInstance < InstanceResource ## - # Initialize the CommandInstance + # Initialize the EsimProfileInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio - # @param [String] sid The SID of the Command resource to fetch. - # @return [CommandInstance] CommandInstance + # @param [String] sid The SID of the eSIM Profile resource to fetch. + # @return [EsimProfileInstance] EsimProfileInstance def initialize(version, payload, sid: nil) super(version) @@ -262,10 +245,13 @@ def initialize(version, payload, sid: nil) @properties = { 'sid' => payload['sid'], 'account_sid' => payload['account_sid'], + 'iccid' => payload['iccid'], 'sim_sid' => payload['sim_sid'], - 'command' => payload['command'], 'status' => payload['status'], - 'direction' => payload['direction'], + 'eid' => payload['eid'], + 'smdp_plus_address' => payload['smdp_plus_address'], + 'error_code' => payload['error_code'], + 'error_message' => payload['error_message'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'url' => payload['url'], @@ -279,10 +265,10 @@ def initialize(version, payload, sid: nil) ## # Generate an instance context for the instance, the context is capable of # performing various actions. All instance actions are proxied to the context - # @return [CommandContext] CommandContext for this CommandInstance + # @return [EsimProfileContext] EsimProfileContext for this EsimProfileInstance def context unless @instance_context - @instance_context = CommandContext.new(@version, @params['sid'], ) + @instance_context = EsimProfileContext.new(@version, @params['sid'], ) end @instance_context end @@ -294,33 +280,51 @@ def sid end ## - # @return [String] The SID of the Account that created the resource + # @return [String] The SID of the Account to which the eSIM Profile resource belongs def account_sid @properties['account_sid'] end ## - # @return [String] The SID of the SIM that this Command was sent to or from - def sim_sid - @properties['sim_sid'] + # @return [String] The ICCID associated with the Sim resource + def iccid + @properties['iccid'] end ## - # @return [String] The message body of the command sent to or from the SIM - def command - @properties['command'] + # @return [String] The SID of the Sim resource that this eSIM Profile controls + def sim_sid + @properties['sim_sid'] end ## - # @return [command.Status] The status of the Command + # @return [esim_profile.Status] The status of the eSIM Profile def status @properties['status'] end ## - # @return [command.Direction] The direction of the Command - def direction - @properties['direction'] + # @return [String] Identifier of the eUICC that can claim the eSIM Profile + def eid + @properties['eid'] + end + + ## + # @return [String] Address of the SM-DP+ server from which the Profile will be downloaded + def smdp_plus_address + @properties['smdp_plus_address'] + end + + ## + # @return [String] Code indicating the failure if the download of the SIM Profile failed and the eSIM Profile is in `failed` state + def error_code + @properties['error_code'] + end + + ## + # @return [String] Error message describing the failure if the download of the SIM Profile failed and the eSIM Profile is in `failed` state + def error_message + @properties['error_message'] end ## @@ -336,14 +340,14 @@ def date_updated end ## - # @return [String] The absolute URL of the Command resource + # @return [String] The absolute URL of the eSIM Profile resource def url @properties['url'] end ## - # Fetch the CommandInstance - # @return [CommandInstance] Fetched CommandInstance + # Fetch the EsimProfileInstance + # @return [EsimProfileInstance] Fetched EsimProfileInstance def fetch context.fetch end @@ -352,14 +356,14 @@ def fetch # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" + "" end ## # Provide a detailed, user friendly representation def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" + "" end end end diff --git a/lib/twilio-ruby/rest/supersim/v1/fleet.rb b/lib/twilio-ruby/rest/supersim/v1/fleet.rb index f0b60e89e..33bc6162c 100644 --- a/lib/twilio-ruby/rest/supersim/v1/fleet.rb +++ b/lib/twilio-ruby/rest/supersim/v1/fleet.rb @@ -39,16 +39,13 @@ def initialize(version) # in Megabytes that each Sim resource assigned to the Fleet resource can consume # during a billing period (normally one month). Value must be between 1MB (1) and # 2TB (2,000,000). Defaults to 1GB (1,000). - # @param [Boolean] commands_enabled Defines whether SIMs in the Fleet are capable - # of sending and receiving machine-to-machine SMS via Commands. Defaults to - # `true`. - # @param [String] commands_url The URL that will receive a webhook when a Super - # SIM in the Fleet is used to send an SMS from your device to the Commands number. - # Your server should respond with an HTTP status code in the 200 range; any - # response body will be ignored. - # @param [String] commands_method A string representing the HTTP method to use - # when making a request to `commands_url`. Can be one of `POST` or `GET`. Defaults - # to `POST`. + # @param [String] ip_commands_url The URL that will receive a webhook when a Super + # SIM in the Fleet is used to send an IP Command from your device to a special IP + # address. Your server should respond with an HTTP status code in the 200 range; + # any response body will be ignored. + # @param [String] ip_commands_method A string representing the HTTP method to use + # when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. + # Defaults to `POST`. # @param [Boolean] sms_commands_enabled Defines whether SIMs in the Fleet are # capable of sending and receiving machine-to-machine SMS via Commands. Defaults # to `true`. @@ -60,15 +57,14 @@ def initialize(version) # when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. # Defaults to `POST`. # @return [FleetInstance] Created FleetInstance - def create(network_access_profile: nil, unique_name: :unset, data_enabled: :unset, data_limit: :unset, commands_enabled: :unset, commands_url: :unset, commands_method: :unset, sms_commands_enabled: :unset, sms_commands_url: :unset, sms_commands_method: :unset) + def create(network_access_profile: nil, unique_name: :unset, data_enabled: :unset, data_limit: :unset, ip_commands_url: :unset, ip_commands_method: :unset, sms_commands_enabled: :unset, sms_commands_url: :unset, sms_commands_method: :unset) data = Twilio::Values.of({ 'NetworkAccessProfile' => network_access_profile, 'UniqueName' => unique_name, 'DataEnabled' => data_enabled, 'DataLimit' => data_limit, - 'CommandsEnabled' => commands_enabled, - 'CommandsUrl' => commands_url, - 'CommandsMethod' => commands_method, + 'IpCommandsUrl' => ip_commands_url, + 'IpCommandsMethod' => ip_commands_method, 'SmsCommandsEnabled' => sms_commands_enabled, 'SmsCommandsUrl' => sms_commands_url, 'SmsCommandsMethod' => sms_commands_method, @@ -244,13 +240,13 @@ def fetch # @param [String] network_access_profile The SID or unique name of the Network # Access Profile that will control which cellular networks the Fleet's SIMs can # connect to. - # @param [String] commands_url The URL that will receive a webhook when a Super - # SIM in the Fleet is used to send an SMS from your device to the Commands number. - # Your server should respond with an HTTP status code in the 200 range; any - # response body will be ignored. - # @param [String] commands_method A string representing the HTTP method to use - # when making a request to `commands_url`. Can be one of `POST` or `GET`. Defaults - # to `POST`. + # @param [String] ip_commands_url The URL that will receive a webhook when a Super + # SIM in the Fleet is used to send an IP Command from your device to a special IP + # address. Your server should respond with an HTTP status code in the 200 range; + # any response body will be ignored. + # @param [String] ip_commands_method A string representing the HTTP method to use + # when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. + # Defaults to `POST`. # @param [String] sms_commands_url The URL that will receive a webhook when a # Super SIM in the Fleet is used to send an SMS from your device to the SMS # Commands number. Your server should respond with an HTTP status code in the 200 @@ -259,12 +255,12 @@ def fetch # when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. # Defaults to `POST`. # @return [FleetInstance] Updated FleetInstance - def update(unique_name: :unset, network_access_profile: :unset, commands_url: :unset, commands_method: :unset, sms_commands_url: :unset, sms_commands_method: :unset) + def update(unique_name: :unset, network_access_profile: :unset, ip_commands_url: :unset, ip_commands_method: :unset, sms_commands_url: :unset, sms_commands_method: :unset) data = Twilio::Values.of({ 'UniqueName' => unique_name, 'NetworkAccessProfile' => network_access_profile, - 'CommandsUrl' => commands_url, - 'CommandsMethod' => commands_method, + 'IpCommandsUrl' => ip_commands_url, + 'IpCommandsMethod' => ip_commands_method, 'SmsCommandsUrl' => sms_commands_url, 'SmsCommandsMethod' => sms_commands_method, }) @@ -312,13 +308,12 @@ def initialize(version, payload, sid: nil) 'data_enabled' => payload['data_enabled'], 'data_limit' => payload['data_limit'].to_i, 'data_metering' => payload['data_metering'], - 'commands_enabled' => payload['commands_enabled'], - 'commands_url' => payload['commands_url'], - 'commands_method' => payload['commands_method'], 'sms_commands_enabled' => payload['sms_commands_enabled'], 'sms_commands_url' => payload['sms_commands_url'], 'sms_commands_method' => payload['sms_commands_method'], 'network_access_profile_sid' => payload['network_access_profile_sid'], + 'ip_commands_url' => payload['ip_commands_url'], + 'ip_commands_method' => payload['ip_commands_method'], } # Context @@ -391,24 +386,6 @@ def data_metering @properties['data_metering'] end - ## - # @return [Boolean] Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands - def commands_enabled - @properties['commands_enabled'] - end - - ## - # @return [String] The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the Commands number - def commands_url - @properties['commands_url'] - end - - ## - # @return [String] A string representing the HTTP method to use when making a request to `commands_url` - def commands_method - @properties['commands_method'] - end - ## # @return [Boolean] Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands def sms_commands_enabled @@ -433,6 +410,18 @@ def network_access_profile_sid @properties['network_access_profile_sid'] end + ## + # @return [String] The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device + def ip_commands_url + @properties['ip_commands_url'] + end + + ## + # @return [String] A string representing the HTTP method to use when making a request to `ip_commands_url` + def ip_commands_method + @properties['ip_commands_method'] + end + ## # Fetch the FleetInstance # @return [FleetInstance] Fetched FleetInstance @@ -448,13 +437,13 @@ def fetch # @param [String] network_access_profile The SID or unique name of the Network # Access Profile that will control which cellular networks the Fleet's SIMs can # connect to. - # @param [String] commands_url The URL that will receive a webhook when a Super - # SIM in the Fleet is used to send an SMS from your device to the Commands number. - # Your server should respond with an HTTP status code in the 200 range; any - # response body will be ignored. - # @param [String] commands_method A string representing the HTTP method to use - # when making a request to `commands_url`. Can be one of `POST` or `GET`. Defaults - # to `POST`. + # @param [String] ip_commands_url The URL that will receive a webhook when a Super + # SIM in the Fleet is used to send an IP Command from your device to a special IP + # address. Your server should respond with an HTTP status code in the 200 range; + # any response body will be ignored. + # @param [String] ip_commands_method A string representing the HTTP method to use + # when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. + # Defaults to `POST`. # @param [String] sms_commands_url The URL that will receive a webhook when a # Super SIM in the Fleet is used to send an SMS from your device to the SMS # Commands number. Your server should respond with an HTTP status code in the 200 @@ -463,12 +452,12 @@ def fetch # when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. # Defaults to `POST`. # @return [FleetInstance] Updated FleetInstance - def update(unique_name: :unset, network_access_profile: :unset, commands_url: :unset, commands_method: :unset, sms_commands_url: :unset, sms_commands_method: :unset) + def update(unique_name: :unset, network_access_profile: :unset, ip_commands_url: :unset, ip_commands_method: :unset, sms_commands_url: :unset, sms_commands_method: :unset) context.update( unique_name: unique_name, network_access_profile: network_access_profile, - commands_url: commands_url, - commands_method: commands_method, + ip_commands_url: ip_commands_url, + ip_commands_method: ip_commands_method, sms_commands_url: sms_commands_url, sms_commands_method: sms_commands_method, ) diff --git a/lib/twilio-ruby/rest/supersim/v1/sms_command.rb b/lib/twilio-ruby/rest/supersim/v1/sms_command.rb index c56ee7c77..486cd148e 100644 --- a/lib/twilio-ruby/rest/supersim/v1/sms_command.rb +++ b/lib/twilio-ruby/rest/supersim/v1/sms_command.rb @@ -28,7 +28,7 @@ def initialize(version) ## # Create the SmsCommandInstance # @param [String] sim The `sid` or `unique_name` of the - # {SIM}[https://www.twilio.com/docs/wireless/api/sim-resource] to send the SMS + # {SIM}[https://www.twilio.com/docs/iot/supersim/api/sim-resource] to send the SMS # Command to. # @param [String] payload The message body of the SMS Command. # @param [String] callback_method The HTTP method we should use to call diff --git a/lib/twilio-ruby/rest/supersim/v1/usage_record.rb b/lib/twilio-ruby/rest/supersim/v1/usage_record.rb index 8b089b6c7..fda0de246 100644 --- a/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +++ b/lib/twilio-ruby/rest/supersim/v1/usage_record.rb @@ -49,9 +49,9 @@ def initialize(version) # @param [Time] start_time Only include usage that occurred at or after this time, # specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default # is one month before the `end_time`. - # @param [Time] end_time Only include usage that occurred before this time, - # specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default - # is the current time. + # @param [Time] end_time Only include usage that occurred before this time + # (exclusive), specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] + # format. Default is the current time. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size Number of records to fetch per request, when @@ -98,9 +98,9 @@ def list(sim: :unset, fleet: :unset, network: :unset, iso_country: :unset, group # @param [Time] start_time Only include usage that occurred at or after this time, # specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default # is one month before the `end_time`. - # @param [Time] end_time Only include usage that occurred before this time, - # specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default - # is the current time. + # @param [Time] end_time Only include usage that occurred before this time + # (exclusive), specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] + # format. Default is the current time. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit. # @param [Integer] page_size Number of records to fetch per request, when @@ -163,9 +163,9 @@ def each # @param [Time] start_time Only include usage that occurred at or after this time, # specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default # is one month before the `end_time`. - # @param [Time] end_time Only include usage that occurred before this time, - # specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default - # is the current time. + # @param [Time] end_time Only include usage that occurred before this time + # (exclusive), specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] + # format. Default is the current time. # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb index af1af44e3..b8179f0c5 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb @@ -101,7 +101,9 @@ def initialize(version, workspace_sid, task_queue_sid) # @param [String] split_by_wait_time A comma separated list of values that # describes the thresholds, in seconds, to calculate statistics on. For each # threshold specified, the number of Tasks canceled and reservations accepted - # above and below the specified thresholds in seconds are computed. + # above and below the specified thresholds in seconds are computed. TaskRouter + # will calculate statistics on up to 10,000 Tasks/Reservations for any given + # threshold. # @return [TaskQueueCumulativeStatisticsInstance] Fetched TaskQueueCumulativeStatisticsInstance def fetch(end_date: :unset, minutes: :unset, start_date: :unset, task_channel: :unset, split_by_wait_time: :unset) params = Twilio::Values.of({ @@ -343,7 +345,9 @@ def url # @param [String] split_by_wait_time A comma separated list of values that # describes the thresholds, in seconds, to calculate statistics on. For each # threshold specified, the number of Tasks canceled and reservations accepted - # above and below the specified thresholds in seconds are computed. + # above and below the specified thresholds in seconds are computed. TaskRouter + # will calculate statistics on up to 10,000 Tasks/Reservations for any given + # threshold. # @return [TaskQueueCumulativeStatisticsInstance] Fetched TaskQueueCumulativeStatisticsInstance def fetch(end_date: :unset, minutes: :unset, start_date: :unset, task_channel: :unset, split_by_wait_time: :unset) context.fetch( diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb index 9255a28b1..7fdbaf52b 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb @@ -105,7 +105,8 @@ def initialize(version, workspace_sid, workflow_sid) # above and below the specified thresholds in seconds are computed. For example, # `5,30` would show splits of Tasks that were canceled or accepted before and # after 5 seconds and before and after 30 seconds. This can be used to show short - # abandoned Tasks or Tasks that failed to meet an SLA. + # abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate + # statistics on up to 10,000 Tasks for any given threshold. # @return [WorkflowCumulativeStatisticsInstance] Fetched WorkflowCumulativeStatisticsInstance def fetch(end_date: :unset, minutes: :unset, start_date: :unset, task_channel: :unset, split_by_wait_time: :unset) params = Twilio::Values.of({ @@ -351,7 +352,8 @@ def url # above and below the specified thresholds in seconds are computed. For example, # `5,30` would show splits of Tasks that were canceled or accepted before and # after 5 seconds and before and after 30 seconds. This can be used to show short - # abandoned Tasks or Tasks that failed to meet an SLA. + # abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate + # statistics on up to 10,000 Tasks for any given threshold. # @return [WorkflowCumulativeStatisticsInstance] Fetched WorkflowCumulativeStatisticsInstance def fetch(end_date: :unset, minutes: :unset, start_date: :unset, task_channel: :unset, split_by_wait_time: :unset) context.fetch( diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb index 0ed5f7952..1df0ef156 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb @@ -97,7 +97,8 @@ def initialize(version, workspace_sid) # above and below the specified thresholds in seconds are computed. For example, # `5,30` would show splits of Tasks that were canceled or accepted before and # after 5 seconds and before and after 30 seconds. This can be used to show short - # abandoned Tasks or Tasks that failed to meet an SLA. + # abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate + # statistics on up to 10,000 Tasks for any given threshold. # @return [WorkspaceCumulativeStatisticsInstance] Fetched WorkspaceCumulativeStatisticsInstance def fetch(end_date: :unset, minutes: :unset, start_date: :unset, task_channel: :unset, split_by_wait_time: :unset) params = Twilio::Values.of({ @@ -328,7 +329,8 @@ def url # above and below the specified thresholds in seconds are computed. For example, # `5,30` would show splits of Tasks that were canceled or accepted before and # after 5 seconds and before and after 30 seconds. This can be used to show short - # abandoned Tasks or Tasks that failed to meet an SLA. + # abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate + # statistics on up to 10,000 Tasks for any given threshold. # @return [WorkspaceCumulativeStatisticsInstance] Fetched WorkspaceCumulativeStatisticsInstance def fetch(end_date: :unset, minutes: :unset, start_date: :unset, task_channel: :unset, split_by_wait_time: :unset) context.fetch( diff --git a/lib/twilio-ruby/rest/verify.rb b/lib/twilio-ruby/rest/verify.rb index bd4ec9149..d59c66793 100644 --- a/lib/twilio-ruby/rest/verify.rb +++ b/lib/twilio-ruby/rest/verify.rb @@ -47,8 +47,8 @@ def services(sid=:unset) end ## - # @param [String] sid A 34 character string that uniquely identifies this - # Verification Attempt. + # @param [String] sid The SID that uniquely identifies the verification attempt + # resource. # @return [Twilio::REST::Verify::V2::VerificationAttemptInstance] if sid was passed. # @return [Twilio::REST::Verify::V2::VerificationAttemptList] def verification_attempts(sid=:unset) diff --git a/lib/twilio-ruby/rest/verify/v2/service.rb b/lib/twilio-ruby/rest/verify/v2/service.rb index 288464dcf..e1a3969c2 100644 --- a/lib/twilio-ruby/rest/verify/v2/service.rb +++ b/lib/twilio-ruby/rest/verify/v2/service.rb @@ -442,8 +442,14 @@ def webhooks(sid=:unset) ## # Access the access_tokens # @return [AccessTokenList] - # @return [AccessTokenContext] - def access_tokens + # @return [AccessTokenContext] if sid was passed. + def access_tokens(sid=:unset) + raise ArgumentError, 'sid cannot be nil' if sid.nil? + + if sid != :unset + return AccessTokenContext.new(@version, @solution[:sid], sid, ) + end + unless @access_tokens @access_tokens = AccessTokenList.new(@version, service_sid: @solution[:sid], ) end diff --git a/lib/twilio-ruby/rest/verify/v2/service/access_token.rb b/lib/twilio-ruby/rest/verify/v2/service/access_token.rb index ddc7a3d74..855eac74c 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/access_token.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/access_token.rb @@ -17,8 +17,7 @@ class AccessTokenList < ListResource ## # Initialize the AccessTokenList # @param [Version] version Version that contains the resource - # @param [String] service_sid The unique string that we created to identify the - # Service resource. + # @param [String] service_sid The unique SID identifier of the Verify Service. # @return [AccessTokenList] AccessTokenList def initialize(version, service_sid: nil) super(version) @@ -37,12 +36,15 @@ def initialize(version, service_sid: nil) # `push` # @param [String] factor_friendly_name The friendly name of the factor that is # going to be created with this access token + # @param [String] ttl How long, in seconds, the access token is valid. Can be an + # integer between 60 and 300. Default is 60. # @return [AccessTokenInstance] Created AccessTokenInstance - def create(identity: nil, factor_type: nil, factor_friendly_name: :unset) + def create(identity: nil, factor_type: nil, factor_friendly_name: :unset, ttl: :unset) data = Twilio::Values.of({ 'Identity' => identity, 'FactorType' => factor_type, 'FactorFriendlyName' => factor_friendly_name, + 'Ttl' => ttl, }) payload = @version.create('POST', @uri, data: data) @@ -88,6 +90,53 @@ def to_s end end + ## + # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + class AccessTokenContext < InstanceContext + ## + # Initialize the AccessTokenContext + # @param [Version] version Version that contains the resource + # @param [String] service_sid The unique SID identifier of the Service. + # @param [String] sid A 34 character string that uniquely identifies this Access + # Token. + # @return [AccessTokenContext] AccessTokenContext + def initialize(version, service_sid, sid) + super(version) + + # Path Solution + @solution = {service_sid: service_sid, sid: sid, } + @uri = "/Services/#{@solution[:service_sid]}/AccessTokens/#{@solution[:sid]}" + end + + ## + # Fetch the AccessTokenInstance + # @return [AccessTokenInstance] Fetched AccessTokenInstance + def fetch + payload = @version.fetch('GET', @uri) + + AccessTokenInstance.new( + @version, + payload, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end + ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. class AccessTokenInstance < InstanceResource @@ -95,14 +144,77 @@ class AccessTokenInstance < InstanceResource # Initialize the AccessTokenInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio - # @param [String] service_sid The unique string that we created to identify the - # Service resource. + # @param [String] service_sid The unique SID identifier of the Verify Service. + # @param [String] sid A 34 character string that uniquely identifies this Access + # Token. # @return [AccessTokenInstance] AccessTokenInstance - def initialize(version, payload, service_sid: nil) + def initialize(version, payload, service_sid: nil, sid: nil) super(version) # Marshaled Properties - @properties = {'token' => payload['token'], } + @properties = { + 'sid' => payload['sid'], + 'account_sid' => payload['account_sid'], + 'service_sid' => payload['service_sid'], + 'entity_identity' => payload['entity_identity'], + 'factor_type' => payload['factor_type'], + 'factor_friendly_name' => payload['factor_friendly_name'], + 'token' => payload['token'], + 'url' => payload['url'], + 'ttl' => payload['ttl'].to_i, + 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), + } + + # Context + @instance_context = nil + @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [AccessTokenContext] AccessTokenContext for this AccessTokenInstance + def context + unless @instance_context + @instance_context = AccessTokenContext.new(@version, @params['service_sid'], @params['sid'], ) + end + @instance_context + end + + ## + # @return [String] A string that uniquely identifies this Access Token. + def sid + @properties['sid'] + end + + ## + # @return [String] Account Sid. + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] Verify Service Sid. + def service_sid + @properties['service_sid'] + end + + ## + # @return [String] Unique external identifier of the Entity + def entity_identity + @properties['entity_identity'] + end + + ## + # @return [access_token.FactorTypes] The Type of the Factor + def factor_type + @properties['factor_type'] + end + + ## + # @return [String] A human readable description of this factor. + def factor_friendly_name + @properties['factor_friendly_name'] end ## @@ -111,16 +223,43 @@ def token @properties['token'] end + ## + # @return [String] The URL of this resource. + def url + @properties['url'] + end + + ## + # @return [String] How long, in seconds, the access token is valid. + def ttl + @properties['ttl'] + end + + ## + # @return [Time] The date this access token was created + def date_created + @properties['date_created'] + end + + ## + # Fetch the AccessTokenInstance + # @return [AccessTokenInstance] Fetched AccessTokenInstance + def fetch + context.fetch + end + ## # Provide a user friendly representation def to_s - "" + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" end ## # Provide a detailed, user friendly representation def inspect - "" + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" end end end diff --git a/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb b/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb index 8fff0e3f1..36a9ab467 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb @@ -277,9 +277,16 @@ def fetch # Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must # be between 3 and 8 characters long. For `Push` this value can be up to 5456 # characters in length + # @param [Hash] metadata Custom metadata associated with the challenge. This is + # added by the Device/SDK directly to allow for the inclusion of device + # information. It must be a stringified JSON with only strings values eg. `{"os": + # "Android"}`. Can be up to 1024 characters in length. # @return [ChallengeInstance] Updated ChallengeInstance - def update(auth_payload: :unset) - data = Twilio::Values.of({'AuthPayload' => auth_payload, }) + def update(auth_payload: :unset, metadata: :unset) + data = Twilio::Values.of({ + 'AuthPayload' => auth_payload, + 'Metadata' => Twilio.serialize_object(metadata), + }) payload = @version.update('POST', @uri, data: data) @@ -358,6 +365,7 @@ def initialize(version, payload, service_sid: nil, identity: nil, sid: nil) 'responded_reason' => payload['responded_reason'], 'details' => payload['details'], 'hidden_details' => payload['hidden_details'], + 'metadata' => payload['metadata'], 'factor_type' => payload['factor_type'], 'url' => payload['url'], 'links' => payload['links'], @@ -468,6 +476,12 @@ def hidden_details @properties['hidden_details'] end + ## + # @return [Hash] Metadata of the challenge. + def metadata + @properties['metadata'] + end + ## # @return [challenge.FactorTypes] The Factor Type of this Challenge def factor_type @@ -499,9 +513,13 @@ def fetch # Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must # be between 3 and 8 characters long. For `Push` this value can be up to 5456 # characters in length + # @param [Hash] metadata Custom metadata associated with the challenge. This is + # added by the Device/SDK directly to allow for the inclusion of device + # information. It must be a stringified JSON with only strings values eg. `{"os": + # "Android"}`. Can be up to 1024 characters in length. # @return [ChallengeInstance] Updated ChallengeInstance - def update(auth_payload: :unset) - context.update(auth_payload: auth_payload, ) + def update(auth_payload: :unset, metadata: :unset) + context.update(auth_payload: auth_payload, metadata: metadata, ) end ## diff --git a/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb b/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb index 06089c80e..ddff92165 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb @@ -293,6 +293,7 @@ def initialize(version, payload, service_sid: nil, identity: nil, sid: nil) 'status' => payload['status'], 'factor_type' => payload['factor_type'], 'config' => payload['config'], + 'metadata' => payload['metadata'], 'url' => payload['url'], } @@ -383,6 +384,12 @@ def config @properties['config'] end + ## + # @return [Hash] Metadata of the factor. + def metadata + @properties['metadata'] + end + ## # @return [String] The URL of this resource. def url diff --git a/lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb b/lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb index 23babbfa8..14155d306 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb @@ -41,9 +41,7 @@ def initialize(version, service_sid: nil, identity: nil) # constructing the `binding.uri` property. # At the same time, we recommend avoiding providing PII. # @param [new_factor.FactorTypes] factor_type The Type of this Factor. Currently - # `push` and `totp` are supported. For `totp` to work, you need to contact {Twilio - # sales}[https://www.twilio.com/help/sales] first to have the Verify TOTP feature - # enabled for your Twilio account. + # `push` and `totp` are supported. # @param [String] binding_alg The algorithm used when `factor_type` is `push`. # Algorithm supported: `ES256` # @param [String] binding_public_key The Ecdsa public key in PKIX, ASN.1 DER @@ -96,8 +94,12 @@ def initialize(version, service_sid: nil, identity: nil) # TOTP codes. Can be `sha1`, `sha256` or `sha512`. Defaults to `sha1`. # # Used when `factor_type` is `totp` + # @param [Hash] metadata Custom metadata associated with the factor. This is added + # by the Device/SDK directly to allow for the inclusion of device information. It + # must be a stringified JSON with only strings values eg. `{"os": "Android"}`. Can + # be up to 1024 characters in length. # @return [NewFactorInstance] Created NewFactorInstance - def create(friendly_name: nil, factor_type: nil, binding_alg: :unset, binding_public_key: :unset, config_app_id: :unset, config_notification_platform: :unset, config_notification_token: :unset, config_sdk_version: :unset, binding_secret: :unset, config_time_step: :unset, config_skew: :unset, config_code_length: :unset, config_alg: :unset) + def create(friendly_name: nil, factor_type: nil, binding_alg: :unset, binding_public_key: :unset, config_app_id: :unset, config_notification_platform: :unset, config_notification_token: :unset, config_sdk_version: :unset, binding_secret: :unset, config_time_step: :unset, config_skew: :unset, config_code_length: :unset, config_alg: :unset, metadata: :unset) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'FactorType' => factor_type, @@ -112,6 +114,7 @@ def create(friendly_name: nil, factor_type: nil, binding_alg: :unset, binding_pu 'Config.Skew' => config_skew, 'Config.CodeLength' => config_code_length, 'Config.Alg' => config_alg, + 'Metadata' => Twilio.serialize_object(metadata), }) payload = @version.create('POST', @uri, data: data) @@ -197,6 +200,7 @@ def initialize(version, payload, service_sid: nil, identity: nil) 'status' => payload['status'], 'factor_type' => payload['factor_type'], 'config' => payload['config'], + 'metadata' => payload['metadata'], 'url' => payload['url'], } end @@ -232,7 +236,7 @@ def identity end ## - # @return [Hash] Unique external identifier of the Entity + # @return [Hash] Binding of the factor def binding @properties['binding'] end @@ -268,11 +272,17 @@ def factor_type end ## - # @return [Hash] Binding for a `factor_type`. + # @return [Hash] Configurations for a `factor_type`. def config @properties['config'] end + ## + # @return [Hash] Metadata of the factor. + def metadata + @properties['metadata'] + end + ## # @return [String] The URL of this resource. def url diff --git a/lib/twilio-ruby/rest/verify/v2/template.rb b/lib/twilio-ruby/rest/verify/v2/template.rb index 2a5d512ce..03573667a 100644 --- a/lib/twilio-ruby/rest/verify/v2/template.rb +++ b/lib/twilio-ruby/rest/verify/v2/template.rb @@ -183,7 +183,7 @@ def friendly_name end ## - # @return [Hash] Ojbect with the template translations. + # @return [Hash] Object with the template translations. def translations @properties['translations'] end diff --git a/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb b/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb index ab8c41524..c0b8efb1c 100644 --- a/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb +++ b/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb @@ -28,11 +28,24 @@ def initialize(version) # Unlike stream(), this operation is eager and will load `limit` records into # memory before returning. # @param [Time] date_created_after Datetime filter used to query Verification - # Attempts created after this datetime. + # Attempts created after this datetime. Given as GMT in RFC 2822 format. # @param [Time] date_created_before Datetime filter used to query Verification - # Attempts created before this datetime. - # @param [String] channel_data_to Destination of a verification. Depending on the - # type of channel, it could be a phone number in E.164 format or an email address. + # Attempts created before this datetime. Given as GMT in RFC 2822 format. + # @param [String] channel_data_to Destination of a verification. It is phone + # number in E.164 format. + # @param [String] country Filter used to query Verification Attempts sent to the + # specified destination country. + # @param [verification_attempt.Channels] channel Filter used to query Verification + # Attempts by communication channel. Valid values are `SMS` and `CALL` + # @param [String] verify_service_sid Filter used to query Verification Attempts by + # verify service. Only attempts of the provided SID will be returned. + # @param [String] verification_sid Filter used to return all the Verification + # Attempts of a single verification. Only attempts of the provided verification + # SID will be returned. + # @param [verification_attempt.ConversionStatus] status Filter used to query + # Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for + # attempts that were not converted, and `CONVERTED`, for attempts that were + # confirmed. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size Number of records to fetch per request, when @@ -40,11 +53,16 @@ def initialize(version) # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Array] Array of up to limit results - def list(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, limit: nil, page_size: nil) + def list(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, country: :unset, channel: :unset, verify_service_sid: :unset, verification_sid: :unset, status: :unset, limit: nil, page_size: nil) self.stream( date_created_after: date_created_after, date_created_before: date_created_before, channel_data_to: channel_data_to, + country: country, + channel: channel, + verify_service_sid: verify_service_sid, + verification_sid: verification_sid, + status: status, limit: limit, page_size: page_size ).entries @@ -55,11 +73,24 @@ def list(date_created_after: :unset, date_created_before: :unset, channel_data_t # This operation lazily loads records as efficiently as possible until the limit # is reached. # @param [Time] date_created_after Datetime filter used to query Verification - # Attempts created after this datetime. + # Attempts created after this datetime. Given as GMT in RFC 2822 format. # @param [Time] date_created_before Datetime filter used to query Verification - # Attempts created before this datetime. - # @param [String] channel_data_to Destination of a verification. Depending on the - # type of channel, it could be a phone number in E.164 format or an email address. + # Attempts created before this datetime. Given as GMT in RFC 2822 format. + # @param [String] channel_data_to Destination of a verification. It is phone + # number in E.164 format. + # @param [String] country Filter used to query Verification Attempts sent to the + # specified destination country. + # @param [verification_attempt.Channels] channel Filter used to query Verification + # Attempts by communication channel. Valid values are `SMS` and `CALL` + # @param [String] verify_service_sid Filter used to query Verification Attempts by + # verify service. Only attempts of the provided SID will be returned. + # @param [String] verification_sid Filter used to return all the Verification + # Attempts of a single verification. Only attempts of the provided verification + # SID will be returned. + # @param [verification_attempt.ConversionStatus] status Filter used to query + # Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for + # attempts that were not converted, and `CONVERTED`, for attempts that were + # confirmed. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit. # @param [Integer] page_size Number of records to fetch per request, when @@ -67,13 +98,18 @@ def list(date_created_after: :unset, date_created_before: :unset, channel_data_t # but a limit is defined, stream() will attempt to read the limit with the most # efficient page size, i.e. min(limit, 1000) # @return [Enumerable] Enumerable that will yield up to limit results - def stream(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, limit: nil, page_size: nil) + def stream(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, country: :unset, channel: :unset, verify_service_sid: :unset, verification_sid: :unset, status: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( date_created_after: date_created_after, date_created_before: date_created_before, channel_data_to: channel_data_to, + country: country, + channel: channel, + verify_service_sid: verify_service_sid, + verification_sid: verification_sid, + status: status, page_size: limits[:page_size], ) @@ -98,20 +134,38 @@ def each # Retrieve a single page of VerificationAttemptInstance records from the API. # Request is executed immediately. # @param [Time] date_created_after Datetime filter used to query Verification - # Attempts created after this datetime. + # Attempts created after this datetime. Given as GMT in RFC 2822 format. # @param [Time] date_created_before Datetime filter used to query Verification - # Attempts created before this datetime. - # @param [String] channel_data_to Destination of a verification. Depending on the - # type of channel, it could be a phone number in E.164 format or an email address. + # Attempts created before this datetime. Given as GMT in RFC 2822 format. + # @param [String] channel_data_to Destination of a verification. It is phone + # number in E.164 format. + # @param [String] country Filter used to query Verification Attempts sent to the + # specified destination country. + # @param [verification_attempt.Channels] channel Filter used to query Verification + # Attempts by communication channel. Valid values are `SMS` and `CALL` + # @param [String] verify_service_sid Filter used to query Verification Attempts by + # verify service. Only attempts of the provided SID will be returned. + # @param [String] verification_sid Filter used to return all the Verification + # Attempts of a single verification. Only attempts of the provided verification + # SID will be returned. + # @param [verification_attempt.ConversionStatus] status Filter used to query + # Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for + # attempts that were not converted, and `CONVERTED`, for attempts that were + # confirmed. # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 # @return [Page] Page of VerificationAttemptInstance - def page(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + def page(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, country: :unset, channel: :unset, verify_service_sid: :unset, verification_sid: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), 'ChannelData.To' => channel_data_to, + 'Country' => country, + 'Channel' => channel, + 'VerifyServiceSid' => verify_service_sid, + 'VerificationSid' => verification_sid, + 'Status' => status, 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, @@ -224,10 +278,12 @@ def initialize(version, payload, sid: nil) 'sid' => payload['sid'], 'account_sid' => payload['account_sid'], 'service_sid' => payload['service_sid'], + 'verification_sid' => payload['verification_sid'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'conversion_status' => payload['conversion_status'], 'channel' => payload['channel'], + 'price' => payload['price'], 'channel_data' => payload['channel_data'], 'url' => payload['url'], } @@ -249,23 +305,29 @@ def context end ## - # @return [String] A string that uniquely identifies this Verification Attempt + # @return [String] The SID that uniquely identifies the verification attempt. def sid @properties['sid'] end ## - # @return [String] Account Sid + # @return [String] The SID of the Account that created the verification. def account_sid @properties['account_sid'] end ## - # @return [String] The service_sid + # @return [String] The SID of the verify service that generated this attempt. def service_sid @properties['service_sid'] end + ## + # @return [String] The SID of the verification that generated this attempt. + def verification_sid + @properties['verification_sid'] + end + ## # @return [Time] The date this Attempt was created def date_created @@ -279,19 +341,25 @@ def date_updated end ## - # @return [verification_attempt.ConversionStatus] Status of a conversion + # @return [verification_attempt.ConversionStatus] Status of the conversion for the verification. def conversion_status @properties['conversion_status'] end ## - # @return [verification_attempt.Channels] Channel used for the attempt + # @return [verification_attempt.Channels] Communication channel used for the attempt. def channel @properties['channel'] end ## - # @return [Hash] Object with the channel information for an attempt + # @return [Hash] An object containing the charge for this verification attempt. + def price + @properties['price'] + end + + ## + # @return [Hash] An object containing the channel specific information for an attempt. def channel_data @properties['channel_data'] end diff --git a/lib/twilio-ruby/rest/video/v1/composition.rb b/lib/twilio-ruby/rest/video/v1/composition.rb index d3d15a1be..68c3fc651 100644 --- a/lib/twilio-ruby/rest/video/v1/composition.rb +++ b/lib/twilio-ruby/rest/video/v1/composition.rb @@ -335,6 +335,8 @@ def initialize(version, payload, sid: nil) 'size' => payload['size'].to_i, 'duration' => payload['duration'].to_i, 'media_external_location' => payload['media_external_location'], + 'status_callback' => payload['status_callback'], + 'status_callback_method' => payload['status_callback_method'], 'url' => payload['url'], 'links' => payload['links'], } @@ -457,6 +459,18 @@ def media_external_location @properties['media_external_location'] end + ## + # @return [String] The URL called to send status information on every composition event. + def status_callback + @properties['status_callback'] + end + + ## + # @return [String] The HTTP method used to call `status_callback` + def status_callback_method + @properties['status_callback_method'] + end + ## # @return [String] The absolute URL of the resource def url diff --git a/lib/twilio-ruby/rest/video/v1/recording.rb b/lib/twilio-ruby/rest/video/v1/recording.rb index a62714b90..6f373f638 100644 --- a/lib/twilio-ruby/rest/video/v1/recording.rb +++ b/lib/twilio-ruby/rest/video/v1/recording.rb @@ -273,6 +273,8 @@ def initialize(version, payload, sid: nil) 'track_name' => payload['track_name'], 'offset' => payload['offset'].to_i, 'media_external_location' => payload['media_external_location'], + 'status_callback' => payload['status_callback'], + 'status_callback_method' => payload['status_callback_method'], 'links' => payload['links'], } @@ -382,6 +384,18 @@ def media_external_location @properties['media_external_location'] end + ## + # @return [String] The URL called to send status information on every recording event. + def status_callback + @properties['status_callback'] + end + + ## + # @return [String] The HTTP method used to call `status_callback` + def status_callback_method + @properties['status_callback_method'] + end + ## # @return [String] The URLs of related resources def links diff --git a/lib/twilio-ruby/rest/video/v1/room.rb b/lib/twilio-ruby/rest/video/v1/room.rb index 3c7144e6d..a5818dace 100644 --- a/lib/twilio-ruby/rest/video/v1/room.rb +++ b/lib/twilio-ruby/rest/video/v1/room.rb @@ -30,10 +30,13 @@ def initialize(version) # `group-small`, or `group`. The default value is `group`. # @param [String] unique_name An application-defined string that uniquely # identifies the resource. It can be used as a `room_sid` in place of the - # resource's `sid` in the URL to address the resource. This value is unique for - # `in-progress` rooms. SDK clients can use this name to connect to the room. REST - # API clients can use this name in place of the Room SID to interact with the room - # as long as the room is `in-progress`. + # resource's `sid` in the URL to address the resource, assuming it does not + # contain any {reserved + # characters}[https://tools.ietf.org/html/rfc3986#section-2.2] that would need to + # be URL encoded. This value is unique for `in-progress` rooms. SDK clients can + # use this name to connect to the room. REST API clients can use this name in + # place of the Room SID to interact with the room as long as the room is + # `in-progress`. # @param [String] status_callback The URL we should call using the # `status_callback_method` to send status information to your application on every # room event. See {Status diff --git a/lib/twilio-ruby/version.rb b/lib/twilio-ruby/version.rb index 2f61ebfd6..72822097b 100644 --- a/lib/twilio-ruby/version.rb +++ b/lib/twilio-ruby/version.rb @@ -1,3 +1,3 @@ module Twilio - VERSION = '5.63.0' + VERSION = '5.66.0' end diff --git a/spec/integration/api/v2010/account/call/siprec_spec.rb b/spec/integration/api/v2010/account/call/siprec_spec.rb index 6f7436d67..a94babef3 100644 --- a/spec/integration/api/v2010/account/call/siprec_spec.rb +++ b/spec/integration/api/v2010/account/call/siprec_spec.rb @@ -35,7 +35,8 @@ "sid": "SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": null, "status": "in-progress", - "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000" + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec/SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ] )) @@ -57,7 +58,8 @@ "sid": "SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "myName", "status": "in-progress", - "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000" + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec/SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ] )) @@ -97,7 +99,8 @@ "sid": "SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": null, "status": "stopped", - "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000" + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec/SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ] )) @@ -119,7 +122,8 @@ "sid": "SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "mySiprec", "status": "stopped", - "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000" + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec/SRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ] )) diff --git a/spec/integration/api/v2010/account/call/stream_spec.rb b/spec/integration/api/v2010/account/call/stream_spec.rb new file mode 100644 index 000000000..66aa2e5b8 --- /dev/null +++ b/spec/integration/api/v2010/account/call/stream_spec.rb @@ -0,0 +1,139 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'Stream' do + it "can create" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .streams.create(url: 'https://example.com') + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Url' => 'https://example.com', } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams.json', + data: values, + ))).to eq(true) + end + + it "receives create_no_args responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "name": null, + "status": "in-progress", + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" + } + ] + )) + + actual = @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .streams.create(url: 'https://example.com') + + expect(actual).to_not eq(nil) + end + + it "receives create_with_args responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "name": "myName", + "status": "in-progress", + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" + } + ] + )) + + actual = @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .streams.create(url: 'https://example.com') + + expect(actual).to_not eq(nil) + end + + it "can update" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .streams('MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'stopped') + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Status' => 'stopped', } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json', + data: values, + ))).to eq(true) + end + + it "receives update_by_sid responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "name": null, + "status": "stopped", + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" + } + ] + )) + + actual = @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .streams('MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'stopped') + + expect(actual).to_not eq(nil) + end + + it "receives update_by_name responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "name": "myStream", + "status": "stopped", + "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/MZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" + } + ] + )) + + actual = @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .streams('MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'stopped') + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/api/v2010/account/call_spec.rb b/spec/integration/api/v2010/account/call_spec.rb index e9dbe5ba9..349aa4ba0 100644 --- a/spec/integration/api/v2010/account/call_spec.rb +++ b/spec/integration/api/v2010/account/call_spec.rb @@ -59,7 +59,8 @@ "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", @@ -109,7 +110,8 @@ "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", @@ -201,7 +203,8 @@ "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+13051913581", "to_formatted": "(305) 191-3581", @@ -268,7 +271,8 @@ "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+13051913581", "to_formatted": "(305) 191-3581", @@ -305,7 +309,8 @@ "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Recordings.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Streams.json" }, "to": "+13051913580", "to_formatted": "(305) 191-3580", @@ -367,7 +372,8 @@ "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+13051913581", "to_formatted": "(305) 191-3581", @@ -404,7 +410,8 @@ "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Recordings.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0/Streams.json" }, "to": "+13051913580", "to_formatted": "(305) 191-3580", @@ -551,7 +558,8 @@ "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", @@ -601,7 +609,8 @@ "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", @@ -651,7 +660,8 @@ "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", @@ -701,7 +711,8 @@ "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json", "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json", "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json", - "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json" + "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json", + "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", diff --git a/spec/integration/api/v2010/account/message_spec.rb b/spec/integration/api/v2010/account/message_spec.rb index ba58b2f2f..56fdfbea6 100644 --- a/spec/integration/api/v2010/account/message_spec.rb +++ b/spec/integration/api/v2010/account/message_spec.rb @@ -231,13 +231,13 @@ "num_segments": "1", "price": null, "price_unit": null, - "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "scheduled", "subresource_uris": { - "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json" + "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json" }, "to": "+15558675310", - "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ] )) @@ -626,13 +626,13 @@ "date_sent": "Fri, 24 May 2019 17:18:28 +0000", "date_updated": "Fri, 24 May 2019 17:18:28 +0000", "direction": "outbound-api", - "error_code": 30007, - "error_message": "Carrier violation", + "error_code": null, + "error_message": null, "from": "+12019235161", "messaging_service_sid": "MGdeadbeefdeadbeefdeadbeefdeadbeef", "num_media": "0", "num_segments": "1", - "price": "-0.00750", + "price": null, "price_unit": "USD", "sid": "SMb7c0a2ce80504485a6f653a7110836f5", "status": "sent", @@ -659,18 +659,18 @@ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", - "body": "", + "body": "Hello World!", "date_created": "Fri, 24 May 2019 17:18:27 +0000", - "date_sent": "Fri, 24 May 2019 17:18:28 +0000", - "date_updated": "Fri, 24 May 2019 17:18:28 +0000", + "date_sent": null, + "date_updated": "Fri, 24 May 2019 18:18:28 +0000", "direction": "outbound-api", - "error_code": 30007, - "error_message": "Carrier violation", - "from": "+12019235161", + "error_code": null, + "error_message": null, + "from": null, "messaging_service_sid": "MGdeadbeefdeadbeefdeadbeefdeadbeef", "num_media": "0", "num_segments": "1", - "price": "-0.00750", + "price": null, "price_unit": "USD", "sid": "SMb7c0a2ce80504485a6f653a7110836f5", "status": "canceled", diff --git a/spec/integration/api/v2010/account/recording_spec.rb b/spec/integration/api/v2010/account/recording_spec.rb index 8ebb04237..8ecc049bc 100644 --- a/spec/integration/api/v2010/account/recording_spec.rb +++ b/spec/integration/api/v2010/account/recording_spec.rb @@ -64,6 +64,46 @@ expect(actual).to_not eq(nil) end + it "receives fetch_include_soft_deleted responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "api_version": "2010-04-01", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "channels": 1, + "date_created": "Mon, 14 Feb 2022 22:23:00 +0100", + "date_updated": "Mon, 14 Feb 2022 22:23:00 +0100", + "start_time": "Mon, 14 Feb 2022 22:23:00 +0100", + "price": "-0.00250", + "price_unit": "USD", + "duration": "4", + "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "source": "StartConferenceRecordingAPI", + "status": "deleted", + "error_code": null, + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", + "subresource_uris": { + "add_on_results": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json", + "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json" + }, + "encryption_details": { + "encryption_public_key_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "encryption_cek": "OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==", + "encryption_iv": "8I2hhNIYNTrwxfHk" + } + } + ] + )) + + actual = @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .recordings('REXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + it "can delete" do @holodeck.mock(Twilio::Response.new(500, '')) @@ -181,4 +221,83 @@ expect(actual).to_not eq(nil) end + + it "receives read_include_soft_deleted responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "end": 0, + "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=2&Page=0", + "next_page_uri": null, + "page": 0, + "page_size": 2, + "previous_page_uri": null, + "recordings": [ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "api_version": "2010-04-01", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "channels": 2, + "date_created": "Mon, 14 Feb 2022 22:23:00 +0100", + "date_updated": "Mon, 14 Feb 2022 22:23:00 +0100", + "start_time": "Mon, 14 Feb 2022 22:23:00 +0100", + "price": "0.04", + "price_unit": "USD", + "duration": "6", + "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "source": "OutboundAPI", + "status": "deleted", + "error_code": null, + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", + "subresource_uris": { + "add_on_results": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json", + "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json" + }, + "encryption_details": { + "encryption_public_key_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "encryption_cek": "OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==", + "encryption_iv": "8I2hhNIYNTrwxfHk" + } + }, + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "api_version": "2010-04-01", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "channels": 2, + "date_created": "Mon, 14 Feb 2022 22:23:00 +0100", + "date_updated": "Mon, 14 Feb 2022 22:23:00 +0100", + "start_time": "Mon, 14 Feb 2022 22:23:00 +0000", + "price": "0.04", + "price_unit": "USD", + "duration": "6", + "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "source": "OutboundAPI", + "status": "completed", + "error_code": null, + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab.json", + "subresource_uris": { + "add_on_results": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/AddOnResults.json", + "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Transcriptions.json" + }, + "encryption_details": { + "encryption_public_key_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "encryption_cek": "OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==", + "encryption_iv": "8I2hhNIYNTrwxfHk" + } + } + ], + "start": 0, + "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=2&Page=0" + } + ] + )) + + actual = @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .recordings.list() + + expect(actual).to_not eq(nil) + end end \ No newline at end of file diff --git a/spec/integration/api/v2010/account/usage/trigger_spec.rb b/spec/integration/api/v2010/account/usage/trigger_spec.rb index cc2b55edf..37ca11d07 100644 --- a/spec/integration/api/v2010/account/usage/trigger_spec.rb +++ b/spec/integration/api/v2010/account/usage/trigger_spec.rb @@ -140,13 +140,13 @@ expect { @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .usage \ - .triggers.create(callback_url: 'https://example.com', trigger_value: 'trigger_value', usage_category: 'agent-conference') + .triggers.create(callback_url: 'https://example.com', trigger_value: 'trigger_value', usage_category: 'a2p-registration-fees') }.to raise_exception(Twilio::REST::TwilioError) values = { 'CallbackUrl' => 'https://example.com', 'TriggerValue' => 'trigger_value', - 'UsageCategory' => 'agent-conference', + 'UsageCategory' => 'a2p-registration-fees', } expect( @holodeck.has_request?(Holodeck::Request.new( @@ -183,7 +183,7 @@ actual = @client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .usage \ - .triggers.create(callback_url: 'https://example.com', trigger_value: 'trigger_value', usage_category: 'agent-conference') + .triggers.create(callback_url: 'https://example.com', trigger_value: 'trigger_value', usage_category: 'a2p-registration-fees') expect(actual).to_not eq(nil) end diff --git a/spec/integration/chat/v1/credential_spec.rb b/spec/integration/chat/v1/credential_spec.rb index 83ff0313d..5f5963417 100644 --- a/spec/integration/chat/v1/credential_spec.rb +++ b/spec/integration/chat/v1/credential_spec.rb @@ -42,10 +42,10 @@ ], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", + "url": "https://chat.twilio.com/v1/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } @@ -66,10 +66,10 @@ "credentials": [], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", + "url": "https://chat.twilio.com/v1/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } diff --git a/spec/integration/chat/v1/service_spec.rb b/spec/integration/chat/v1/service_spec.rb index bfe702331..0c8a59ce3 100644 --- a/spec/integration/chat/v1/service_spec.rb +++ b/spec/integration/chat/v1/service_spec.rb @@ -37,11 +37,14 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, - "links": {}, + "links": { + "channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", @@ -49,7 +52,7 @@ "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], @@ -119,11 +122,14 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, - "links": {}, + "links": { + "channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", @@ -131,7 +137,7 @@ "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], @@ -166,13 +172,13 @@ %q[ { "meta": { - "first_page_url": "https://chat.twilio.com/v1/Services?Page=0&PageSize=50", + "first_page_url": "https://chat.twilio.com/v1/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, - "page_size": 0, + "page_size": 50, "previous_page_url": null, - "url": "https://chat.twilio.com/v1/Services" + "url": "https://chat.twilio.com/v1/Services?PageSize=50&Page=0" }, "services": [] } @@ -190,13 +196,13 @@ %q[ { "meta": { - "first_page_url": "https://chat.twilio.com/v1/Services?Page=0&PageSize=50", + "first_page_url": "https://chat.twilio.com/v1/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, - "page_size": 1, + "page_size": 50, "previous_page_url": null, - "url": "https://chat.twilio.com/v1/Services" + "url": "https://chat.twilio.com/v1/Services?PageSize=50&Page=0" }, "services": [ { @@ -209,24 +215,127 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, + "user_channels": 250, "channel_members": 100, - "user_channels": 250 + "actions_per_second": 30 + }, + "links": { + "channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, + "notifications": { + "added_to_channel": { + "enabled": false, + "template": "notifications.added_to_channel.template" + }, + "invited_to_channel": { + "enabled": false, + "template": "notifications.invited_to_channel.template" + }, + "log_enabled": true, + "new_message": { + "enabled": false, + "template": "notifications.new_message.template" + }, + "removed_from_channel": { + "enabled": false, + "template": "notifications.removed_from_channel.template" + } }, - "links": {}, - "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", - "webhooks": {} + "webhooks": { + "on_channel_add": { + "format": "webhooks.on_channel_add.format", + "method": "webhooks.on_channel_add.method", + "url": "webhooks.on_channel_add.url" + }, + "on_channel_added": { + "format": "webhooks.on_channel_added.format", + "method": "webhooks.on_channel_added.method", + "url": "webhooks.on_channel_added.url" + }, + "on_channel_destroy": { + "format": "webhooks.on_channel_destroy.format", + "method": "webhooks.on_channel_destroy.method", + "url": "webhooks.on_channel_destroy.url" + }, + "on_channel_destroyed": { + "format": "webhooks.on_channel_destroyed.format", + "method": "webhooks.on_channel_destroyed.method", + "url": "webhooks.on_channel_destroyed.url" + }, + "on_channel_update": { + "format": "webhooks.on_channel_update.format", + "method": "webhooks.on_channel_update.method", + "url": "webhooks.on_channel_update.url" + }, + "on_channel_updated": { + "format": "webhooks.on_channel_updated.format", + "method": "webhooks.on_channel_updated.method", + "url": "webhooks.on_channel_updated.url" + }, + "on_member_add": { + "format": "webhooks.on_member_add.format", + "method": "webhooks.on_member_add.method", + "url": "webhooks.on_member_add.url" + }, + "on_member_added": { + "format": "webhooks.on_member_added.format", + "method": "webhooks.on_member_added.method", + "url": "webhooks.on_member_added.url" + }, + "on_member_remove": { + "format": "webhooks.on_member_remove.format", + "method": "webhooks.on_member_remove.method", + "url": "webhooks.on_member_remove.url" + }, + "on_member_removed": { + "format": "webhooks.on_member_removed.format", + "method": "webhooks.on_member_removed.method", + "url": "webhooks.on_member_removed.url" + }, + "on_message_remove": { + "format": "webhooks.on_message_remove.format", + "method": "webhooks.on_message_remove.method", + "url": "webhooks.on_message_remove.url" + }, + "on_message_removed": { + "format": "webhooks.on_message_removed.format", + "method": "webhooks.on_message_removed.method", + "url": "webhooks.on_message_removed.url" + }, + "on_message_send": { + "format": "webhooks.on_message_send.format", + "method": "webhooks.on_message_send.method", + "url": "webhooks.on_message_send.url" + }, + "on_message_sent": { + "format": "webhooks.on_message_sent.format", + "method": "webhooks.on_message_sent.method", + "url": "webhooks.on_message_sent.url" + }, + "on_message_update": { + "format": "webhooks.on_message_update.format", + "method": "webhooks.on_message_update.method", + "url": "webhooks.on_message_update.url" + }, + "on_message_updated": { + "format": "webhooks.on_message_updated.format", + "method": "webhooks.on_message_updated.method", + "url": "webhooks.on_message_updated.url" + } + } } ] } @@ -266,24 +375,125 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, "channel_members": 500, "user_channels": 600 }, - "links": {}, - "notifications": {}, + "links": { + "channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, + "notifications": { + "added_to_channel": { + "enabled": false, + "template": "notifications.added_to_channel.template" + }, + "invited_to_channel": { + "enabled": false, + "template": "notifications.invited_to_channel.template" + }, + "new_message": { + "enabled": false, + "template": "notifications.new_message.template" + }, + "removed_from_channel": { + "enabled": false, + "template": "notifications.removed_from_channel.template" + } + }, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", - "webhooks": {} + "webhooks": { + "on_channel_add": { + "format": "webhooks.on_channel_add.format", + "method": "webhooks.on_channel_add.method", + "url": "webhooks.on_channel_add.url" + }, + "on_channel_added": { + "format": "webhooks.on_channel_added.format", + "method": "webhooks.on_channel_added.method", + "url": "webhooks.on_channel_added.url" + }, + "on_channel_destroy": { + "format": "webhooks.on_channel_destroy.format", + "method": "webhooks.on_channel_destroy.method", + "url": "webhooks.on_channel_destroy.url" + }, + "on_channel_destroyed": { + "format": "webhooks.on_channel_destroyed.format", + "method": "webhooks.on_channel_destroyed.method", + "url": "webhooks.on_channel_destroyed.url" + }, + "on_channel_update": { + "format": "webhooks.on_channel_update.format", + "method": "webhooks.on_channel_update.method", + "url": "webhooks.on_channel_update.url" + }, + "on_channel_updated": { + "format": "webhooks.on_channel_updated.format", + "method": "webhooks.on_channel_updated.method", + "url": "webhooks.on_channel_updated.url" + }, + "on_member_add": { + "format": "webhooks.on_member_add.format", + "method": "webhooks.on_member_add.method", + "url": "webhooks.on_member_add.url" + }, + "on_member_added": { + "format": "webhooks.on_member_added.format", + "method": "webhooks.on_member_added.method", + "url": "webhooks.on_member_added.url" + }, + "on_member_remove": { + "format": "webhooks.on_member_remove.format", + "method": "webhooks.on_member_remove.method", + "url": "webhooks.on_member_remove.url" + }, + "on_member_removed": { + "format": "webhooks.on_member_removed.format", + "method": "webhooks.on_member_removed.method", + "url": "webhooks.on_member_removed.url" + }, + "on_message_remove": { + "format": "webhooks.on_message_remove.format", + "method": "webhooks.on_message_remove.method", + "url": "webhooks.on_message_remove.url" + }, + "on_message_removed": { + "format": "webhooks.on_message_removed.format", + "method": "webhooks.on_message_removed.method", + "url": "webhooks.on_message_removed.url" + }, + "on_message_send": { + "format": "webhooks.on_message_send.format", + "method": "webhooks.on_message_send.method", + "url": "webhooks.on_message_send.url" + }, + "on_message_sent": { + "format": "webhooks.on_message_sent.format", + "method": "webhooks.on_message_sent.method", + "url": "webhooks.on_message_sent.url" + }, + "on_message_update": { + "format": "webhooks.on_message_update.format", + "method": "webhooks.on_message_update.method", + "url": "webhooks.on_message_update.url" + }, + "on_message_updated": { + "format": "webhooks.on_message_updated.format", + "method": "webhooks.on_message_updated.method", + "url": "webhooks.on_message_updated.url" + } + } } ] )) diff --git a/spec/integration/chat/v2/credential_spec.rb b/spec/integration/chat/v2/credential_spec.rb index 308b99933..a4bc5fa84 100644 --- a/spec/integration/chat/v2/credential_spec.rb +++ b/spec/integration/chat/v2/credential_spec.rb @@ -42,10 +42,10 @@ ], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", + "url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } @@ -66,10 +66,10 @@ "credentials": [], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", + "url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } diff --git a/spec/integration/chat/v2/service/user/user_channel_spec.rb b/spec/integration/chat/v2/service/user/user_channel_spec.rb index f718460db..19439b22b 100644 --- a/spec/integration/chat/v2/service/user/user_channel_spec.rb +++ b/spec/integration/chat/v2/service/user/user_channel_spec.rb @@ -146,13 +146,15 @@ expect { @client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ - .user_channels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() + .user_channels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete(x_twilio_webhook_enabled: 'true') }.to raise_exception(Twilio::REST::TwilioError) + headers = {'X-Twilio-Webhook-Enabled' => 'true', } expect( @holodeck.has_request?(Holodeck::Request.new( method: 'delete', url: 'https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + headers: headers, ))).to eq(true) end diff --git a/spec/integration/chat/v3/channel_spec.rb b/spec/integration/chat/v3/channel_spec.rb new file mode 100644 index 000000000..6cb934870 --- /dev/null +++ b/spec/integration/chat/v3/channel_spec.rb @@ -0,0 +1,55 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'Channel' do + it "can update" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.chat.v3.channels('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(x_twilio_webhook_enabled: 'true') + }.to raise_exception(Twilio::REST::TwilioError) + + headers = {'X-Twilio-Webhook-Enabled' => 'true', } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://chat.twilio.com/v3/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + headers: headers, + ))).to eq(true) + end + + it "receives update responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "friendly_name", + "unique_name": "unique_name", + "attributes": "{ \\"foo\\": \\"bar\\" }", + "type": "public", + "date_created": "2015-12-16T22:18:37Z", + "date_updated": "2015-12-16T22:18:38Z", + "created_by": "username", + "members_count": 0, + "messages_count": 0, + "url": "https://chat.twilio.com/v3/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.chat.v3.channels('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/conversations/v1/address_configuration_spec.rb b/spec/integration/conversations/v1/address_configuration_spec.rb new file mode 100644 index 000000000..181b91827 --- /dev/null +++ b/spec/integration/conversations/v1/address_configuration_spec.rb @@ -0,0 +1,290 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'AddressConfiguration' do + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.conversations.v1.address_configurations.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://conversations.twilio.com/v1/Configuration/Addresses', + ))).to eq(true) + end + + it "receives read_all responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://conversations.twilio.com/v1/Configuration/Addresses?PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://conversations.twilio.com/v1/Configuration/Addresses?PageSize=50&Page=0", + "next_page_url": null, + "key": "address_configurations" + }, + "address_configurations": [ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "address": "+37256123457", + "type": "sms", + "friendly_name": "My Test Configuration", + "auto_creation": { + "enabled": true, + "type": "webhook", + "conversation_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "webhook_url": "https://example.com", + "webhook_method": "POST", + "webhook_filters": [ + "onParticipantAdded", + "onMessageAdded" + ] + }, + "date_created": "2016-03-24T21:05:50Z", + "date_updated": "2016-03-24T21:05:50Z", + "url": "https://conversations.twilio.com/v1/Configuration/Addresses/IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "address": "+37256123458", + "type": "sms", + "friendly_name": "Studio Test Configuration", + "auto_creation": { + "enabled": false, + "type": "studio", + "conversation_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "studio_flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "studio_retry_count": 3 + }, + "date_created": "2016-03-24T21:05:50Z", + "date_updated": "2016-03-24T21:05:50Z", + "url": "https://conversations.twilio.com/v1/Configuration/Addresses/IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab" + }, + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac", + "address": "+37256123459", + "type": "sms", + "friendly_name": "Default Test Configuration", + "auto_creation": { + "enabled": true, + "type": "default" + }, + "date_created": "2016-03-24T21:05:50Z", + "date_updated": "2016-03-24T21:05:50Z", + "url": "https://conversations.twilio.com/v1/Configuration/Addresses/IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac" + } + ] + } + ] + )) + + actual = @client.conversations.v1.address_configurations.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_blank responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://conversations.twilio.com/v1/Configuration/Addresses?PageSize=50&Page=0", + "url": "https://conversations.twilio.com/v1/Configuration/Addresses?PageSize=50&Page=0", + "previous_page_url": null, + "next_page_url": null, + "key": "address_configurations" + }, + "address_configurations": [] + } + ] + )) + + actual = @client.conversations.v1.address_configurations.list() + + expect(actual).to_not eq(nil) + end + + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.conversations.v1.address_configurations('IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://conversations.twilio.com/v1/Configuration/Addresses/IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "address": "+37256123457", + "type": "sms", + "friendly_name": "My Test Configuration", + "auto_creation": { + "enabled": true, + "type": "webhook", + "conversation_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "webhook_url": "https://example.com", + "webhook_method": "POST", + "webhook_filters": [ + "onParticipantAdded", + "onMessageAdded" + ] + }, + "date_created": "2016-03-24T21:05:50Z", + "date_updated": "2016-03-24T21:05:50Z", + "url": "https://conversations.twilio.com/v1/Configuration/Addresses/IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.conversations.v1.address_configurations('IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + + it "can create" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.conversations.v1.address_configurations.create(type: 'sms', address: 'address') + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Type' => 'sms', 'Address' => 'address', } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://conversations.twilio.com/v1/Configuration/Addresses', + data: values, + ))).to eq(true) + end + + it "receives create responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "address": "+37256123457", + "type": "sms", + "friendly_name": "My Test Configuration", + "auto_creation": { + "enabled": true, + "type": "webhook", + "conversation_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "webhook_url": "https://example.com", + "webhook_method": "POST", + "webhook_filters": [ + "onParticipantAdded", + "onMessageAdded" + ] + }, + "date_created": "2016-03-24T21:05:50Z", + "date_updated": "2016-03-24T21:05:50Z", + "url": "https://conversations.twilio.com/v1/Configuration/Addresses/IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.conversations.v1.address_configurations.create(type: 'sms', address: 'address') + + expect(actual).to_not eq(nil) + end + + it "can update" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.conversations.v1.address_configurations('IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://conversations.twilio.com/v1/Configuration/Addresses/IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives update responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "address": "+37256123457", + "type": "sms", + "friendly_name": "My Test Configuration Updated", + "auto_creation": { + "enabled": false, + "type": "studio", + "conversation_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "studio_flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "studio_retry_count": 3 + }, + "date_created": "2016-03-24T21:05:50Z", + "date_updated": "2016-03-24T21:05:51Z", + "url": "https://conversations.twilio.com/v1/Configuration/Addresses/IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.conversations.v1.address_configurations('IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() + + expect(actual).to_not eq(nil) + end + + it "can delete" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.conversations.v1.address_configurations('IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'delete', + url: 'https://conversations.twilio.com/v1/Configuration/Addresses/IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives delete responses" do + @holodeck.mock(Twilio::Response.new( + 204, + nil, + )) + + actual = @client.conversations.v1.address_configurations('IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() + + expect(actual).to eq(true) + end +end \ No newline at end of file diff --git a/spec/integration/fax/v1/fax_spec.rb b/spec/integration/fax/v1/fax_spec.rb index 96cbd81dc..ae789894b 100644 --- a/spec/integration/fax/v1/fax_spec.rb +++ b/spec/integration/fax/v1/fax_spec.rb @@ -142,104 +142,6 @@ expect(actual).to_not eq(nil) end - it "can create" do - @holodeck.mock(Twilio::Response.new(500, '')) - - expect { - @client.fax.v1.faxes.create(to: 'to', media_url: 'https://example.com') - }.to raise_exception(Twilio::REST::TwilioError) - - values = {'To' => 'to', 'MediaUrl' => 'https://example.com', } - expect( - @holodeck.has_request?(Holodeck::Request.new( - method: 'post', - url: 'https://fax.twilio.com/v1/Faxes', - data: values, - ))).to eq(true) - end - - it "receives create responses" do - @holodeck.mock(Twilio::Response.new( - 201, - %q[ - { - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "api_version": "v1", - "date_created": "2015-07-30T20:00:00Z", - "date_updated": "2015-07-30T20:00:00Z", - "direction": "outbound", - "from": "+14155551234", - "media_url": null, - "media_sid": null, - "num_pages": null, - "price": null, - "price_unit": null, - "quality": "superfine", - "sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "status": "queued", - "to": "+14155554321", - "duration": null, - "links": { - "media": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" - }, - "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - } - ] - )) - - actual = @client.fax.v1.faxes.create(to: 'to', media_url: 'https://example.com') - - expect(actual).to_not eq(nil) - end - - it "can update" do - @holodeck.mock(Twilio::Response.new(500, '')) - - expect { - @client.fax.v1.faxes('FXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() - }.to raise_exception(Twilio::REST::TwilioError) - - expect( - @holodeck.has_request?(Holodeck::Request.new( - method: 'post', - url: 'https://fax.twilio.com/v1/Faxes/FXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - ))).to eq(true) - end - - it "receives update responses" do - @holodeck.mock(Twilio::Response.new( - 200, - %q[ - { - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "api_version": "v1", - "date_created": "2015-07-30T20:00:00Z", - "date_updated": "2015-07-30T20:00:00Z", - "direction": "outbound", - "from": "+14155551234", - "media_url": null, - "media_sid": null, - "num_pages": null, - "price": null, - "price_unit": null, - "quality": "fine", - "sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "status": "canceled", - "to": "+14155554321", - "duration": null, - "links": { - "media": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" - }, - "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - } - ] - )) - - actual = @client.fax.v1.faxes('FXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() - - expect(actual).to_not eq(nil) - end - it "can delete" do @holodeck.mock(Twilio::Response.new(500, '')) diff --git a/spec/integration/flex_api/v1/configuration_spec.rb b/spec/integration/flex_api/v1/configuration_spec.rb index 43726a33a..dcab2a253 100644 --- a/spec/integration/flex_api/v1/configuration_spec.rb +++ b/spec/integration/flex_api/v1/configuration_spec.rb @@ -204,7 +204,46 @@ }, "url": "https://flex-api.twilio.com/v1/Configuration", "flex_insights_drilldown": true, - "flex_url": "https://flex.twilio.com" + "flex_url": "https://flex.twilio.com", + "channel_configs": [ + { + "address_type": "sms", + "cbm_attachments": { + "enabled": true, + "number_of_attachments": 10, + "max_file_size": 157286400, + "max_total_file_size": 157286400, + "accepted_extensions": [ + "jpg", + "jpeg", + "png", + "gif", + "txt", + "pdf" + ] + } + }, + { + "address_type": "whatsapp", + "cbm_attachments": { + "enabled": true, + "number_of_attachments": 1, + "max_file_size": 16777216, + "max_total_file_size": 67108864, + "accepted_extensions": [ + "jpg", + "jpeg", + "png", + "amr", + "mp3", + "mp4", + "pdf", + "heic", + "oga" + ] + } + } + ] } ] )) @@ -396,7 +435,26 @@ "flex_insights_hr": null, "url": "https://flex-api.twilio.com/v1/Configuration", "flex_insights_drilldown": false, - "flex_url": "https://flex.twilio.com" + "flex_url": "https://flex.twilio.com", + "channel_configs": [ + { + "address_type": "sms", + "cbm_attachments": { + "enabled": true, + "number_of_attachments": 10, + "max_file_size": 157286400, + "max_total_file_size": 157286400, + "accepted_extensions": [ + "jpg", + "jpeg", + "png", + "gif", + "txt", + "pdf" + ] + } + } + ] } ] )) @@ -601,7 +659,26 @@ }, "url": "https://flex-api.twilio.com/v1/Configuration", "flex_insights_drilldown": true, - "flex_url": "https://flex.twilio.com" + "flex_url": "https://flex.twilio.com", + "channel_configs": [ + { + "address_type": "sms", + "cbm_attachments": { + "enabled": true, + "number_of_attachments": 10, + "max_file_size": 157286400, + "max_total_file_size": 157286400, + "accepted_extensions": [ + "jpg", + "jpeg", + "png", + "gif", + "txt", + "pdf" + ] + } + } + ] } ] )) diff --git a/spec/integration/flex_api/v1/interaction/interaction_channel/interaction_channel_invite_spec.rb b/spec/integration/flex_api/v1/interaction/interaction_channel/interaction_channel_invite_spec.rb new file mode 100644 index 000000000..8930b560b --- /dev/null +++ b/spec/integration/flex_api/v1/interaction/interaction_channel/interaction_channel_invite_spec.rb @@ -0,0 +1,182 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'InteractionChannelInvite' do + it "can create" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .invites.create(routing: {}) + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Routing' => Twilio.serialize_object({}), } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Invites', + data: values, + ))).to eq(true) + end + + it "receives create responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "sid": "KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "routing": { + "properties": { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "date_created": 1634845217, + "date_updated": 1634845217, + "attributes": "{\\"customerAddress\\":\\"customer email address\\",\\"conversationSid\\":\\"UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1\\",\\"customerName\\":\\"customer name\\"}", + "assignment_status": "pending", + "workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "workflow_name": "Default Fifo Workflow", + "queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "queue_name": "Sample Queue", + "priority": 0, + "age": 0, + "reason": null, + "timeout": 86400, + "assignmentCounter": 0, + "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_channel_unique_name": "default", + "routing_target": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_queue_entered_date": 1634845217, + "age_in_queue": 0, + "addons": "{}" + } + }, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites/KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .invites.create(routing: {}) + + expect(actual).to_not eq(nil) + end + + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .invites.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Invites', + ))).to eq(true) + end + + it "receives read responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "invites": [ + { + "sid": "KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "routing": { + "properties": { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "date_created": 1634845217, + "date_updated": 1634845217, + "attributes": "{\\"customerAddress\\":\\"customer email address\\",\\"conversationSid\\":\\"UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1\\",\\"customerName\\":\\"customer name\\"}", + "assignment_status": "pending", + "workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "workflow_name": "Default Fifo Workflow", + "queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "queue_name": "Sample Queue", + "priority": 0, + "age": 0, + "reason": null, + "timeout": 86400, + "assignmentCounter": 0, + "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_channel_unique_name": "default", + "routing_target": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_queue_entered_date": 1634845217, + "age_in_queue": 0, + "addons": "{}" + } + }, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites/KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1" + }, + { + "sid": "KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "routing": { + "properties": { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "date_created": 1634845217, + "date_updated": 1634845217, + "attributes": "{\\"customerAddress\\":\\"customer email address\\",\\"conversationSid\\":\\"UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1\\",\\"customerName\\":\\"customer name\\"}", + "assignment_status": "pending", + "workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "workflow_name": "Default Fifo Workflow", + "queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "queue_name": "Sample Queue", + "priority": 0, + "age": 0, + "reason": null, + "timeout": 86400, + "assignmentCounter": 0, + "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_channel_unique_name": "default", + "routing_target": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_queue_entered_date": 1634845217, + "age_in_queue": 0, + "addons": "{}" + } + }, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites/KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2" + } + ], + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites?PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites?PageSize=50&Page=0", + "next_page_url": null, + "key": "invites" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .invites.list() + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/flex_api/v1/interaction/interaction_channel/interaction_channel_participant_spec.rb b/spec/integration/flex_api/v1/interaction/interaction_channel/interaction_channel_participant_spec.rb new file mode 100644 index 000000000..326cd780c --- /dev/null +++ b/spec/integration/flex_api/v1/interaction/interaction_channel/interaction_channel_participant_spec.rb @@ -0,0 +1,167 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'InteractionChannelParticipant' do + it "can create" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .participants.create(type: 'supervisor', media_properties: {}) + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Type' => 'supervisor', 'MediaProperties' => Twilio.serialize_object({}), } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants', + data: values, + ))).to eq(true) + end + + it "receives create responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "type": "customer", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1" + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .participants.create(type: 'supervisor', media_properties: {}) + + expect(actual).to_not eq(nil) + end + + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .participants.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants', + ))).to eq(true) + end + + it "receives read responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "participants": [ + { + "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "type": "customer", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1" + }, + { + "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "type": "agent", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2" + } + ], + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants?PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants?PageSize=50&Page=0", + "next_page_url": null, + "key": "participants" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .participants.list() + + expect(actual).to_not eq(nil) + end + + it "can update" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .participants('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'close') + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Status' => 'close', } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + data: values, + ))).to eq(true) + end + + it "receives update responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "type": "agent", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1" + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .participants('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'close') + + expect(actual).to_not eq(nil) + end + + it "receives update_status_closed responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "channel_sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "type": "agent", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1" + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .participants('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'close') + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/flex_api/v1/interaction/interaction_channel_spec.rb b/spec/integration/flex_api/v1/interaction/interaction_channel_spec.rb new file mode 100644 index 000000000..1000ea0a8 --- /dev/null +++ b/spec/integration/flex_api/v1/interaction/interaction_channel_spec.rb @@ -0,0 +1,173 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'InteractionChannel' do + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "type": "chat", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "links": { + "participants": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants", + "invites": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels', + ))).to eq(true) + end + + it "receives read responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "channels": [ + { + "sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "type": "chat", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "links": { + "participants": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants", + "invites": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites" + } + }, + { + "sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2", + "type": "sms", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2", + "links": { + "participants": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2/Participants", + "invites": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2/Invites" + } + } + ], + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", + "next_page_url": null, + "key": "channels" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels.list() + + expect(actual).to_not eq(nil) + end + + it "can update" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'close') + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Status' => 'close', } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + data: values, + ))).to eq(true) + end + + it "receives update responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "type": "chat", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "links": { + "participants": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants", + "invites": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'close') + + expect(actual).to_not eq(nil) + end + + it "receives update_status_closed responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "interaction_sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "type": "chat", + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", + "links": { + "participants": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Participants", + "invites": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/Invites" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .channels('UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(status: 'close') + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/flex_api/v1/interaction_spec.rb b/spec/integration/flex_api/v1/interaction_spec.rb new file mode 100644 index 000000000..86f19937e --- /dev/null +++ b/spec/integration/flex_api/v1/interaction_spec.rb @@ -0,0 +1,103 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'Interaction' do + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "channel": { + "type": "email" + }, + "routing": { + "properties": { + "workflow_sid": "WWxx", + "attributes": "WWxx", + "task_channel_unique_name": "email", + "routing_target": "WKXX", + "queue_name": "WQXX" + } + }, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "channels": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction('KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + + it "can create" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.flex_api.v1.interaction.create(channel: {}, routing: {}) + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Channel' => Twilio.serialize_object({}), 'Routing' => Twilio.serialize_object({}), } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://flex-api.twilio.com/v1/Interactions', + data: values, + ))).to eq(true) + end + + it "receives create responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "channel": { + "type": "email" + }, + "routing": { + "properties": { + "workflow_sid": "WWxx", + "attributes": "WWxx", + "task_channel_unique_name": "email", + "routing_target": "WKXX", + "queue_name": "WQXX" + } + }, + "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "channels": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" + } + } + ] + )) + + actual = @client.flex_api.v1.interaction.create(channel: {}, routing: {}) + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/insights/v1/annotation_spec.rb b/spec/integration/insights/v1/annotation_spec.rb new file mode 100644 index 000000000..8a84b0a85 --- /dev/null +++ b/spec/integration/insights/v1/annotation_spec.rb @@ -0,0 +1,91 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'Annotation' do + it "can update" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.insights.v1.annotation('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://insights.twilio.com/v1/Voice/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Annotation', + ))).to eq(true) + end + + it "receives update responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "answered_by": "human", + "connectivity_issue": "invalid_number", + "quality_issues": [ + "low_volume" + ], + "spam": true, + "call_score": 2, + "comment": "this is a call", + "incident": "https://twilio.zendesk.com/support/tickets/17353089", + "url": "https://insights.twilio.com/v1/Voice/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Annotation" + } + ] + )) + + actual = @client.insights.v1.annotation('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() + + expect(actual).to_not eq(nil) + end + + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.insights.v1.annotation('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://insights.twilio.com/v1/Voice/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Annotation', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "answered_by": "human", + "connectivity_issue": "invalid_number", + "quality_issues": [ + "low_volume" + ], + "spam": true, + "call_score": 2, + "comment": "this is a call", + "incident": "https://twilio.zendesk.com/support/tickets/17353089", + "url": "https://insights.twilio.com/v1/Voice/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Annotation" + } + ] + )) + + actual = @client.insights.v1.annotation('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/insights/v1/conference/conference_participant_spec.rb b/spec/integration/insights/v1/conference/conference_participant_spec.rb new file mode 100644 index 000000000..1c7a37efe --- /dev/null +++ b/spec/integration/insights/v1/conference/conference_participant_spec.rb @@ -0,0 +1,377 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'ConferenceParticipant' do + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .conference_participants('CPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://insights.twilio.com/v1/Conferences/CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants/CPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "participant_sid": "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "label": null, + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_direction": "outbound", + "from": "+10000000000", + "to": "+1000000001", + "call_status": "completed", + "country_code": "US", + "is_moderator": true, + "join_time": "2021-10-08T02:58:59Z", + "leave_time": "2021-10-08T03:00:02Z", + "duration_seconds": 64, + "outbound_queue_length": 0, + "outbound_time_in_queue": 965, + "jitter_buffer_size": null, + "is_coach": false, + "coached_participants": null, + "participant_region": "us1", + "conference_region": "us1", + "call_type": "carrier", + "processing_state": "complete", + "properties": { + "start_conference_on_enter": false, + "end_conference_on_exit": false, + "play_early_media": false, + "enter_muted": true, + "beep_on_enter": false, + "beep_on_exit": false + }, + "events": { + "mute": [ + 1633705131000 + ] + }, + "metrics": { + "inbound": { + "total_packets_lost": 0, + "total_packets_received": 49, + "packet_loss_percentage": 0.0, + "jitter": { + "avg": 0.34, + "max": 0.53 + }, + "latency": { + "avg": 0.0, + "max": 0.0 + }, + "mos": 4.4 + }, + "outbound": { + "total_packets_lost": 0, + "total_packets_received": 126, + "packet_loss_percentage": 0, + "jitter": { + "avg": 0.01, + "max": 0.01 + }, + "latency": { + "avg": 0, + "max": 0 + }, + "mos": 4.4 + } + }, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .conference_participants('CPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .conference_participants.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://insights.twilio.com/v1/Conferences/CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants', + ))).to eq(true) + end + + it "receives read_full responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 25, + "first_page_url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0", + "previous_page_url": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0", + "next_page_url": null, + "key": "participants" + }, + "participants": [ + { + "participant_sid": "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "label": null, + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_direction": "outbound", + "from": "+10000000000", + "to": "+10000000001", + "call_status": "completed", + "country_code": "US", + "is_moderator": true, + "join_time": "2021-10-08T02:58:51Z", + "leave_time": "2021-10-08T02:59:55Z", + "duration_seconds": 65, + "outbound_queue_length": 0, + "outbound_time_in_queue": 3361, + "jitter_buffer_size": null, + "is_coach": false, + "coached_participants": null, + "participant_region": "us1", + "conference_region": "us1", + "call_type": "carrier", + "processing_state": "complete", + "properties": { + "start_conference_on_enter": true, + "end_conference_on_exit": false, + "play_early_media": true, + "enter_muted": false, + "beep_on_enter": false, + "beep_on_exit": false + }, + "metrics": { + "inbound": { + "total_packets_lost": 0, + "total_packets_received": 70, + "packet_loss_percentage": 0.0, + "jitter": { + "avg": 0.41, + "max": 0.84 + }, + "latency": { + "avg": 0.0, + "max": 0.0 + }, + "mos": 4.4 + }, + "outbound": { + "total_packets_lost": 0, + "total_packets_received": 126, + "packet_loss_percentage": 0, + "jitter": { + "avg": 0.01, + "max": 0.01 + }, + "latency": { + "avg": 0, + "max": 0 + }, + "mos": 4.4 + } + }, + "events": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + { + "participant_sid": "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "label": null, + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_direction": "outbound", + "from": "+10000000000", + "to": "+10000000002", + "call_status": "completed", + "country_code": "US", + "is_moderator": true, + "join_time": "2021-10-08T02:58:52Z", + "leave_time": "2021-10-08T02:59:54Z", + "duration_seconds": 63, + "outbound_queue_length": 0, + "outbound_time_in_queue": 321, + "jitter_buffer_size": null, + "is_coach": false, + "coached_participants": null, + "participant_region": "us1", + "conference_region": "us1", + "call_type": "carrier", + "processing_state": "complete", + "properties": { + "start_conference_on_enter": false, + "end_conference_on_exit": false, + "early_media": false, + "enter_muted": true, + "beep_on_enter": false, + "beep_on_exit": false + }, + "metrics": { + "inbound": { + "total_packets_lost": 0, + "total_packets_received": 16, + "packet_loss_percentage": 0, + "jitter": { + "avg": 0.26, + "max": 0.45 + }, + "latency": { + "avg": 0, + "max": 0 + }, + "mos": 4.4 + }, + "outbound": { + "total_packets_lost": 0, + "total_packets_received": 42, + "packet_loss_percentage": 0, + "jitter": { + "avg": 0.03, + "max": 0.08 + }, + "latency": { + "avg": 0, + "max": 0 + }, + "mos": 4.4, + "tags": [ + "silent" + ] + } + }, + "events": { + "mute": [ + 1633705131000 + ] + }, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab" + } + ] + } + ] + )) + + actual = @client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .conference_participants.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_with_label responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 25, + "first_page_url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?Label=client&PageSize=25&Page=0", + "previous_page_url": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?Label=client&PageSize=25&Page=0", + "next_page_url": null, + "key": "participants" + }, + "participants": [ + { + "participant_sid": "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "call_direction": "outbound", + "from": "+10000000000", + "to": "+10000000001", + "call_status": "completed", + "country_code": "US", + "is_moderator": true, + "join_time": "2021-10-08T02:58:51Z", + "leave_time": "2021-10-08T02:59:55Z", + "duration_seconds": 65, + "label": "client", + "outbound_queue_length": 0, + "outbound_time_in_queue": 3361, + "jitter_buffer_size": null, + "is_coach": false, + "coached_participants": null, + "participant_region": "us1", + "conference_region": "us1", + "call_type": "carrier", + "processing_state": "complete", + "properties": { + "start_conference_on_enter": true, + "end_conference_on_exit": false, + "play_early_media": true, + "enter_muted": false, + "beep_on_enter": false, + "beep_on_exit": false + }, + "metrics": { + "inbound": { + "total_packets_lost": 0, + "total_packets_received": 70, + "packet_loss_percentage": 0.0, + "jitter": { + "avg": 0.41, + "max": 0.84 + }, + "latency": { + "avg": 0.0, + "max": 0.0 + }, + "mos": 4.4 + }, + "outbound": { + "total_packets_lost": 0, + "total_packets_received": 96, + "packet_loss_percentage": 0, + "jitter": { + "avg": 0.01, + "max": 0.01 + }, + "latency": { + "avg": 0, + "max": 0 + }, + "mos": 4.4 + } + }, + "events": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + } + ] + )) + + actual = @client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .conference_participants.list() + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/insights/v1/conference_spec.rb b/spec/integration/insights/v1/conference_spec.rb new file mode 100644 index 000000000..4955f435f --- /dev/null +++ b/spec/integration/insights/v1/conference_spec.rb @@ -0,0 +1,475 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'Conference' do + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://insights.twilio.com/v1/Conferences/CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "conference1", + "start_time": "2021-10-08T02:58:51Z", + "create_time": "2021-10-08T02:58:47Z", + "end_time": "2021-10-08T03:00:02Z", + "duration_seconds": 76, + "connect_duration_seconds": 72, + "status": "completed", + "max_participants": 250, + "max_concurrent_participants": 4, + "unique_participants": 4, + "end_reason": "last_participant_left", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mixer_region": "us1", + "mixer_region_requested": "us1", + "recording_enabled": false, + "processing_state": "complete", + "detected_issues": { + "call_quality": 1, + "region_configuration": 0, + "participant_behavior": 3 + }, + "tags": [ + "duplicate_identity", + "detected_silence", + "participant_behavior_issues" + ], + "tag_info": { + "duplicate_identity": [ + { + "participant_identity": "client:+10000000000", + "participant_sids": [ + "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab" + ] + } + ] + }, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" + } + } + ] + )) + + actual = @client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.insights.v1.conferences.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://insights.twilio.com/v1/Conferences', + ))).to eq(true) + end + + it "receives read_full responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 25, + "first_page_url": "https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0", + "previous_page_url": null, + "url": "https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0", + "next_page_url": null, + "key": "conferences" + }, + "conferences": [ + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "conference 1", + "start_time": "2021-10-12T18:11:10Z", + "create_time": "2021-10-12T18:11:09Z", + "end_time": "2021-10-12T18:11:15Z", + "duration_seconds": 7, + "connect_duration_seconds": 5, + "status": "completed", + "max_participants": 250, + "max_concurrent_participants": 2, + "unique_participants": 2, + "end_reason": "last_participant_left", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mixer_region": "us1", + "mixer_region_requested": null, + "recording_enabled": false, + "processing_state": "complete", + "detected_issues": { + "call_quality": 1, + "region_configuration": 0, + "participant_behavior": 0 + }, + "tags": null, + "tag_info": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" + } + }, + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "conference 2", + "start_time": null, + "create_time": "2021-10-12T18:09:21Z", + "end_time": "2021-10-12T18:09:21Z", + "duration_seconds": 1, + "connect_duration_seconds": 0, + "status": "completed", + "max_participants": 250, + "max_concurrent_participants": 2, + "unique_participants": 3, + "end_reason": "last_participant_left", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "mixer_region": "us1", + "mixer_region_requested": null, + "recording_enabled": false, + "processing_state": "complete", + "detected_issues": { + "call_quality": 1, + "region_configuration": 0, + "participant_behavior": 0 + }, + "tags": [ + "detected_silence", + "participant_behavior_issues" + ], + "tag_info": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Participants" + } + } + ] + } + ] + )) + + actual = @client.insights.v1.conferences.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_with_region responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 25, + "first_page_url": "https://insights.twilio.com/v1/Conferences?MixerRegion=au1&Status=completed&PageSize=25&Page=0", + "previous_page_url": null, + "url": "https://insights.twilio.com/v1/Conferences?MixerRegion=au1&Status=completed&PageSize=25&Page=0", + "next_page_url": null, + "key": "conferences" + }, + "conferences": [ + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "conference 1", + "start_time": "2021-10-12T18:19:10Z", + "create_time": "2021-10-12T18:19:09Z", + "end_time": "2021-10-12T18:20:17Z", + "duration_seconds": 7, + "connect_duration_seconds": 5, + "status": "completed", + "max_participants": 250, + "max_concurrent_participants": 2, + "unique_participants": 2, + "end_reason": "participant_with_end_conference_on_exit_kicked", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mixer_region": "au1", + "mixer_region_requested": "au1", + "recording_enabled": true, + "processing_state": "complete", + "detected_issues": { + "call_quality": 0, + "region_configuration": 2, + "participant_behavior": 0 + }, + "tags": [ + "region_configuration_issues" + ], + "tag_info": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" + } + }, + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "conference 2", + "start_time": "2021-10-12T18:16:53Z", + "create_time": "2021-10-12T18:16:51Z", + "end_time": "2021-10-12T18:17:20Z", + "duration_seconds": 30, + "connect_duration_seconds": 27, + "status": "completed", + "max_participants": 250, + "max_concurrent_participants": 2, + "unique_participants": 2, + "end_reason": "last_participant_left", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "mixer_region": "au1", + "mixer_region_requested": null, + "recording_enabled": false, + "processing_state": "complete", + "detected_issues": { + "call_quality": 0, + "region_configuration": 2, + "participant_behavior": 3 + }, + "tags": [ + "detected_silence", + "region_configuration_issues", + "participant_behavior_issues" + ], + "tag_info": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Participants" + } + } + ] + } + ] + )) + + actual = @client.insights.v1.conferences.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_with_friendlyname_startfailure responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 25, + "first_page_url": "https://insights.twilio.com/v1/Conferences?FriendlyName=outboundConfCallTransferThrice_1&Status=not_started&PageSize=25&Page=0", + "previous_page_url": null, + "url": "https://insights.twilio.com/v1/Conferences?FriendlyName=outboundConfCallTransferThrice_1&Status=not_started&PageSize=25&Page=0", + "next_page_url": null, + "key": "conferences" + }, + "conferences": [ + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "outboundConfCallTransferThrice_1", + "start_time": null, + "create_time": "2021-11-18T00:09:09Z", + "end_time": "2021-11-18T00:09:52Z", + "duration_seconds": 7, + "connect_duration_seconds": 0, + "status": "not_started", + "max_participants": 250, + "max_concurrent_participants": 1, + "unique_participants": 1, + "end_reason": "last_participant_left", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mixer_region": null, + "mixer_region_requested": null, + "recording_enabled": false, + "processing_state": "complete", + "detected_issues": { + "call_quality": 0, + "region_configuration": 0, + "participant_behavior": 0 + }, + "tags": [ + "participant_behavior_issues", + "start_failure" + ], + "tag_info": { + "start_failure": { + "reason": "no_concurrent_participants" + } + }, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" + } + } + ] + } + ] + )) + + actual = @client.insights.v1.conferences.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_with_duplicate_identity responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 25, + "first_page_url": "https://insights.twilio.com/v1/Conferences?Tags=duplicate_identity&PageSize=25&Page=0", + "previous_page_url": null, + "url": "https://insights.twilio.com/v1/Conferences?Tags=duplicate_identity&PageSize=25&Page=0", + "next_page_url": null, + "key": "conferences" + }, + "conferences": [ + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "conference 1", + "start_time": "2021-11-17T16:21:45Z", + "create_time": "2021-11-17T16:21:40Z", + "end_time": "2021-11-17T16:22:11Z", + "duration_seconds": 32, + "connect_duration_seconds": 27, + "status": "not_started", + "max_participants": 250, + "max_concurrent_participants": 3, + "unique_participants": 4, + "end_reason": "last_participant_left", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mixer_region": "us1", + "mixer_region_requested": null, + "recording_enabled": false, + "processing_state": "complete", + "detected_issues": { + "call_quality": 0, + "region_configuration": 0, + "participant_behavior": 0 + }, + "tags": [ + "duplicate_identity", + "detected_silence", + "participant_behavior_issues" + ], + "tag_info": { + "duplicate_identity": [ + { + "participant_identity": "client:+10000000000", + "participant_sids": [ + "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab" + ] + } + ] + }, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" + } + } + ] + } + ] + )) + + actual = @client.insights.v1.conferences.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_with_detected_issue_endreason responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 25, + "first_page_url": "https://insights.twilio.com/v1/Conferences?DetectedIssues=call_quality&EndReason=participant_with_end_conference_on_exit_left&PageSize=25&Page=0", + "previous_page_url": null, + "url": "https://insights.twilio.com/v1/Conferences?DetectedIssues=call_quality&EndReason=participant_with_end_conference_on_exit_left&PageSize=25&Page=0", + "next_page_url": null, + "key": "conferences" + }, + "conferences": [ + { + "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "conference 1", + "start_time": "2021-11-17T16:21:45Z", + "create_time": "2021-11-17T16:21:40Z", + "end_time": "2021-11-17T16:22:11Z", + "duration_seconds": 32, + "connect_duration_seconds": 27, + "status": "not_started", + "max_participants": 250, + "max_concurrent_participants": 3, + "unique_participants": 3, + "end_reason": "participant_with_end_conference_on_exit_left", + "ended_by": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mixer_region": "us1", + "mixer_region_requested": null, + "recording_enabled": false, + "processing_state": "complete", + "detected_issues": { + "call_quality": 3, + "region_configuration": 0, + "participant_behavior": 1 + }, + "tags": [ + "high_packet_loss", + "low_mos", + "participant_behavior_issues", + "quality_warnings", + "high_jitter", + "detected_silence" + ], + "tag_info": null, + "url": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "conference_participants": "https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" + } + } + ] + } + ] + )) + + actual = @client.insights.v1.conferences.list() + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/ip_messaging/v1/credential_spec.rb b/spec/integration/ip_messaging/v1/credential_spec.rb index 5f0e7b4b1..379316d15 100644 --- a/spec/integration/ip_messaging/v1/credential_spec.rb +++ b/spec/integration/ip_messaging/v1/credential_spec.rb @@ -42,10 +42,10 @@ ], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=1&Page=0", + "url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } @@ -66,10 +66,10 @@ "credentials": [], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=1&Page=0", + "url": "https://ip-messaging.twilio.com/v1/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } diff --git a/spec/integration/ip_messaging/v1/service_spec.rb b/spec/integration/ip_messaging/v1/service_spec.rb index 449547d46..1f17d8cfe 100644 --- a/spec/integration/ip_messaging/v1/service_spec.rb +++ b/spec/integration/ip_messaging/v1/service_spec.rb @@ -37,11 +37,14 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, - "links": {}, + "links": { + "channels": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", @@ -49,7 +52,7 @@ "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], @@ -119,11 +122,14 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, - "links": {}, + "links": { + "channels": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", @@ -131,7 +137,7 @@ "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], @@ -166,13 +172,13 @@ %q[ { "meta": { - "first_page_url": "https://ip-messaging.twilio.com/v1/Services?Page=0&PageSize=50", + "first_page_url": "https://ip-messaging.twilio.com/v1/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, - "page_size": 0, + "page_size": 50, "previous_page_url": null, - "url": "https://ip-messaging.twilio.com/v1/Services" + "url": "https://ip-messaging.twilio.com/v1/Services?PageSize=50&Page=0" }, "services": [] } @@ -190,13 +196,13 @@ %q[ { "meta": { - "first_page_url": "https://ip-messaging.twilio.com/v1/Services?Page=0&PageSize=50", + "first_page_url": "https://ip-messaging.twilio.com/v1/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, - "page_size": 1, + "page_size": 50, "previous_page_url": null, - "url": "https://ip-messaging.twilio.com/v1/Services" + "url": "https://ip-messaging.twilio.com/v1/Services?PageSize=50&Page=0" }, "services": [ { @@ -209,11 +215,14 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, - "links": {}, + "links": { + "channels": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", @@ -221,7 +230,7 @@ "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], @@ -266,24 +275,125 @@ "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { - "actions_per_second": 20, "channel_members": 500, "user_channels": 600 }, - "links": {}, - "notifications": {}, + "links": { + "channels": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", + "users": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", + "roles": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles" + }, + "notifications": { + "added_to_channel": { + "enabled": false, + "template": "notifications.added_to_channel.template" + }, + "invited_to_channel": { + "enabled": false, + "template": "notifications.invited_to_channel.template" + }, + "new_message": { + "enabled": false, + "template": "notifications.new_message.template" + }, + "removed_from_channel": { + "enabled": false, + "template": "notifications.removed_from_channel.template" + } + }, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, - "url": "http://www.example.com", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", - "webhooks": {} + "webhooks": { + "on_channel_add": { + "format": "webhooks.on_channel_add.format", + "method": "webhooks.on_channel_add.method", + "url": "webhooks.on_channel_add.url" + }, + "on_channel_added": { + "format": "webhooks.on_channel_added.format", + "method": "webhooks.on_channel_added.method", + "url": "webhooks.on_channel_added.url" + }, + "on_channel_destroy": { + "format": "webhooks.on_channel_destroy.format", + "method": "webhooks.on_channel_destroy.method", + "url": "webhooks.on_channel_destroy.url" + }, + "on_channel_destroyed": { + "format": "webhooks.on_channel_destroyed.format", + "method": "webhooks.on_channel_destroyed.method", + "url": "webhooks.on_channel_destroyed.url" + }, + "on_channel_update": { + "format": "webhooks.on_channel_update.format", + "method": "webhooks.on_channel_update.method", + "url": "webhooks.on_channel_update.url" + }, + "on_channel_updated": { + "format": "webhooks.on_channel_updated.format", + "method": "webhooks.on_channel_updated.method", + "url": "webhooks.on_channel_updated.url" + }, + "on_member_add": { + "format": "webhooks.on_member_add.format", + "method": "webhooks.on_member_add.method", + "url": "webhooks.on_member_add.url" + }, + "on_member_added": { + "format": "webhooks.on_member_added.format", + "method": "webhooks.on_member_added.method", + "url": "webhooks.on_member_added.url" + }, + "on_member_remove": { + "format": "webhooks.on_member_remove.format", + "method": "webhooks.on_member_remove.method", + "url": "webhooks.on_member_remove.url" + }, + "on_member_removed": { + "format": "webhooks.on_member_removed.format", + "method": "webhooks.on_member_removed.method", + "url": "webhooks.on_member_removed.url" + }, + "on_message_remove": { + "format": "webhooks.on_message_remove.format", + "method": "webhooks.on_message_remove.method", + "url": "webhooks.on_message_remove.url" + }, + "on_message_removed": { + "format": "webhooks.on_message_removed.format", + "method": "webhooks.on_message_removed.method", + "url": "webhooks.on_message_removed.url" + }, + "on_message_send": { + "format": "webhooks.on_message_send.format", + "method": "webhooks.on_message_send.method", + "url": "webhooks.on_message_send.url" + }, + "on_message_sent": { + "format": "webhooks.on_message_sent.format", + "method": "webhooks.on_message_sent.method", + "url": "webhooks.on_message_sent.url" + }, + "on_message_update": { + "format": "webhooks.on_message_update.format", + "method": "webhooks.on_message_update.method", + "url": "webhooks.on_message_update.url" + }, + "on_message_updated": { + "format": "webhooks.on_message_updated.format", + "method": "webhooks.on_message_updated.method", + "url": "webhooks.on_message_updated.url" + } + } } ] )) diff --git a/spec/integration/ip_messaging/v2/credential_spec.rb b/spec/integration/ip_messaging/v2/credential_spec.rb index 24fbeeac6..d806df956 100644 --- a/spec/integration/ip_messaging/v2/credential_spec.rb +++ b/spec/integration/ip_messaging/v2/credential_spec.rb @@ -42,10 +42,10 @@ ], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=1&Page=0", + "url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } @@ -66,10 +66,10 @@ "credentials": [], "meta": { "page": 0, - "page_size": 1, - "first_page_url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=1&Page=0", + "page_size": 50, + "first_page_url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=50&Page=0", "previous_page_url": null, - "url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=1&Page=0", + "url": "https://ip-messaging.twilio.com/v2/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } diff --git a/spec/integration/media/v1/media_recording_spec.rb b/spec/integration/media/v1/media_recording_spec.rb new file mode 100644 index 000000000..0f9f6253f --- /dev/null +++ b/spec/integration/media/v1/media_recording_spec.rb @@ -0,0 +1,167 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'MediaRecording' do + it "can delete" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.media.v1.media_recording('KVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'delete', + url: 'https://media.twilio.com/v1/MediaRecordings/KVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives delete responses" do + @holodeck.mock(Twilio::Response.new( + 204, + nil, + )) + + actual = @client.media.v1.media_recording('KVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() + + expect(actual).to eq(true) + end + + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.media.v1.media_recording('KVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://media.twilio.com/v1/MediaRecordings/KVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "bitrate": 1000, + "date_created": "2015-07-30T20:00:00Z", + "date_updated": "2015-07-30T20:00:00Z", + "duration": 2147483647, + "format": "mp4", + "links": { + "media": "https://media.twilio.com/v1/MediaRecordings/KVcafebabecafebabecafebabecafebabe/Media", + "timed_metadata": "https://media.twilio.com/v1/MediaRecordings/KVcafebabecafebabecafebabecafebabe/TimedMetadata" + }, + "processor_sid": "ZXcafebabecafebabecafebabecafebabe", + "resolution": "640x480", + "source_sid": "RMcafebabecafebabecafebabecafebabe", + "sid": "KVcafebabecafebabecafebabecafebabe", + "size": 2147483648, + "status": "completed", + "status_callback": "https://www.example.com", + "status_callback_method": "POST", + "url": "https://media.twilio.com/v1/MediaRecordings/KVcafebabecafebabecafebabecafebabe" + } + ] + )) + + actual = @client.media.v1.media_recording('KVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.media.v1.media_recording.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://media.twilio.com/v1/MediaRecordings', + ))).to eq(true) + end + + it "receives read_empty responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 10, + "first_page_url": "https://media.twilio.com/v1/MediaRecordings?Status=processing&SourceSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&ProcessorSid=ZXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Order=asc&PageSize=10&Page=0", + "previous_page_url": null, + "url": "https://media.twilio.com/v1/MediaRecordings?Status=processing&SourceSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&ProcessorSid=ZXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Order=asc&PageSize=10&Page=0", + "next_page_url": null, + "key": "media_recordings" + }, + "media_recordings": [] + } + ] + )) + + actual = @client.media.v1.media_recording.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_items responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 10, + "first_page_url": "https://media.twilio.com/v1/MediaRecordings?Status=completed&SourceSid=RMcafebabecafebabecafebabecafebabe&ProcessorSid=ZXcafebabecafebabecafebabecafebabe&Order=desc&PageSize=10&Page=0", + "previous_page_url": null, + "url": "https://media.twilio.com/v1/MediaRecordings?Status=completed&SourceSid=RMcafebabecafebabecafebabecafebabe&ProcessorSid=ZXcafebabecafebabecafebabecafebabe&Order=desc&PageSize=10&Page=0", + "next_page_url": null, + "key": "media_recordings" + }, + "media_recordings": [ + { + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "bitrate": 1000, + "date_created": "2015-07-30T20:00:00Z", + "date_updated": "2015-07-30T20:00:00Z", + "duration": 1000, + "format": "mp4", + "links": { + "media": "https://media.twilio.com/v1/MediaRecordings/KVcafebabecafebabecafebabecafebabe/Media", + "timed_metadata": "https://media.twilio.com/v1/MediaRecordings/KVcafebabecafebabecafebabecafebabe/TimedMetadata" + }, + "processor_sid": "ZXcafebabecafebabecafebabecafebabe", + "resolution": "640x480", + "source_sid": "RMcafebabecafebabecafebabecafebabe", + "sid": "KVcafebabecafebabecafebabecafebabe", + "size": 1000, + "status": "completed", + "status_callback": "https://www.example.com", + "status_callback_method": "POST", + "url": "https://media.twilio.com/v1/MediaRecordings/KVcafebabecafebabecafebabecafebabe" + } + ] + } + ] + )) + + actual = @client.media.v1.media_recording.list() + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/media/v1/player_streamer_spec.rb b/spec/integration/media/v1/player_streamer_spec.rb index 932a251df..b1266c496 100644 --- a/spec/integration/media/v1/player_streamer_spec.rb +++ b/spec/integration/media/v1/player_streamer_spec.rb @@ -38,6 +38,7 @@ "status_callback_method": "POST", "ended_reason": null, "url": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe", + "max_duration": 300, "links": { "timed_metadata": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/TimedMetadata", "playback_grant": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/PlaybackGrant" @@ -80,6 +81,7 @@ "status_callback_method": "POST", "ended_reason": null, "url": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe", + "max_duration": 300, "links": { "timed_metadata": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/TimedMetadata", "playback_grant": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/PlaybackGrant" @@ -124,6 +126,7 @@ "status_callback_method": "POST", "ended_reason": "ended-via-api", "url": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe", + "max_duration": 300, "links": { "timed_metadata": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/TimedMetadata", "playback_grant": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/PlaybackGrant" @@ -201,6 +204,7 @@ "status_callback_method": "POST", "ended_reason": "ended-via-api", "url": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe", + "max_duration": 300, "links": { "timed_metadata": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/TimedMetadata", "playback_grant": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/PlaybackGrant" @@ -242,6 +246,7 @@ "status_callback_method": "POST", "ended_reason": "ended-via-api", "url": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe", + "max_duration": 300, "links": { "timed_metadata": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/TimedMetadata", "playback_grant": "https://media.twilio.com/v1/PlayerStreamers/VJcafebabecafebabecafebabecafebabe/PlaybackGrant" diff --git a/spec/integration/messaging/v1/brand_registration_spec.rb b/spec/integration/messaging/v1/brand_registration_spec.rb index 83b910e3a..02ebd3baf 100644 --- a/spec/integration/messaging/v1/brand_registration_spec.rb +++ b/spec/integration/messaging/v1/brand_registration_spec.rb @@ -46,6 +46,7 @@ ], "identity_status": "VERIFIED", "russell_3000": true, + "government_entity": false, "tax_exempt_status": "501c3", "skip_automatic_sec_vet": false, "mock": false, @@ -110,6 +111,7 @@ "identity_status": "VERIFIED", "russell_3000": true, "tax_exempt_status": "501c3", + "government_entity": false, "skip_automatic_sec_vet": false, "mock": false, "links": { @@ -168,6 +170,7 @@ ], "identity_status": "VERIFIED", "russell_3000": true, + "government_entity": false, "tax_exempt_status": "501c3", "skip_automatic_sec_vet": false, "mock": false, @@ -220,6 +223,7 @@ ], "identity_status": "VERIFIED", "russell_3000": false, + "government_entity": false, "tax_exempt_status": "501c3", "skip_automatic_sec_vet": false, "mock": false, diff --git a/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb b/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb index 53716d0b4..f8835bd83 100644 --- a/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb +++ b/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb @@ -141,6 +141,138 @@ expect(actual).to_not eq(nil) end + it "receives read_approved_au_mobile_with_date responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "results": [ + { + "sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "regulation_sid": "RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "friendly_name", + "status": "twilio-approved", + "email": "email", + "status_callback": "http://www.example.com", + "valid_until": "2022-11-29T01:00:00Z", + "date_created": "2021-08-30T22:29:24Z", + "date_updated": "2021-08-31T01:09:00Z", + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "evaluations": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Evaluations", + "item_assignments": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ItemAssignments", + "bundle_copies": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Copies" + } + } + ], + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles?Status=twilio-approved&IsoCountry=AU&HasValidUntilDate=true&NumberType=mobile&PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles?Status=twilio-approved&IsoCountry=AU&HasValidUntilDate=true&NumberType=mobile&PageSize=50&Page=0", + "next_page_url": null, + "key": "results" + } + } + ] + )) + + actual = @client.numbers.v2.regulatory_compliance \ + .bundles.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_approved_au_mobile_date_less responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "results": [ + { + "sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "regulation_sid": "RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "friendly_name", + "status": "twilio-approved", + "email": "email", + "status_callback": "http://www.example.com", + "valid_until": "2022-11-29T01:00:00Z", + "date_created": "2021-08-30T22:29:24Z", + "date_updated": "2021-08-31T01:09:00Z", + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "evaluations": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Evaluations", + "item_assignments": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ItemAssignments", + "bundle_copies": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Copies" + } + } + ], + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles?Status=twilio-approved&IsoCountry=AU&ValidUntilDate%3C=2022-11-29T23%3A59%3A59Z&NumberType=mobile&PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles?Status=twilio-approved&IsoCountry=AU&ValidUntilDate%3C=2022-11-29T23%3A59%3A59Z&NumberType=mobile&PageSize=50&Page=0", + "next_page_url": null, + "key": "results" + } + } + ] + )) + + actual = @client.numbers.v2.regulatory_compliance \ + .bundles.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_approved_japan_tollfree_date_between responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "results": [ + { + "sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "regulation_sid": "RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "friendly_name", + "status": "twilio-approved", + "email": "email", + "status_callback": "http://www.example.com", + "valid_until": "2022-11-29T01:00:00Z", + "date_created": "2021-08-30T22:29:24Z", + "date_updated": "2021-08-31T01:09:00Z", + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "links": { + "evaluations": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Evaluations", + "item_assignments": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ItemAssignments", + "bundle_copies": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Copies" + } + } + ], + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles?Status=twilio-approved&IsoCountry=JP&ValidUntilDate%3E=2022-01-01T00%3A00%3A00Z&ValidUntilDate%3C=2022-11-29T23%3A59%3A59Z&NumberType=tollfree&PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Bundles?Status=twilio-approved&IsoCountry=JP&ValidUntilDate%3E=2022-01-01T00%3A00%3A00Z&ValidUntilDate%3C=2022-11-29T23%3A59%3A59Z&NumberType=tollfree&PageSize=50&Page=0", + "next_page_url": null, + "key": "results" + } + } + ] + )) + + actual = @client.numbers.v2.regulatory_compliance \ + .bundles.list() + + expect(actual).to_not eq(nil) + end + it "can fetch" do @holodeck.mock(Twilio::Response.new(500, '')) diff --git a/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb b/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb index 2b5efae94..240ae85ad 100644 --- a/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +++ b/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb @@ -36,6 +36,7 @@ "friendly_name": "friendly_name", "mime_type": "mime_type", "status": "draft", + "failure_reason": null, "type": "type", "attributes": { "first_name": "foo", @@ -106,6 +107,49 @@ "friendly_name": "friendly_name", "mime_type": "mime_type", "status": "draft", + "failure_reason": null, + "type": "type", + "attributes": { + "first_name": "foo", + "last_name": "bar" + }, + "date_created": "2019-07-31T02:11:52Z", + "date_updated": "2019-07-31T02:11:52Z", + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/SupportingDocuments/RDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ], + "meta": { + "page": 0, + "page_size": 50, + "first_page_url": "https://numbers.twilio.com/v2/RegulatoryCompliance/SupportingDocuments?PageSize=50&Page=0", + "previous_page_url": null, + "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/SupportingDocuments?PageSize=50&Page=0", + "next_page_url": null, + "key": "results" + } + } + ] + )) + + actual = @client.numbers.v2.regulatory_compliance \ + .supporting_documents.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_rejected_document responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "results": [ + { + "sid": "RDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "friendly_name", + "mime_type": "mime_type", + "status": "twilio-rejected", + "failure_reason": "Some failure reason.", "type": "type", "attributes": { "first_name": "foo", @@ -160,6 +204,7 @@ "friendly_name": "friendly_name", "mime_type": "mime_type", "status": "draft", + "failure_reason": null, "type": "type", "attributes": { "first_name": "foo", @@ -203,6 +248,7 @@ "friendly_name": "friendly_name", "mime_type": "mime_type", "status": "draft", + "failure_reason": null, "type": "type", "attributes": { "first_name": "foo", diff --git a/spec/integration/supersim/v1/command_spec.rb b/spec/integration/supersim/v1/command_spec.rb deleted file mode 100644 index b0d529375..000000000 --- a/spec/integration/supersim/v1/command_spec.rb +++ /dev/null @@ -1,184 +0,0 @@ -## -# This code was generated by -# \ / _ _ _| _ _ -# | (_)\/(_)(_|\/| |(/_ v1.0.0 -# / / -# -# frozen_string_literal: true - -require 'spec_helper.rb' - -describe 'Command' do - it "can create" do - @holodeck.mock(Twilio::Response.new(500, '')) - - expect { - @client.supersim.v1.commands.create(sim: 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', command: 'command') - }.to raise_exception(Twilio::REST::TwilioError) - - values = {'Sim' => 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'Command' => 'command', } - expect( - @holodeck.has_request?(Holodeck::Request.new( - method: 'post', - url: 'https://supersim.twilio.com/v1/Commands', - data: values, - ))).to eq(true) - end - - it "receives create_command_minimal responses" do - @holodeck.mock(Twilio::Response.new( - 201, - %q[ - { - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "command": "command", - "date_created": "2015-07-30T20:00:00Z", - "date_updated": "2015-07-30T20:00:00Z", - "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "sid": "HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "status": "queued", - "direction": "to_sim", - "url": "https://supersim.twilio.com/v1/Commands/HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - } - ] - )) - - actual = @client.supersim.v1.commands.create(sim: 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', command: 'command') - - expect(actual).to_not eq(nil) - end - - it "receives create_command_full responses" do - @holodeck.mock(Twilio::Response.new( - 201, - %q[ - { - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "command": "command", - "date_created": "2015-07-30T20:00:00Z", - "date_updated": "2015-07-30T20:00:00Z", - "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "sid": "HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "status": "queued", - "direction": "to_sim", - "url": "https://supersim.twilio.com/v1/Commands/HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - } - ] - )) - - actual = @client.supersim.v1.commands.create(sim: 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', command: 'command') - - expect(actual).to_not eq(nil) - end - - it "can fetch" do - @holodeck.mock(Twilio::Response.new(500, '')) - - expect { - @client.supersim.v1.commands('HCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() - }.to raise_exception(Twilio::REST::TwilioError) - - expect( - @holodeck.has_request?(Holodeck::Request.new( - method: 'get', - url: 'https://supersim.twilio.com/v1/Commands/HCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - ))).to eq(true) - end - - it "receives fetch responses" do - @holodeck.mock(Twilio::Response.new( - 200, - %q[ - { - "sid": "HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "command": "content of the command", - "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "status": "queued", - "direction": "to_sim", - "date_created": "2015-07-30T20:00:00Z", - "date_updated": "2015-07-30T20:00:00Z", - "url": "https://supersim.twilio.com/v1/Commands/HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - } - ] - )) - - actual = @client.supersim.v1.commands('HCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() - - expect(actual).to_not eq(nil) - end - - it "can read" do - @holodeck.mock(Twilio::Response.new(500, '')) - - expect { - @client.supersim.v1.commands.list() - }.to raise_exception(Twilio::REST::TwilioError) - - expect( - @holodeck.has_request?(Holodeck::Request.new( - method: 'get', - url: 'https://supersim.twilio.com/v1/Commands', - ))).to eq(true) - end - - it "receives read_empty responses" do - @holodeck.mock(Twilio::Response.new( - 200, - %q[ - { - "commands": [], - "meta": { - "first_page_url": "https://supersim.twilio.com/v1/Commands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0", - "key": "commands", - "next_page_url": null, - "page": 0, - "page_size": 50, - "previous_page_url": null, - "url": "https://supersim.twilio.com/v1/Commands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0" - } - } - ] - )) - - actual = @client.supersim.v1.commands.list() - - expect(actual).to_not eq(nil) - end - - it "receives read_full responses" do - @holodeck.mock(Twilio::Response.new( - 200, - %q[ - { - "meta": { - "first_page_url": "https://supersim.twilio.com/v1/Commands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0", - "key": "commands", - "next_page_url": null, - "page": 0, - "page_size": 50, - "previous_page_url": null, - "url": "https://supersim.twilio.com/v1/Commands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0" - }, - "commands": [ - { - "sid": "HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "command": "content of the command", - "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "status": "queued", - "direction": "from_sim", - "date_created": "2015-07-30T20:00:00Z", - "date_updated": "2015-07-30T20:00:00Z", - "url": "https://supersim.twilio.com/v1/Commands/HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - } - ] - } - ] - )) - - actual = @client.supersim.v1.commands.list() - - expect(actual).to_not eq(nil) - end -end \ No newline at end of file diff --git a/spec/integration/supersim/v1/esim_profile_spec.rb b/spec/integration/supersim/v1/esim_profile_spec.rb new file mode 100644 index 000000000..4459abee1 --- /dev/null +++ b/spec/integration/supersim/v1/esim_profile_spec.rb @@ -0,0 +1,289 @@ +## +# This code was generated by +# \ / _ _ _| _ _ +# | (_)\/(_)(_|\/| |(/_ v1.0.0 +# / / +# +# frozen_string_literal: true + +require 'spec_helper.rb' + +describe 'EsimProfile' do + it "can create" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.supersim.v1.esim_profiles.create(eid: 'eid') + }.to raise_exception(Twilio::REST::TwilioError) + + values = {'Eid' => 'eid', } + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'post', + url: 'https://supersim.twilio.com/v1/ESimProfiles', + data: values, + ))).to eq(true) + end + + it "receives create_default_smdp responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "sid": "HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "iccid": null, + "sim_sid": null, + "status": "reserving", + "eid": "89049032005008882600033489aaaaaa", + "smdp_plus_address": null, + "error_code": null, + "error_message": null, + "date_created": "2020-09-01T20:00:00Z", + "date_updated": "2020-09-01T20:00:00Z", + "url": "https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.supersim.v1.esim_profiles.create(eid: 'eid') + + expect(actual).to_not eq(nil) + end + + it "receives create_with_callback responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "sid": "HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "iccid": null, + "sim_sid": null, + "status": "reserving", + "eid": "89049032005008882600033489aaaaaa", + "smdp_plus_address": null, + "error_code": null, + "error_message": null, + "date_created": "2020-09-01T20:00:00Z", + "date_updated": "2020-09-01T20:00:00Z", + "url": "https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.supersim.v1.esim_profiles.create(eid: 'eid') + + expect(actual).to_not eq(nil) + end + + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.supersim.v1.esim_profiles('HPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://supersim.twilio.com/v1/ESimProfiles/HPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "iccid": "8988307aaaaaaaaaaaaa", + "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status": "available", + "eid": "89049032005008882600033489aaaaaa", + "smdp_plus_address": "https://sm-dp-plus.twilio.com", + "error_code": null, + "error_message": null, + "date_created": "2020-09-01T20:00:00Z", + "date_updated": "2020-09-01T20:00:00Z", + "url": "https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.supersim.v1.esim_profiles('HPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end + + it "can read" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.supersim.v1.esim_profiles.list() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://supersim.twilio.com/v1/ESimProfiles', + ))).to eq(true) + end + + it "receives read_all responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "esim_profiles": [ + { + "sid": "HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "iccid": "8988307aaaaaaaaaaaaa", + "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status": "available", + "eid": "89049032005008882600033489aaaaaa", + "smdp_plus_address": "https://sm-dp-plus.twilio.com", + "error_code": null, + "error_message": null, + "date_created": "2020-09-01T20:00:00Z", + "date_updated": "2020-09-01T20:00:00Z", + "url": "https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ], + "meta": { + "first_page_url": "https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0", + "key": "esim_profiles", + "next_page_url": null, + "page": 0, + "page_size": 50, + "previous_page_url": null, + "url": "https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0" + } + } + ] + )) + + actual = @client.supersim.v1.esim_profiles.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_by_eid responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "esim_profiles": [ + { + "sid": "HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "iccid": "8988307aaaaaaaaaaaaa", + "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status": "available", + "eid": "89049032005008882600033489aaaaaa", + "smdp_plus_address": "https://sm-dp-plus.twilio.com", + "error_code": null, + "error_message": null, + "date_created": "2020-09-01T20:00:00Z", + "date_updated": "2020-09-01T20:00:00Z", + "url": "https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ], + "meta": { + "first_page_url": "https://supersim.twilio.com/v1/ESimProfiles?Eid=89049032005008882600033489aaaaaa&PageSize=50&Page=0", + "key": "esim_profiles", + "next_page_url": null, + "page": 0, + "page_size": 50, + "previous_page_url": null, + "url": "https://supersim.twilio.com/v1/ESimProfiles?Eid=89049032005008882600033489aaaaaa&PageSize=50&Page=0" + } + } + ] + )) + + actual = @client.supersim.v1.esim_profiles.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_by_sim_sid responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "esim_profiles": [ + { + "sid": "HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "iccid": "8988307aaaaaaaaaaaaa", + "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status": "available", + "eid": "89049032005008882600033489aaaaaa", + "smdp_plus_address": "https://sm-dp-plus.twilio.com", + "error_code": null, + "error_message": null, + "date_created": "2020-09-01T20:00:00Z", + "date_updated": "2020-09-01T20:00:00Z", + "url": "https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ], + "meta": { + "first_page_url": "https://supersim.twilio.com/v1/ESimProfiles?SimSid=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0", + "key": "esim_profiles", + "next_page_url": null, + "page": 0, + "page_size": 50, + "previous_page_url": null, + "url": "https://supersim.twilio.com/v1/ESimProfiles?SimSid=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0" + } + } + ] + )) + + actual = @client.supersim.v1.esim_profiles.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_by_status responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "esim_profiles": [ + { + "sid": "HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "iccid": "8988307aaaaaaaaaaaaa", + "sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status": "downloaded", + "eid": "89049032005008882600033489aaaaaa", + "smdp_plus_address": "https://sm-dp-plus.twilio.com", + "error_code": null, + "error_message": null, + "date_created": "2020-09-01T20:00:00Z", + "date_updated": "2020-09-01T20:00:00Z", + "url": "https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ], + "meta": { + "first_page_url": "https://supersim.twilio.com/v1/ESimProfiles?Status=downloaded&PageSize=50&Page=0", + "key": "esim_profiles", + "next_page_url": null, + "page": 0, + "page_size": 50, + "previous_page_url": null, + "url": "https://supersim.twilio.com/v1/ESimProfiles?Status=downloaded&PageSize=50&Page=0" + } + } + ] + )) + + actual = @client.supersim.v1.esim_profiles.list() + + expect(actual).to_not eq(nil) + end +end \ No newline at end of file diff --git a/spec/integration/supersim/v1/fleet_spec.rb b/spec/integration/supersim/v1/fleet_spec.rb index d0607a08a..62845c102 100644 --- a/spec/integration/supersim/v1/fleet_spec.rb +++ b/spec/integration/supersim/v1/fleet_spec.rb @@ -37,9 +37,6 @@ "data_metering": "payg", "date_created": "2019-07-30T20:00:00Z", "date_updated": "2019-07-30T20:00:00Z", - "commands_enabled": true, - "commands_method": "GET", - "commands_url": "https://google.com", "sms_commands_enabled": true, "sms_commands_method": "GET", "sms_commands_url": "https://google.com", @@ -83,9 +80,6 @@ "data_metering": "payg", "date_created": "2019-07-30T20:00:00Z", "date_updated": "2019-07-30T20:00:00Z", - "commands_enabled": true, - "commands_method": "POST", - "commands_url": null, "sms_commands_enabled": true, "sms_commands_method": "POST", "sms_commands_url": null, @@ -164,9 +158,6 @@ "data_metering": "payg", "date_created": "2019-10-15T20:00:00Z", "date_updated": "2019-10-15T20:00:00Z", - "commands_enabled": true, - "commands_method": "POST", - "commands_url": null, "sms_commands_enabled": true, "sms_commands_method": "POST", "sms_commands_url": null, @@ -212,9 +203,6 @@ "data_metering": "payg", "date_created": "2019-10-15T20:00:00Z", "date_updated": "2019-10-15T20:00:00Z", - "commands_enabled": true, - "commands_method": "POST", - "commands_url": null, "sms_commands_enabled": true, "sms_commands_method": "POST", "sms_commands_url": null, diff --git a/spec/integration/supersim/v1/sms_command_spec.rb b/spec/integration/supersim/v1/sms_command_spec.rb index ec3f46aa5..3b8265630 100644 --- a/spec/integration/supersim/v1/sms_command_spec.rb +++ b/spec/integration/supersim/v1/sms_command_spec.rb @@ -13,10 +13,10 @@ @holodeck.mock(Twilio::Response.new(500, '')) expect { - @client.supersim.v1.sms_commands.create(sim: 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', payload: 'payload') + @client.supersim.v1.sms_commands.create(sim: 'sim', payload: 'payload') }.to raise_exception(Twilio::REST::TwilioError) - values = {'Sim' => 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'Payload' => 'payload', } + values = {'Sim' => 'sim', 'Payload' => 'payload', } expect( @holodeck.has_request?(Holodeck::Request.new( method: 'post', @@ -43,7 +43,7 @@ ] )) - actual = @client.supersim.v1.sms_commands.create(sim: 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', payload: 'payload') + actual = @client.supersim.v1.sms_commands.create(sim: 'sim', payload: 'payload') expect(actual).to_not eq(nil) end @@ -66,7 +66,7 @@ ] )) - actual = @client.supersim.v1.sms_commands.create(sim: 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', payload: 'payload') + actual = @client.supersim.v1.sms_commands.create(sim: 'sim', payload: 'payload') expect(actual).to_not eq(nil) end diff --git a/spec/integration/verify/v2/service/access_token_spec.rb b/spec/integration/verify/v2/service/access_token_spec.rb index 12c0aa248..c2df2de8b 100644 --- a/spec/integration/verify/v2/service/access_token_spec.rb +++ b/spec/integration/verify/v2/service/access_token_spec.rb @@ -26,12 +26,21 @@ ))).to eq(true) end - it "receives create responses" do + it "receives create_with_ttl responses" do @holodeck.mock(Twilio::Response.new( 201, %q[ { - "token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ" + "sid": "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "entity_identity": "ff483d1ff591898a9942916050d2ca3f", + "factor_type": "push", + "factor_friendly_name": "John Doe iPhone", + "ttl": 300, + "date_created": "2015-07-30T20:00:00Z", + "token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ", + "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] )) @@ -41,4 +50,69 @@ expect(actual).to_not eq(nil) end + + it "receives create_without_ttl responses" do + @holodeck.mock(Twilio::Response.new( + 201, + %q[ + { + "sid": "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "entity_identity": "ff483d1ff591898a9942916050d2ca3f", + "factor_type": "push", + "factor_friendly_name": "John Doe iPhone", + "ttl": 60, + "date_created": "2015-07-30T20:00:00Z", + "token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ", + "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .access_tokens.create(identity: 'identity', factor_type: 'push') + + expect(actual).to_not eq(nil) + end + + it "can fetch" do + @holodeck.mock(Twilio::Response.new(500, '')) + + expect { + @client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .access_tokens('YKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + }.to raise_exception(Twilio::REST::TwilioError) + + expect( + @holodeck.has_request?(Holodeck::Request.new( + method: 'get', + url: 'https://verify.twilio.com/v2/Services/VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AccessTokens/YKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + ))).to eq(true) + end + + it "receives fetch responses" do + @holodeck.mock(Twilio::Response.new( + 200, + %q[ + { + "sid": "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "entity_identity": "ff483d1ff591898a9942916050d2ca3f", + "factor_type": "push", + "factor_friendly_name": "John Doe iPhone", + "ttl": 60, + "date_created": "2015-07-30T20:00:00Z", + "token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ", + "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .access_tokens('YKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() + + expect(actual).to_not eq(nil) + end end \ No newline at end of file diff --git a/spec/integration/verify/v2/service/entity/challenge_spec.rb b/spec/integration/verify/v2/service/entity/challenge_spec.rb index 462ab6290..f8dce4c38 100644 --- a/spec/integration/verify/v2/service/entity/challenge_spec.rb +++ b/spec/integration/verify/v2/service/entity/challenge_spec.rb @@ -27,7 +27,7 @@ ))).to eq(true) end - it "receives create_push_without_auth_payload responses" do + it "receives create_push responses" do @holodeck.mock(Twilio::Response.new( 201, %q[ @@ -57,6 +57,7 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": null, "factor_type": "push", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { @@ -103,6 +104,7 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": null, "factor_type": "totp", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { @@ -149,6 +151,7 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": null, "factor_type": "totp", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { @@ -196,7 +199,7 @@ "date_updated": "2015-07-30T20:00:00Z", "date_responded": "2015-07-30T20:00:00Z", "expiration_date": "2015-07-30T20:00:00Z", - "status": "pending", + "status": "approved", "responded_reason": "none", "details": { "message": "Hi! Mr. John Doe, would you like to sign up?", @@ -211,6 +214,9 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": { + "os": "Android" + }, "factor_type": "push", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { @@ -301,6 +307,7 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": null, "factor_type": "push", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { @@ -333,6 +340,7 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": null, "factor_type": "totp", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { @@ -406,6 +414,9 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": { + "os": "Android" + }, "factor_type": "push", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { @@ -452,6 +463,7 @@ "hidden_details": { "ip": "172.168.1.234" }, + "metadata": null, "factor_type": "totp", "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { diff --git a/spec/integration/verify/v2/service/entity/factor_spec.rb b/spec/integration/verify/v2/service/entity/factor_spec.rb index 8a57e1020..cd7a7b818 100644 --- a/spec/integration/verify/v2/service/entity/factor_spec.rb +++ b/spec/integration/verify/v2/service/entity/factor_spec.rb @@ -75,6 +75,9 @@ "notification_platform": "fcm", "notification_token": "test_token" }, + "metadata": { + "os": "Android" + }, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] @@ -108,6 +111,7 @@ "code_length": 6, "time_step": 30 }, + "metadata": null, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] @@ -185,6 +189,9 @@ "notification_platform": "fcm", "notification_token": "test_token" }, + "metadata": { + "os": "Android" + }, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], @@ -231,6 +238,7 @@ "code_length": 6, "time_step": 30 }, + "metadata": null, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], @@ -291,6 +299,9 @@ "notification_platform": "fcm", "notification_token": "test_token" }, + "metadata": { + "os": "Android" + }, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] @@ -324,6 +335,7 @@ "code_length": 6, "time_step": 30 }, + "metadata": null, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] diff --git a/spec/integration/verify/v2/service/entity/new_factor_spec.rb b/spec/integration/verify/v2/service/entity/new_factor_spec.rb index 7a258ca73..ff5af9017 100644 --- a/spec/integration/verify/v2/service/entity/new_factor_spec.rb +++ b/spec/integration/verify/v2/service/entity/new_factor_spec.rb @@ -52,6 +52,9 @@ "notification_platform": "fcm", "notification_token": "test_token" }, + "metadata": { + "os": "Android" + }, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] @@ -89,6 +92,7 @@ "code_length": 6, "time_step": 30 }, + "metadata": null, "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] diff --git a/spec/integration/verify/v2/service/verification_spec.rb b/spec/integration/verify/v2/service/verification_spec.rb index 682440107..8c466250e 100644 --- a/spec/integration/verify/v2/service/verification_spec.rb +++ b/spec/integration/verify/v2/service/verification_spec.rb @@ -40,22 +40,14 @@ "valid": false, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", - "lookup": { - "carrier": { - "error_code": null, - "name": "Carrier Name", - "mobile_country_code": "310", - "mobile_network_code": "150", - "type": "mobile" - } - }, + "lookup": {}, "amount": null, "payee": null, "send_code_attempts": [ { "time": "2015-07-30T20:00:00Z", "channel": "SMS", - "channel_id": null + "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -83,22 +75,14 @@ "valid": false, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", - "lookup": { - "carrier": { - "error_code": null, - "name": "Carrier Name", - "mobile_country_code": "310", - "mobile_network_code": "150", - "type": "mobile" - } - }, + "lookup": {}, "amount": null, "payee": null, "send_code_attempts": [ { "time": "2015-07-30T20:00:00Z", "channel": "whatsapp", - "channel_id": null + "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -126,22 +110,14 @@ "valid": false, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", - "lookup": { - "carrier": { - "error_code": null, - "name": null, - "mobile_country_code": null, - "mobile_network_code": null, - "type": null - } - }, + "lookup": {}, "amount": null, "payee": null, "send_code_attempts": [ { "time": "2015-07-30T20:00:00Z", "channel": "EMAIL", - "channel_id": null + "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -169,22 +145,14 @@ "valid": false, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", - "lookup": { - "carrier": { - "error_code": null, - "name": "Carrier Name", - "mobile_country_code": "310", - "mobile_network_code": "150", - "type": "mobile" - } - }, + "lookup": {}, "amount": null, "payee": null, "send_code_attempts": [ { "time": "2015-07-30T20:00:00Z", "channel": "SMS", - "channel_id": null + "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -229,22 +197,14 @@ "valid": false, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", - "lookup": { - "carrier": { - "error_code": null, - "name": "Carrier Name", - "mobile_country_code": "310", - "mobile_network_code": "150", - "type": "mobile" - } - }, + "lookup": {}, "amount": null, "payee": null, "send_code_attempts": [ { "time": "2015-07-30T20:00:00Z", "channel": "SMS", - "channel_id": null + "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -272,22 +232,14 @@ "valid": true, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", - "lookup": { - "carrier": { - "error_code": null, - "name": "Carrier Name", - "mobile_country_code": "310", - "mobile_network_code": "150", - "type": "mobile" - } - }, + "lookup": {}, "amount": null, "payee": null, "send_code_attempts": [ { "time": "2015-07-30T20:00:00Z", "channel": "SMS", - "channel_id": null + "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -330,22 +282,14 @@ "valid": false, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", - "lookup": { - "carrier": { - "error_code": null, - "name": "Carrier Name", - "mobile_country_code": "310", - "mobile_network_code": "150", - "type": "mobile" - } - }, + "lookup": {}, "amount": null, "payee": null, "send_code_attempts": [ { "time": "2015-07-30T20:00:00Z", "channel": "SMS", - "channel_id": null + "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" diff --git a/spec/integration/verify/v2/verification_attempt_spec.rb b/spec/integration/verify/v2/verification_attempt_spec.rb index 1553c05e3..3146eb197 100644 --- a/spec/integration/verify/v2/verification_attempt_spec.rb +++ b/spec/integration/verify/v2/verification_attempt_spec.rb @@ -57,10 +57,15 @@ "sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "verification_sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2020-08-11T18:36:59Z", "date_updated": "2020-08-11T18:37:00Z", "conversion_status": "unconverted", "channel": "sms", + "price": { + "value": "0.005", + "currency": "usd" + }, "channel_data": { "verification_sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "+573003003030", @@ -117,10 +122,15 @@ "sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "verification_sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2020-08-11T18:36:59Z", "date_updated": "2020-08-11T18:37:00Z", "conversion_status": "unconverted", "channel": "sms", + "price": { + "value": "0.005", + "currency": "usd" + }, "channel_data": { "verification_sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "+573003003030", diff --git a/spec/integration/video/v1/composition_spec.rb b/spec/integration/video/v1/composition_spec.rb index a332f38f2..ffbf21d80 100644 --- a/spec/integration/video/v1/composition_spec.rb +++ b/spec/integration/video/v1/composition_spec.rb @@ -85,6 +85,8 @@ "media_external_location": null, "encryption_key": null, "url": "https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status_callback": "https://mycallbackurl.com", + "status_callback_method": "POST", "links": { "media": "https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" } @@ -219,6 +221,8 @@ "media_external_location": null, "encryption_key": null, "url": "https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status_callback": "https://mycallbackurl.com", + "status_callback_method": "POST", "links": { "media": "https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" } @@ -333,6 +337,8 @@ "media_external_location": null, "encryption_key": null, "url": "https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "status_callback": "https://mycallbackurl.com", + "status_callback_method": "POST", "links": { "media": "https://video.twilio.com/v1/Compositions/CJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" } diff --git a/spec/integration/video/v1/recording_spec.rb b/spec/integration/video/v1/recording_spec.rb index 64df4a67e..7bda72b78 100644 --- a/spec/integration/video/v1/recording_spec.rb +++ b/spec/integration/video/v1/recording_spec.rb @@ -43,6 +43,8 @@ "codec": "OPUS", "track_name": "A name", "offset": 10, + "status_callback": "https://mycallbackurl.com", + "status_callback_method": "POST", "grouping_sids": { "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, @@ -119,6 +121,8 @@ "codec": "OPUS", "track_name": "A name", "offset": 10, + "status_callback": "https://mycallbackurl.com", + "status_callback_method": "POST", "grouping_sids": { "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_sid": "PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" diff --git a/spec/rack/twilio_webhook_authentication_spec.rb b/spec/rack/twilio_webhook_authentication_spec.rb index 309bed868..b71a41116 100644 --- a/spec/rack/twilio_webhook_authentication_spec.rb +++ b/spec/rack/twilio_webhook_authentication_spec.rb @@ -31,6 +31,7 @@ auth_token = 'qwerty' account_sid = 12_345 expect_any_instance_of(Rack::Request).to receive(:post?).and_return(true) + expect_any_instance_of(Rack::Request).to receive(:media_type).and_return(Rack::MediaType.type('application/x-www-form-urlencoded')) expect_any_instance_of(Rack::Request).to receive(:POST).and_return({ 'AccountSid' => account_sid }) @middleware = Rack::TwilioWebhookAuthentication.new(@app, nil, /\/voice/) { |asid| auth_token } request_validator = double('RequestValidator') @@ -103,4 +104,92 @@ expect(status).to be(403) end end + + describe 'validating non-form-data POST payloads' do + it 'should fail if the body does not validate' do + middleware = Rack::TwilioWebhookAuthentication.new(@app, 'qwerty', /\/test/) + input = StringIO.new('{"message": "a post body that does not match the bodySHA256"}') + + request = Rack::MockRequest.env_for( + 'https://example.com/test?bodySHA256=79bfb0acaf0045fd30f13d48d4fe296b393d85a3bfbee881a0172b2bd574b11e', + method: 'POST', + input: input + ) + request['HTTP_X_TWILIO_SIGNATURE'] = '+LYlbGr/VmN84YPJQCuWs+9UA7E=' + request['CONTENT_TYPE'] = 'application/json' + + status, headers, body = middleware.call(request) + + expect(status).not_to be(200) + end + + it 'should validate if the body signature is correct' do + middleware = Rack::TwilioWebhookAuthentication.new(@app, 'qwerty', /\/test/) + input = StringIO.new('{"message": "a post body"}') + + request = Rack::MockRequest.env_for( + 'https://example.com/test?bodySHA256=8d90d640c6ba47d595ac56203d7f5c6b511be80fdf44a2055acca75a119b9fd2', + method: 'POST', + input: input + ) + request['HTTP_X_TWILIO_SIGNATURE'] = 'zR5Oq4f6cijN5oz5bisiVuxYnTU=' + request['CONTENT_TYPE'] = 'application/json' + + status, headers, body = middleware.call(request) + + expect(status).to be(200) + end + + it 'should validate even if a previous middleware read the body first' do + middleware = Rack::TwilioWebhookAuthentication.new(@app, 'qwerty', /\/test/) + input = StringIO.new('{"message": "a post body"}') + + request = Rack::MockRequest.env_for( + 'https://example.com/test?bodySHA256=8d90d640c6ba47d595ac56203d7f5c6b511be80fdf44a2055acca75a119b9fd2', + method: 'POST', + input: input + ) + request['HTTP_X_TWILIO_SIGNATURE'] = 'zR5Oq4f6cijN5oz5bisiVuxYnTU=' + request['CONTENT_TYPE'] = 'application/json' + request['rack.input'].read + + status, headers, body = middleware.call(request) + + expect(status).to be(200) + end + end + + describe 'validating application/x-www-form-urlencoded POST payloads' do + it 'should fail if the body does not validate' do + middleware = Rack::TwilioWebhookAuthentication.new(@app, 'qwerty', /\/test/) + + request = Rack::MockRequest.env_for( + 'https://example.com/test', + method: 'POST', + params: { 'foo' => 'bar' } + ) + request['HTTP_X_TWILIO_SIGNATURE'] = 'foobarbaz' + expect(request['CONTENT_TYPE']).to eq('application/x-www-form-urlencoded') + + status, headers, body = middleware.call(request) + + expect(status).not_to be(200) + end + + it 'should validate if the body signature is correct' do + middleware = Rack::TwilioWebhookAuthentication.new(@app, 'qwerty', /\/test/) + + request = Rack::MockRequest.env_for( + 'https://example.com/test', + method: 'POST', + params: { 'foo' => 'bar' } + ) + request['HTTP_X_TWILIO_SIGNATURE'] = 'TR9Skm9jiF4WVRJznU5glK5I83k=' + expect(request['CONTENT_TYPE']).to eq('application/x-www-form-urlencoded') + + status, headers, body = middleware.call(request) + + expect(status).to be(200) + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 18b0616ea..62fbbaa88 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,8 +15,8 @@ require_relative './holodeck/holodeck.rb' require_relative './holodeck/hologram.rb' -require 'twilio-ruby' require 'rack' +require 'twilio-ruby' require 'rspec/matchers' require 'equivalent-xml'