From fe105cf7c700ce405f6cb9728e841e2f64d17eb5 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Fri, 12 Dec 2025 15:23:37 +0530 Subject: [PATCH 01/11] chore: add new methods --- lib/twilio-ruby/framework/rest/version.rb | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/twilio-ruby/framework/rest/version.rb b/lib/twilio-ruby/framework/rest/version.rb index a55b3a902..d8dd8ea9e 100644 --- a/lib/twilio-ruby/framework/rest/version.rb +++ b/lib/twilio-ruby/framework/rest/version.rb @@ -166,6 +166,53 @@ def create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: n response.body end + + def create_with_metdata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) + response = request(method, uri, params, data, headers, auth, timeout) + + if response.status_code < 200 || response.status_code >= 300 + raise exception(response, 'Unable to create record') + end + + response + end + + def fetch_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) + response = request( + method, + uri, + params, + data, + headers, + auth, + timeout + ) + + # Note that 3XX response codes are allowed for fetches. + if response.status_code < 200 || response.status_code >= 400 + raise exception(response, 'Unable to fetch record') + end + + response + end + + def update_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) + response = request( + method, + uri, + params, + data, + headers, + auth, + timeout + ) + + if response.status_code < 200 || response.status_code >= 300 + raise exception(response, 'Unable to update record') + end + + response + end end end end From 092a516cb9079b82df94b05dd2ded87fbe665aee Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Fri, 12 Dec 2025 16:24:15 +0530 Subject: [PATCH 02/11] chore: resolve review comments --- lib/twilio-ruby/framework/rest/resource.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/twilio-ruby/framework/rest/resource.rb b/lib/twilio-ruby/framework/rest/resource.rb index 320e42e4f..07657238e 100644 --- a/lib/twilio-ruby/framework/rest/resource.rb +++ b/lib/twilio-ruby/framework/rest/resource.rb @@ -19,5 +19,20 @@ def initialize(version) @version = version end end + + class InstanceResourceMetadata + def initialize(version, headers, status_code) + @version = version + @headers = headers + @status_code = status_code + end + + def headers + @headers + end + def status_code + @status_code + end + end end end From ca72fe038edbeaa84ed2f918b97f3ae476070209 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Sun, 14 Dec 2025 17:15:22 +0530 Subject: [PATCH 03/11] chore: pagination --- .../framework/rest/page_metadata.rb | 106 ++++ lib/twilio-ruby/framework/rest/version.rb | 18 +- .../rest/api/v2010/account/message.rb | 476 ++++++++++++++---- test.rb | 12 + 4 files changed, 527 insertions(+), 85 deletions(-) create mode 100644 lib/twilio-ruby/framework/rest/page_metadata.rb create mode 100644 test.rb diff --git a/lib/twilio-ruby/framework/rest/page_metadata.rb b/lib/twilio-ruby/framework/rest/page_metadata.rb new file mode 100644 index 000000000..40326d7f1 --- /dev/null +++ b/lib/twilio-ruby/framework/rest/page_metadata.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true + +module Twilio + module REST + # Page Base Class + class PageMetadata + include Enumerable + + META_KEYS = [ + 'end', + 'first_page_uri', + 'next_page_uri', + 'last_page_uri', + 'page', + 'page_size', + 'previous_page_uri', + 'total', + 'num_pages', + 'start', + 'uri' + ].freeze + + def initialize(version, response) + payload = process_response(response) + + @version = version + @payload = payload + @solution = {} + @records = load_page(payload) + @headers = response.headers + @status_code = response.status_code + end + + def process_response(response) + if response.status_code != 200 + raise Twilio::REST::RestError.new('Unable to fetch page', response) + end + + response + end + + def load_page(payload) + return payload.body['Resources'] if payload.body['Resources'] + if payload.body['meta'] && payload.body['meta']['key'] + return payload.body[payload.body['meta']['key']] + else + keys = payload.body.keys + key = keys - META_KEYS + return payload.body[key.first] if key.size == 1 + end + + raise Twilio::REST::TwilioError, 'Page Records can not be deserialized' + end + + def previous_page_url + if @payload.body['meta'] && @payload.body['meta']['previous_page_url'] + return @version.domain.absolute_url(URI.parse(@payload.body['meta']['previous_page_url']).request_uri) + elsif @payload.body['previous_page_uri'] + return @version.domain.absolute_url(@payload.body['previous_page_uri']) + end + + nil + end + + def next_page_url + if @payload.body['meta'] && @payload.body['meta']['next_page_url'] + return @version.domain.absolute_url(URI.parse(@payload.body['meta']['next_page_url']).request_uri) + elsif @payload.body['next_page_uri'] + return @version.domain.absolute_url(@payload.body['next_page_uri']) + end + + nil + end + + def get_instance(payload) + raise Twilio::REST::TwilioError, 'Page.get_instance() must be implemented in the derived class' + end + + def previous_page + return nil unless previous_page_url + + response = @version.domain.request('GET', previous_page_url) + + self.class.new(@version, response, @solution) + end + + def next_page + return nil unless next_page_url + + response = @version.domain.request('GET', next_page_url) + + self.class.new(@version, response, @solution) + end + + def each + @records.each do |record| + yield get_instance(record) + end + end + + def to_s + '#' + end + end + end +end diff --git a/lib/twilio-ruby/framework/rest/version.rb b/lib/twilio-ruby/framework/rest/version.rb index d8dd8ea9e..b878eae36 100644 --- a/lib/twilio-ruby/framework/rest/version.rb +++ b/lib/twilio-ruby/framework/rest/version.rb @@ -157,6 +157,10 @@ def stream(page, limit: nil, page_limit: nil) RecordStream.new(page, limit: limit, page_limit: page_limit) end + def stream_with_metadata(page, limit: nil, page_limit: nil) + RecordStream.new(page, limit: limit, page_limit: page_limit) + end + def create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) response = request(method, uri, params, data, headers, auth, timeout) @@ -167,7 +171,7 @@ def create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: n response.body end - def create_with_metdata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) + def create_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) response = request(method, uri, params, data, headers, auth, timeout) if response.status_code < 200 || response.status_code >= 300 @@ -213,6 +217,18 @@ def update_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: n response end + + def page_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) + request( + method, + uri, + params, + data, + headers, + auth, + timeout + ) + end end end end diff --git a/lib/twilio-ruby/rest/api/v2010/account/message.rb b/lib/twilio-ruby/rest/api/v2010/account/message.rb index ea842ddf8..b2f09476e 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message.rb @@ -20,7 +20,7 @@ class V2010 < Version class AccountContext < InstanceContext class MessageList < ListResource - + ## # Initialize the MessageList # @param [Version] version Version that contains the resource @@ -30,29 +30,29 @@ def initialize(version, account_sid: nil) # Path Solution @solution = { account_sid: account_sid } @uri = "/Accounts/#{@solution[:account_sid]}/Messages.json" - + end ## # Create the MessageInstance # @param [String] to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`. - # @param [String] status_callback The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). + # @param [String] status_callback The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). # @param [String] application_sid The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored. # @param [Float] max_price [OBSOLETE] This parameter will no longer have any effect as of 2024-06-03. # @param [Boolean] provide_feedback Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`. # @param [String] attempt Total number of attempts made (including this request) to send the message regardless of the provider used # @param [String] validity_period The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `36000`. Default value is `36000`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) # @param [Boolean] force_delivery Reserved - # @param [ContentRetention] content_retention - # @param [AddressRetention] address_retention + # @param [ContentRetention] content_retention + # @param [AddressRetention] address_retention # @param [Boolean] smart_encoded Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. # @param [Array[String]] persistent_action Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). - # @param [TrafficType] traffic_type + # @param [TrafficType] traffic_type # @param [Boolean] shorten_urls For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. - # @param [ScheduleType] schedule_type + # @param [ScheduleType] schedule_type # @param [Time] send_at The time that Twilio will send the message. Must be in ISO 8601 format. # @param [Boolean] send_as_mms If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. # @param [String] content_variables For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. - # @param [RiskCheck] risk_check + # @param [RiskCheck] risk_check # @param [String] from The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool. # @param [String] body The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages). @@ -60,29 +60,29 @@ def initialize(version, account_sid: nil) # @param [String] content_sid For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources). # @return [MessageInstance] Created MessageInstance def create( - to: nil, - status_callback: :unset, - application_sid: :unset, - max_price: :unset, - provide_feedback: :unset, - attempt: :unset, - validity_period: :unset, - force_delivery: :unset, - content_retention: :unset, - address_retention: :unset, - smart_encoded: :unset, - persistent_action: :unset, - traffic_type: :unset, - shorten_urls: :unset, - schedule_type: :unset, - send_at: :unset, - send_as_mms: :unset, - content_variables: :unset, - risk_check: :unset, - from: :unset, - messaging_service_sid: :unset, - body: :unset, - media_url: :unset, + to: nil, + status_callback: :unset, + application_sid: :unset, + max_price: :unset, + provide_feedback: :unset, + attempt: :unset, + validity_period: :unset, + force_delivery: :unset, + content_retention: :unset, + address_retention: :unset, + smart_encoded: :unset, + persistent_action: :unset, + traffic_type: :unset, + shorten_urls: :unset, + schedule_type: :unset, + send_at: :unset, + send_as_mms: :unset, + content_variables: :unset, + risk_check: :unset, + from: :unset, + messaging_service_sid: :unset, + body: :unset, + media_url: :unset, content_sid: :unset ) @@ -114,11 +114,11 @@ def create( }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - - + + + + + payload = @version.create('POST', @uri, data: data, headers: headers) MessageInstance.new( @version, @@ -127,7 +127,108 @@ def create( ) end - + ## + # Create the MessageInstance + # @param [String] to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`. + # @param [String] status_callback The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). + # @param [String] application_sid The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored. + # @param [Float] max_price [OBSOLETE] This parameter will no longer have any effect as of 2024-06-03. + # @param [Boolean] provide_feedback Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`. + # @param [String] attempt Total number of attempts made (including this request) to send the message regardless of the provider used + # @param [String] validity_period The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `36000`. Default value is `36000`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) + # @param [Boolean] force_delivery Reserved + # @param [ContentRetention] content_retention + # @param [AddressRetention] address_retention + # @param [Boolean] smart_encoded Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. + # @param [Array[String]] persistent_action Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). + # @param [TrafficType] traffic_type + # @param [Boolean] shorten_urls For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. + # @param [ScheduleType] schedule_type + # @param [Time] send_at The time that Twilio will send the message. Must be in ISO 8601 format. + # @param [Boolean] send_as_mms If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. + # @param [String] content_variables For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + # @param [RiskCheck] risk_check + # @param [String] from The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. + # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool. + # @param [String] body The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages). + # @param [Array[String]] media_url The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/messaging/guides/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply. + # @param [String] content_sid For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources). + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + to: nil, + status_callback: :unset, + application_sid: :unset, + max_price: :unset, + provide_feedback: :unset, + attempt: :unset, + validity_period: :unset, + force_delivery: :unset, + content_retention: :unset, + address_retention: :unset, + smart_encoded: :unset, + persistent_action: :unset, + traffic_type: :unset, + shorten_urls: :unset, + schedule_type: :unset, + send_at: :unset, + send_as_mms: :unset, + content_variables: :unset, + risk_check: :unset, + from: :unset, + messaging_service_sid: :unset, + body: :unset, + media_url: :unset, + content_sid: :unset + ) + + data = Twilio::Values.of({ + 'To' => to, + 'StatusCallback' => status_callback, + 'ApplicationSid' => application_sid, + 'MaxPrice' => max_price, + 'ProvideFeedback' => provide_feedback, + 'Attempt' => attempt, + 'ValidityPeriod' => validity_period, + 'ForceDelivery' => force_delivery, + 'ContentRetention' => content_retention, + 'AddressRetention' => address_retention, + 'SmartEncoded' => smart_encoded, + 'PersistentAction' => Twilio.serialize_list(persistent_action) { |e| e }, + 'TrafficType' => traffic_type, + 'ShortenUrls' => shorten_urls, + 'ScheduleType' => schedule_type, + 'SendAt' => Twilio.serialize_iso8601_datetime(send_at), + 'SendAsMms' => send_as_mms, + 'ContentVariables' => content_variables, + 'RiskCheck' => risk_check, + 'From' => from, + 'MessagingServiceSid' => messaging_service_sid, + 'Body' => body, + 'MediaUrl' => Twilio.serialize_list(media_url) { |e| e }, + 'ContentSid' => content_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + + ## # Lists MessageInstance records from the API as a list. # Unlike stream(), this operation is eager and will load `limit` records into @@ -156,6 +257,18 @@ def list(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, ).entries end + def list_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, limit: nil, page_size: nil) + self.stream_with_metadata( + to: to, + from: from, + date_sent: date_sent, + date_sent_before: date_sent_before, + date_sent_after: date_sent_after, + limit: limit, + page_size: page_size + ).entries + end + ## # Streams Instance records from the API as an Enumerable. # This operation lazily loads records as efficiently as possible until the limit @@ -186,6 +299,21 @@ def stream(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + def stream_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page_with_metadata( + to: to, + from: from, + date_sent: date_sent, + date_sent_before: date_sent_before, + date_sent_after: date_sent_after, + page_size: limits[:page_size], ) + + # page + @version.stream_with_metadata(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -224,14 +352,34 @@ def page(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) - - + + response = @version.page('GET', @uri, params: params, headers: headers) MessagePage.new(@version, response, @solution) end + def page_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'DateSent' => Twilio.serialize_iso8601_datetime(date_sent), + 'DateSent<' => Twilio.serialize_iso8601_datetime(date_sent_before), + 'DateSent>' => Twilio.serialize_iso8601_datetime(date_sent_after), + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + headers = Twilio::Values.of({}) + + + + response = @version.page_with_metadata('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution) + end + ## # Retrieve a single page of MessageInstance records from the API. # Request is executed immediately. @@ -244,7 +392,7 @@ def get_page(target_url) ) MessagePage.new(@version, response, @solution) end - + # Provide a user friendly representation @@ -278,23 +426,35 @@ def initialize(version, account_sid, sid) def delete headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - + + + @version.delete('DELETE', @uri, headers: headers) end + ## + # Delete the MessageInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + @version.delete('DELETE', @uri, headers: headers) + end + ## # Fetch the MessageInstance # @return [MessageInstance] Fetched MessageInstance def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - - + + + + + payload = @version.fetch('GET', @uri, headers: headers) MessageInstance.new( @version, @@ -304,13 +464,39 @@ def fetch ) end + ## + # Fetch the MessageInstance + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessageInstance # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string - # @param [UpdateStatus] status + # @param [UpdateStatus] status # @return [MessageInstance] Updated MessageInstance def update( - body: :unset, + body: :unset, status: :unset ) @@ -320,11 +506,11 @@ def update( }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - - + + + + + payload = @version.update('POST', @uri, data: data, headers: headers) MessageInstance.new( @version, @@ -334,6 +520,42 @@ def update( ) end + ## + # Update the MessageInstance + # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string + # @param [UpdateStatus] status + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + body: :unset, + status: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Access the feedback # @return [FeedbackList] @@ -408,6 +630,30 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + end + + ## + # Build an instance of MessageInstance + # @param [Hash] payload Payload response from the API + # @return [MessageInstance] MessageInstance + def get_instance(payload) + MessageListResponse.new(@version, payload, account_sid: @solution[:account_sid]) + end + + ## + # Provide a user friendly representation + def to_s + '' + end + end class MessageInstance < InstanceResource ## # Initialize the MessageInstance @@ -420,9 +666,9 @@ class MessageInstance < InstanceResource # @return [MessageInstance] MessageInstance def initialize(version, payload , account_sid: nil, sid: nil) super(version) - + # Marshaled Properties - @properties = { + @properties = { 'body' => payload['body'], 'num_segments' => payload['num_segments'], 'direction' => payload['direction'], @@ -460,127 +706,127 @@ def context end @instance_context end - + ## # @return [String] The text content of the message def body @properties['body'] end - + ## # @return [String] The number of segments that make up the complete message. SMS message bodies that exceed the [character limit](https://www.twilio.com/docs/glossary/what-sms-character-limit) are segmented and charged as multiple messages. Note: For messages sent via a Messaging Service, `num_segments` is initially `0`, since a sender hasn't yet been assigned. def num_segments @properties['num_segments'] end - + ## - # @return [Direction] + # @return [Direction] def direction @properties['direction'] end - + ## # @return [String] The sender's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). For incoming messages, this is the number or channel address of the sender. For outgoing messages, this value is a Twilio phone number, alphanumeric sender ID, short code, or channel address from which the message is sent. def from @properties['from'] end - + ## # @return [String] The recipient's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format) or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g. `whatsapp:+15552229999`) def to @properties['to'] end - + ## # @return [Time] The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was last updated def date_updated @properties['date_updated'] end - + ## # @return [String] The amount billed for the message in the currency specified by `price_unit`. The `price` is populated after the message has been sent/received, and may not be immediately availalble. View the [Pricing page](https://www.twilio.com/en-us/pricing) for more details. def price @properties['price'] end - + ## # @return [String] The description of the `error_code` if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the `error_code` and `error_message` fields programmatically. def error_message @properties['error_message'] end - + ## # @return [String] The URI of the Message resource, relative to `https://api.twilio.com`. def uri @properties['uri'] end - + ## # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource def account_sid @properties['account_sid'] end - + ## # @return [String] The number of media files associated with the Message resource. def num_media @properties['num_media'] end - + ## - # @return [Status] + # @return [Status] def status @properties['status'] end - + ## # @return [String] The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. A unique default value is assigned if a Messaging Service is not used. def messaging_service_sid @properties['messaging_service_sid'] end - + ## # @return [String] The unique, Twilio-provided string that identifies the Message resource. def sid @properties['sid'] end - + ## # @return [Time] The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message was sent. For an outgoing message, this is when Twilio sent the message. For an incoming message, this is when Twilio sent the HTTP request to your incoming message webhook URL. def date_sent @properties['date_sent'] end - + ## # @return [Time] The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was created def date_created @properties['date_created'] end - + ## # @return [String] The [error code](https://www.twilio.com/docs/api/errors) returned if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the `error_code` and `error_message` fields programmatically. def error_code @properties['error_code'] end - + ## # @return [String] The currency in which `price` is measured, in [ISO 4127](https://www.iso.org/iso/home/standards/currency_codes.htm) format (e.g. `usd`, `eur`, `jpy`). def price_unit @properties['price_unit'] end - + ## # @return [String] The API version used to process the Message def api_version @properties['api_version'] end - + ## # @return [Hash] A list of related resources identified by their URIs relative to `https://api.twilio.com` def subresource_uris @properties['subresource_uris'] end - + ## # Delete the MessageInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -589,6 +835,14 @@ def delete context.delete end + ## + # Delete the MessageInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + context.delete + end + ## # Fetch the MessageInstance # @return [MessageInstance] Fetched MessageInstance @@ -597,22 +851,46 @@ def fetch context.fetch end + ## + # Fetch the MessageInstance + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + context.fetch + end + ## # Update the MessageInstance # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string - # @param [UpdateStatus] status + # @param [UpdateStatus] status # @return [MessageInstance] Updated MessageInstance def update( - body: :unset, + body: :unset, status: :unset ) context.update( - body: body, - status: status, + body: body, + status: status, ) end + ## + # Update the MessageInstance + # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string + # @param [UpdateStatus] status + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + body: :unset, + status: :unset + ) + + context.update( + body: body, + status: status, + ) + end + ## # Access the feedback # @return [feedback] feedback @@ -642,6 +920,36 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Hash] Header object with response headers. + # @param [MessageInstance] message_instance The instance associated with the metadata. + # @param [Integer] status_code The SID of the resource to fetch. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def instance + @message_instance + end + end + + class MessageListResponse + attr_reader :messages, :headers, :status_code + + # @param [Array] messages + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(messages, headers, status_code) + @messages = messages + @headers = headers + @status_code = status_code + end + end + end end end diff --git a/test.rb b/test.rb new file mode 100644 index 000000000..d12f4c39f --- /dev/null +++ b/test.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require "./lib/twilio-ruby" + +# Your Account SID and Auth Token from console.twilio.com +account_sid = ENV["TWILIO_ACCOUNT_SID"] +auth_token = ENV["TWILIO_AUTH_TOKEN"] + +@client = Twilio::REST::Client.new account_sid, auth_token +# message = @client.messages.list( limit: 20, page_size: 5) +message = @client.messages.list_with_metadata( limit: 20, page_size: 5) +puts message From 74799a473a253c43be6e5619e6a33868791fd3ec Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Mon, 15 Dec 2025 14:55:26 +0530 Subject: [PATCH 04/11] chore: custom error response redesign --- .../rest/api/v2010/account/message.rb | 107 ++++++++++++++---- 1 file changed, 82 insertions(+), 25 deletions(-) diff --git a/lib/twilio-ruby/rest/api/v2010/account/message.rb b/lib/twilio-ruby/rest/api/v2010/account/message.rb index b2f09476e..2f4736563 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message.rb @@ -631,29 +631,50 @@ def to_s end end - class MessagePageMetadata < PageMetadata - - def initialize(version, response, solution) - super(version, response) - - # Path Solution - @solution = solution - end - - ## - # Build an instance of MessageInstance - # @param [Hash] payload Payload response from the API - # @return [MessageInstance] MessageInstance - def get_instance(payload) - MessageListResponse.new(@version, payload, account_sid: @solution[:account_sid]) - end - - ## - # Provide a user friendly representation - def to_s - '' - end - end + class MessagePageMetadata < PageMetadata + attr_reader :messages, :headers, :status_code + + def initialize(version, response, solution) + super(version, response) + + # Path Solution + @solution = solution + @messages = [] + + # Process each record into a MessageInstance + @records.each do |record| + @messages << MessageInstance.new( + @version, + record, + account_sid: @solution[:account_sid] + ) + end + end + + def get_instance(payload) + # Create a new MessageListResponse containing the message instances, + # headers, and status code + MessageListResponse.new( + @messages, + @headers, + @status_code + ) + end + + def each + @messages.each do |message| + yield message + end + end + + def entries + get_instance(@records) + end + + def to_s + '' + end + end class MessageInstance < InstanceResource ## # Initialize the MessageInstance @@ -923,9 +944,10 @@ def inspect class MessageInstanceMetadata < InstanceResourceMetadata ## # Initializes a new MessageInstanceMetadata. - # @param [Hash] Header object with response headers. + # @param [Version] version Version that contains the resource # @param [MessageInstance] message_instance The instance associated with the metadata. - # @param [Integer] status_code The SID of the resource to fetch. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. # @return [MessageInstanceMetadata] The initialized instance with metadata. def initialize(version, message_instance, headers, status_code) super(version, headers, status_code) @@ -935,9 +957,22 @@ def initialize(version, message_instance, headers, status_code) def instance @message_instance end + + def headers + @headers + end + + def status_code + @status_code + end + + def to_s + "" + end end class MessageListResponse + include Enumerable attr_reader :messages, :headers, :status_code # @param [Array] messages @@ -948,6 +983,28 @@ def initialize(messages, headers, status_code) @headers = headers @status_code = status_code end + + # Make the MessageListResponse enumerable + def each + @messages.each do |message| + yield message + end + end + + # Allow accessing messages by index + def [](index) + @messages[index] + end + + # Return the number of messages + def size + @messages.size + end + alias length size + + def to_s + "" + end end end From aae16495cd0645939bb42c572e70f44658eaf9f7 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Tue, 16 Dec 2025 15:55:16 +0530 Subject: [PATCH 05/11] chore: custom error response redesign --- .../framework/rest/page_metadata.rb | 61 +++++++++++-------- .../rest/api/v2010/account/message.rb | 44 +++---------- test.rb | 1 + 3 files changed, 45 insertions(+), 61 deletions(-) diff --git a/lib/twilio-ruby/framework/rest/page_metadata.rb b/lib/twilio-ruby/framework/rest/page_metadata.rb index 40326d7f1..6d35d91ef 100644 --- a/lib/twilio-ruby/framework/rest/page_metadata.rb +++ b/lib/twilio-ruby/framework/rest/page_metadata.rb @@ -26,9 +26,7 @@ def initialize(version, response) @version = version @payload = payload @solution = {} - @records = load_page(payload) - @headers = response.headers - @status_code = response.status_code + @records = payload end def process_response(response) @@ -39,34 +37,35 @@ def process_response(response) response end - def load_page(payload) - return payload.body['Resources'] if payload.body['Resources'] - if payload.body['meta'] && payload.body['meta']['key'] - return payload.body[payload.body['meta']['key']] - else - keys = payload.body.keys - key = keys - META_KEYS - return payload.body[key.first] if key.size == 1 - end - - raise Twilio::REST::TwilioError, 'Page Records can not be deserialized' - end + # def load_page(payload) + # payload + # # return payload.body['Resources'] if payload.body['Resources'] + # # if payload.body['meta'] && payload.body['meta']['key'] + # # return payload.body[payload.body['meta']['key']] + # # else + # # keys = payload.body.keys + # # key = keys - META_KEYS + # # return payload.body[key.first] if key.size == 1 + # # end + # + # # raise Twilio::REST::TwilioError, 'Page Records can not be deserialized' + # end def previous_page_url - if @payload.body['meta'] && @payload.body['meta']['previous_page_url'] - return @version.domain.absolute_url(URI.parse(@payload.body['meta']['previous_page_url']).request_uri) - elsif @payload.body['previous_page_uri'] - return @version.domain.absolute_url(@payload.body['previous_page_uri']) + if @payload['meta'] && @payload['meta']['previous_page_url'] + return @version.domain.absolute_url(URI.parse(@payload['meta']['previous_page_url']).request_uri) + elsif @payload['previous_page_uri'] + return @version.domain.absolute_url(@payload['previous_page_uri']) end nil end def next_page_url - if @payload.body['meta'] && @payload.body['meta']['next_page_url'] - return @version.domain.absolute_url(URI.parse(@payload.body['meta']['next_page_url']).request_uri) - elsif @payload.body['next_page_uri'] - return @version.domain.absolute_url(@payload.body['next_page_uri']) + if @payload['meta'] && @payload['meta']['next_page_url'] + return @version.domain.absolute_url(URI.parse(@payload['meta']['next_page_url']).request_uri) + elsif @payload['next_page_uri'] + return @version.domain.absolute_url(@payload['next_page_uri']) end nil @@ -93,8 +92,20 @@ def next_page end def each - @records.each do |record| - yield get_instance(record) + current_record = 0 + current_page = 1 + + while @page + @page.each do |record| + yield record + current_record += 1 + return nil if @limit && @limit <= current_record + end + + return nil if @page_limit && @page_limit <= current_page + + @page = @page.next_page + current_page += 1 end end diff --git a/lib/twilio-ruby/rest/api/v2010/account/message.rb b/lib/twilio-ruby/rest/api/v2010/account/message.rb index 2f4736563..171fa0d63 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message.rb @@ -266,7 +266,7 @@ def list_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_be date_sent_after: date_sent_after, limit: limit, page_size: page_size - ).entries + ) end ## @@ -302,7 +302,7 @@ def stream(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset def stream_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) - page = self.page_with_metadata( + self.page_with_metadata( to: to, from: from, date_sent: date_sent, @@ -311,7 +311,7 @@ def stream_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_ page_size: limits[:page_size], ) # page - @version.stream_with_metadata(page, limit: limits[:limit], page_limit: limits[:page_limit]) + # @version.stream_with_metadata(page, limit: limits[:limit], page_limit: limits[:page_limit]) end ## @@ -632,43 +632,15 @@ def to_s end class MessagePageMetadata < PageMetadata - attr_reader :messages, :headers, :status_code def initialize(version, response, solution) super(version, response) - # Path Solution @solution = solution - @messages = [] - - # Process each record into a MessageInstance - @records.each do |record| - @messages << MessageInstance.new( - @version, - record, - account_sid: @solution[:account_sid] - ) - end end def get_instance(payload) - # Create a new MessageListResponse containing the message instances, - # headers, and status code - MessageListResponse.new( - @messages, - @headers, - @status_code - ) - end - - def each - @messages.each do |message| - yield message - end - end - - def entries - get_instance(@records) + MessageListResponse.new(payload) end def to_s @@ -973,15 +945,15 @@ def to_s class MessageListResponse include Enumerable - attr_reader :messages, :headers, :status_code + attr_reader :messages #, :headers, :status_code # @param [Array] messages # @param [Hash{String => Object}] headers # @param [Integer] status_code - def initialize(messages, headers, status_code) + def initialize(messages) @messages = messages - @headers = headers - @status_code = status_code + # @headers = headers + # @status_code = status_code end # Make the MessageListResponse enumerable diff --git a/test.rb b/test.rb index d12f4c39f..c258432b5 100644 --- a/test.rb +++ b/test.rb @@ -9,4 +9,5 @@ @client = Twilio::REST::Client.new account_sid, auth_token # message = @client.messages.list( limit: 20, page_size: 5) message = @client.messages.list_with_metadata( limit: 20, page_size: 5) +message.map { |item| item * 2 } # Internally calls collection.each puts message From 4d852b56892117b5a35a8e9a0d9c715122a95e9b Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Wed, 17 Dec 2025 16:28:47 +0530 Subject: [PATCH 06/11] chore: custom error response redesign --- lib/twilio-ruby/framework/rest/page_metadata.rb | 17 ++++++----------- .../rest/api/v2010/account/message.rb | 15 +++++++++++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/twilio-ruby/framework/rest/page_metadata.rb b/lib/twilio-ruby/framework/rest/page_metadata.rb index 6d35d91ef..3ceccbb90 100644 --- a/lib/twilio-ruby/framework/rest/page_metadata.rb +++ b/lib/twilio-ruby/framework/rest/page_metadata.rb @@ -4,7 +4,6 @@ module Twilio module REST # Page Base Class class PageMetadata - include Enumerable META_KEYS = [ 'end', @@ -62,10 +61,10 @@ def previous_page_url end def next_page_url - if @payload['meta'] && @payload['meta']['next_page_url'] - return @version.domain.absolute_url(URI.parse(@payload['meta']['next_page_url']).request_uri) - elsif @payload['next_page_uri'] - return @version.domain.absolute_url(@payload['next_page_uri']) + if @payload.body['meta'] && @payload.body['meta']['next_page_url'] + return @version.domain.absolute_url(URI.parse(@payload.body['meta']['next_page_url']).request_uri) + elsif @payload.body['next_page_uri'] + return @version.domain.absolute_url(@payload.body['next_page_uri']) end nil @@ -78,17 +77,13 @@ def get_instance(payload) def previous_page return nil unless previous_page_url - response = @version.domain.request('GET', previous_page_url) - - self.class.new(@version, response, @solution) + @version.domain.request('GET', previous_page_url) end def next_page return nil unless next_page_url - response = @version.domain.request('GET', next_page_url) - - self.class.new(@version, response, @solution) + @version.domain.request('GET', next_page_url) end def each diff --git a/lib/twilio-ruby/rest/api/v2010/account/message.rb b/lib/twilio-ruby/rest/api/v2010/account/message.rb index 171fa0d63..36f830b02 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message.rb @@ -308,7 +308,7 @@ def stream_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_ date_sent: date_sent, date_sent_before: date_sent_before, date_sent_after: date_sent_after, - page_size: limits[:page_size], ) + page_size: limits[:page_size], limit: limits[:limit]) # page # @version.stream_with_metadata(page, limit: limits[:limit], page_limit: limits[:page_limit]) @@ -360,7 +360,7 @@ def page(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, MessagePage.new(@version, response, @solution) end - def page_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + def page_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset, limit: :unset) params = Twilio::Values.of({ 'To' => to, 'From' => from, @@ -377,7 +377,7 @@ def page_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_be response = @version.page_with_metadata('GET', @uri, params: params, headers: headers) - MessagePageMetadata.new(@version, response, @solution) + MessagePageMetadata.new(@version, response, @solution, limit) end ## @@ -633,8 +633,15 @@ def to_s class MessagePageMetadata < PageMetadata - def initialize(version, response, solution) + def initialize(version, response, solution, limit) super(version, response) + @limit = limit + number_of_records = @payload.body["page_size"] + while( limit != :unset && number_of_records <= limit ) + next_page = self.next_page + break unless next_page + number_of_records += next_page.body["page_size"] + end # Path Solution @solution = solution end From 18e0f53ae96ab93237fe761517bc20e5eb35cccd Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Wed, 17 Dec 2025 17:48:18 +0530 Subject: [PATCH 07/11] chore: response with header --- .../rest/api/v2010/account/message.rb | 44 ++++++------------- test.rb | 5 +-- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/lib/twilio-ruby/rest/api/v2010/account/message.rb b/lib/twilio-ruby/rest/api/v2010/account/message.rb index 36f830b02..92afa0b9b 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message.rb @@ -632,13 +632,16 @@ def to_s end class MessagePageMetadata < PageMetadata + attr_reader :message_page def initialize(version, response, solution, limit) super(version, response) + @message_page = [] @limit = limit number_of_records = @payload.body["page_size"] while( limit != :unset && number_of_records <= limit ) next_page = self.next_page + @message_page << MessageListResponse.new(version, next_page) break unless next_page number_of_records += next_page.body["page_size"] end @@ -646,8 +649,10 @@ def initialize(version, response, solution, limit) @solution = solution end - def get_instance(payload) - MessageListResponse.new(payload) + def each + @message_page.each do |record| + yield record + end end def to_s @@ -951,38 +956,17 @@ def to_s end class MessageListResponse - include Enumerable - attr_reader :messages #, :headers, :status_code + attr_reader :messages , :headers, :status_code # @param [Array] messages # @param [Hash{String => Object}] headers # @param [Integer] status_code - def initialize(messages) - @messages = messages - # @headers = headers - # @status_code = status_code - end - - # Make the MessageListResponse enumerable - def each - @messages.each do |message| - yield message - end - end - - # Allow accessing messages by index - def [](index) - @messages[index] - end - - # Return the number of messages - def size - @messages.size - end - alias length size - - def to_s - "" + def initialize(version, payload) + @messages = payload.body['messages'].map do |message_data| + MessageInstance.new(version, message_data) + end + @headers = payload.headers + @status_code = payload.status_code end end diff --git a/test.rb b/test.rb index c258432b5..712afd994 100644 --- a/test.rb +++ b/test.rb @@ -8,6 +8,5 @@ @client = Twilio::REST::Client.new account_sid, auth_token # message = @client.messages.list( limit: 20, page_size: 5) -message = @client.messages.list_with_metadata( limit: 20, page_size: 5) -message.map { |item| item * 2 } # Internally calls collection.each -puts message +message_page_with_metadata = @client.messages.list_with_metadata( limit: 20, page_size: 5) +message_page_with_metadata.each { |item| puts item.messages } # Internally calls collection.each From dacd9aed56f9e1be4b3a3891e39a5c8d7212a1d1 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Thu, 18 Dec 2025 15:25:56 +0530 Subject: [PATCH 08/11] chore: token pagination --- lib/twilio-ruby/framework/rest/version.rb | 12 --- .../rest/api/v2010/account/message.rb | 84 +++++++------------ 2 files changed, 31 insertions(+), 65 deletions(-) diff --git a/lib/twilio-ruby/framework/rest/version.rb b/lib/twilio-ruby/framework/rest/version.rb index b878eae36..43e79159e 100644 --- a/lib/twilio-ruby/framework/rest/version.rb +++ b/lib/twilio-ruby/framework/rest/version.rb @@ -217,18 +217,6 @@ def update_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: n response end - - def page_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) - request( - method, - uri, - params, - data, - headers, - auth, - timeout - ) - end end end end diff --git a/lib/twilio-ruby/rest/api/v2010/account/message.rb b/lib/twilio-ruby/rest/api/v2010/account/message.rb index 92afa0b9b..5fff1b205 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message.rb @@ -258,15 +258,20 @@ def list(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, end def list_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, limit: nil, page_size: nil) - self.stream_with_metadata( - to: to, - from: from, - date_sent: date_sent, - date_sent_before: date_sent_before, - date_sent_after: date_sent_after, - limit: limit, - page_size: page_size - ) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'DateSent' => Twilio.serialize_iso8601_datetime(date_sent), + 'DateSent<' => Twilio.serialize_iso8601_datetime(date_sent_before), + 'DateSent>' => Twilio.serialize_iso8601_datetime(date_sent_after), + 'PageSize' => page_size, + }) + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) end ## @@ -299,21 +304,6 @@ def stream(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end - def stream_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, limit: nil, page_size: nil) - limits = @version.read_limits(limit, page_size) - - self.page_with_metadata( - to: to, - from: from, - date_sent: date_sent, - date_sent_before: date_sent_before, - date_sent_after: date_sent_after, - page_size: limits[:page_size], limit: limits[:limit]) - - # page - # @version.stream_with_metadata(page, limit: limits[:limit], page_limit: limits[:page_limit]) - end - ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -353,33 +343,10 @@ def page(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, }) headers = Twilio::Values.of({}) - - response = @version.page('GET', @uri, params: params, headers: headers) MessagePage.new(@version, response, @solution) end - - def page_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset, limit: :unset) - params = Twilio::Values.of({ - 'To' => to, - 'From' => from, - 'DateSent' => Twilio.serialize_iso8601_datetime(date_sent), - 'DateSent<' => Twilio.serialize_iso8601_datetime(date_sent_before), - 'DateSent>' => Twilio.serialize_iso8601_datetime(date_sent_after), - 'PageToken' => page_token, - 'Page' => page_number, - 'PageSize' => page_size, - }) - headers = Twilio::Values.of({}) - - - - response = @version.page_with_metadata('GET', @uri, params: params, headers: headers) - - MessagePageMetadata.new(@version, response, @solution, limit) - end - ## # Retrieve a single page of MessageInstance records from the API. # Request is executed immediately. @@ -639,9 +606,10 @@ def initialize(version, response, solution, limit) @message_page = [] @limit = limit number_of_records = @payload.body["page_size"] + key = get_key(@payload.body) while( limit != :unset && number_of_records <= limit ) next_page = self.next_page - @message_page << MessageListResponse.new(version, next_page) + @message_page << MessageListResponse.new(version, next_page, key) break unless next_page number_of_records += next_page.body["page_size"] end @@ -956,18 +924,28 @@ def to_s end class MessageListResponse - attr_reader :messages , :headers, :status_code - - # @param [Array] messages + # @param [Array] instance # @param [Hash{String => Object}] headers # @param [Integer] status_code - def initialize(version, payload) - @messages = payload.body['messages'].map do |message_data| + def initialize(version, payload, key) + @instance = payload.body[key].map do |message_data| MessageInstance.new(version, message_data) end @headers = payload.headers @status_code = payload.status_code end + + def instance + @instance + end + + def headers + @headers + end + + def status_code + @status_code + end end end From 35e5febc75e721fa1c2e5791ee9736d2947d2935 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Thu, 18 Dec 2025 15:26:05 +0530 Subject: [PATCH 09/11] chore: token pagination --- .../framework/rest/page_metadata.rb | 45 ++++++------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/lib/twilio-ruby/framework/rest/page_metadata.rb b/lib/twilio-ruby/framework/rest/page_metadata.rb index 3ceccbb90..4b7ec6b64 100644 --- a/lib/twilio-ruby/framework/rest/page_metadata.rb +++ b/lib/twilio-ruby/framework/rest/page_metadata.rb @@ -36,19 +36,18 @@ def process_response(response) response end - # def load_page(payload) - # payload - # # return payload.body['Resources'] if payload.body['Resources'] - # # if payload.body['meta'] && payload.body['meta']['key'] - # # return payload.body[payload.body['meta']['key']] - # # else - # # keys = payload.body.keys - # # key = keys - META_KEYS - # # return payload.body[key.first] if key.size == 1 - # # end - # - # # raise Twilio::REST::TwilioError, 'Page Records can not be deserialized' - # end + def get_key(payload) + return 'Resources' if payload['Resources'] + if payload['meta'] && payload['meta']['key'] + return payload['meta']['key'] + else + keys = payload.keys + key = keys - META_KEYS + return key.first if key.size == 1 + end + + raise Twilio::REST::TwilioError, 'Page Records can not be deserialized' + end def previous_page_url if @payload['meta'] && @payload['meta']['previous_page_url'] @@ -86,26 +85,8 @@ def next_page @version.domain.request('GET', next_page_url) end - def each - current_record = 0 - current_page = 1 - - while @page - @page.each do |record| - yield record - current_record += 1 - return nil if @limit && @limit <= current_record - end - - return nil if @page_limit && @page_limit <= current_page - - @page = @page.next_page - current_page += 1 - end - end - def to_s - '#' + '#' end end end From eb96a736d758e1df1d45ffae33e42ec21ec0c34d Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Thu, 18 Dec 2025 15:34:42 +0530 Subject: [PATCH 10/11] chore: response headers --- test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.rb b/test.rb index 712afd994..cb475d542 100644 --- a/test.rb +++ b/test.rb @@ -9,4 +9,4 @@ @client = Twilio::REST::Client.new account_sid, auth_token # message = @client.messages.list( limit: 20, page_size: 5) message_page_with_metadata = @client.messages.list_with_metadata( limit: 20, page_size: 5) -message_page_with_metadata.each { |item| puts item.messages } # Internally calls collection.each +message_page_with_metadata.each { |item| puts item.instance } # Internally calls collection.each From 4a073f57d5beb8337375af09e35844e7d06b9266 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Thu, 18 Dec 2025 19:23:36 +0530 Subject: [PATCH 11/11] chore: response with header --- .../framework/rest/page_metadata.rb | 13 +- lib/twilio-ruby/framework/rest/resource.rb | 17 + lib/twilio-ruby/framework/rest/version.rb | 22 +- .../rest/accounts/v1/auth_token_promotion.rb | 111 +++ .../rest/accounts/v1/bulk_consents.rb | 79 ++ .../rest/accounts/v1/bulk_contacts.rb | 79 ++ .../rest/accounts/v1/credential.rb | 48 ++ .../rest/accounts/v1/credential/aws.rb | 224 +++++- .../rest/accounts/v1/credential/public_key.rb | 224 +++++- .../accounts/v1/messaging_geopermissions.rb | 109 +++ lib/twilio-ruby/rest/accounts/v1/safelist.rb | 136 +++- .../rest/accounts/v1/secondary_auth_token.rb | 132 ++- lib/twilio-ruby/rest/api/v2010/account.rb | 204 +++++ .../rest/api/v2010/account/address.rb | 280 ++++++- .../account/address/dependent_phone_number.rb | 70 ++ .../rest/api/v2010/account/application.rb | 313 +++++++- .../v2010/account/authorized_connect_app.rb | 135 ++++ .../account/available_phone_number_country.rb | 135 ++++ .../available_phone_number_country/local.rb | 106 +++ .../machine_to_machine.rb | 106 +++ .../available_phone_number_country/mobile.rb | 106 +++ .../national.rb | 106 +++ .../shared_cost.rb | 106 +++ .../toll_free.rb | 106 +++ .../available_phone_number_country/voip.rb | 106 +++ .../rest/api/v2010/account/balance.rb | 73 ++ .../rest/api/v2010/account/call.rb | 367 ++++++++- .../rest/api/v2010/account/call/event.rb | 70 ++ .../api/v2010/account/call/notification.rb | 144 ++++ .../rest/api/v2010/account/call/payment.rb | 208 +++++ .../rest/api/v2010/account/call/recording.rb | 248 +++++- .../rest/api/v2010/account/call/siprec.rb | 760 ++++++++++++++++++ .../rest/api/v2010/account/call/stream.rb | 760 ++++++++++++++++++ .../api/v2010/account/call/transcription.rb | 193 +++++ .../account/call/user_defined_message.rb | 84 ++ .../call/user_defined_message_subscription.rb | 147 +++- .../rest/api/v2010/account/conference.rb | 190 +++++ .../v2010/account/conference/participant.rb | 407 +++++++++- .../api/v2010/account/conference/recording.rb | 200 ++++- .../rest/api/v2010/account/connect_app.rb | 210 ++++- .../v2010/account/incoming_phone_number.rb | 364 ++++++++- .../incoming_phone_number/assigned_add_on.rb | 190 ++++- .../assigned_add_on_extension.rb | 137 ++++ .../account/incoming_phone_number/local.rb | 176 ++++ .../account/incoming_phone_number/mobile.rb | 176 ++++ .../incoming_phone_number/toll_free.rb | 176 ++++ lib/twilio-ruby/rest/api/v2010/account/key.rb | 189 ++++- .../rest/api/v2010/account/message.rb | 697 ++++++++-------- .../api/v2010/account/message/feedback.rb | 81 ++ .../rest/api/v2010/account/message/media.rb | 163 +++- .../rest/api/v2010/account/new_key.rb | 80 ++ .../rest/api/v2010/account/new_signing_key.rb | 80 ++ .../rest/api/v2010/account/notification.rb | 143 ++++ .../api/v2010/account/outgoing_caller_id.rb | 193 ++++- .../rest/api/v2010/account/queue.rb | 227 +++++- .../rest/api/v2010/account/queue/member.rb | 173 ++++ .../rest/api/v2010/account/recording.rb | 174 +++- .../v2010/account/recording/add_on_result.rb | 157 +++- .../recording/add_on_result/payload.rb | 158 +++- .../recording/add_on_result/payload/data.rb | 115 +++ .../v2010/account/recording/transcription.rb | 157 +++- .../rest/api/v2010/account/short_code.rb | 187 +++++ .../rest/api/v2010/account/signing_key.rb | 189 ++++- lib/twilio-ruby/rest/api/v2010/account/sip.rb | 48 ++ .../api/v2010/account/sip/credential_list.rb | 221 ++++- .../account/sip/credential_list/credential.rb | 227 +++++- .../rest/api/v2010/account/sip/domain.rb | 293 ++++++- .../v2010/account/sip/domain/auth_types.rb | 48 ++ .../sip/domain/auth_types/auth_type_calls.rb | 48 ++ .../auth_calls_credential_list_mapping.rb | 190 ++++- ...th_calls_ip_access_control_list_mapping.rb | 190 ++++- .../auth_types/auth_type_registrations.rb | 48 ++ ...h_registrations_credential_list_mapping.rb | 190 ++++- .../sip/domain/credential_list_mapping.rb | 190 ++++- .../domain/ip_access_control_list_mapping.rb | 190 ++++- .../account/sip/ip_access_control_list.rb | 221 ++++- .../sip/ip_access_control_list/ip_address.rb | 236 +++++- .../rest/api/v2010/account/token.rb | 80 ++ .../rest/api/v2010/account/transcription.rb | 156 +++- .../rest/api/v2010/account/usage.rb | 48 ++ .../rest/api/v2010/account/usage/record.rb | 78 ++ .../v2010/account/usage/record/all_time.rb | 78 ++ .../api/v2010/account/usage/record/daily.rb | 78 ++ .../v2010/account/usage/record/last_month.rb | 78 ++ .../api/v2010/account/usage/record/monthly.rb | 78 ++ .../v2010/account/usage/record/this_month.rb | 78 ++ .../api/v2010/account/usage/record/today.rb | 78 ++ .../api/v2010/account/usage/record/yearly.rb | 78 ++ .../v2010/account/usage/record/yesterday.rb | 78 ++ .../rest/api/v2010/account/usage/trigger.rb | 251 +++++- .../api/v2010/account/validation_request.rb | 95 +++ .../rest/assistants/v1/assistant.rb | 208 ++++- .../v1/assistant/assistants_knowledge.rb | 156 +++- .../v1/assistant/assistants_tool.rb | 156 +++- .../rest/assistants/v1/assistant/feedback.rb | 97 +++ .../rest/assistants/v1/assistant/message.rb | 75 ++ .../rest/assistants/v1/knowledge.rb | 210 ++++- .../rest/assistants/v1/knowledge/chunk.rb | 70 ++ .../v1/knowledge/knowledge_status.rb | 112 +++ lib/twilio-ruby/rest/assistants/v1/policy.rb | 74 ++ lib/twilio-ruby/rest/assistants/v1/session.rb | 134 +++ .../rest/assistants/v1/session/message.rb | 70 ++ lib/twilio-ruby/rest/assistants/v1/tool.rb | 210 ++++- lib/twilio-ruby/rest/bulkexports/v1/export.rb | 112 +++ .../rest/bulkexports/v1/export/day.rb | 135 ++++ .../v1/export/export_custom_job.rb | 117 +++ .../rest/bulkexports/v1/export/job.rb | 133 ++- .../bulkexports/v1/export_configuration.rb | 150 ++++ lib/twilio-ruby/rest/chat/v1/credential.rb | 251 +++++- lib/twilio-ruby/rest/chat/v1/service.rb | 377 ++++++++- .../rest/chat/v1/service/channel.rb | 239 +++++- .../rest/chat/v1/service/channel/invite.rb | 196 ++++- .../rest/chat/v1/service/channel/member.rb | 233 +++++- .../rest/chat/v1/service/channel/message.rb | 235 +++++- lib/twilio-ruby/rest/chat/v1/service/role.rb | 227 +++++- lib/twilio-ruby/rest/chat/v1/service/user.rb | 236 +++++- .../rest/chat/v1/service/user/user_channel.rb | 70 ++ lib/twilio-ruby/rest/chat/v2/credential.rb | 251 +++++- lib/twilio-ruby/rest/chat/v2/service.rb | 308 ++++++- .../rest/chat/v2/service/binding.rb | 162 +++- .../rest/chat/v2/service/channel.rb | 264 +++++- .../rest/chat/v2/service/channel/invite.rb | 196 ++++- .../rest/chat/v2/service/channel/member.rb | 267 +++++- .../rest/chat/v2/service/channel/message.rb | 266 +++++- .../rest/chat/v2/service/channel/webhook.rb | 257 +++++- lib/twilio-ruby/rest/chat/v2/service/role.rb | 227 +++++- lib/twilio-ruby/rest/chat/v2/service/user.rb | 240 +++++- .../rest/chat/v2/service/user/user_binding.rb | 160 +++- .../rest/chat/v2/service/user/user_channel.rb | 200 ++++- lib/twilio-ruby/rest/chat/v3/channel.rb | 125 +++ lib/twilio-ruby/rest/content/v1/content.rb | 208 ++++- .../content/v1/content/approval_create.rb | 75 ++ .../rest/content/v1/content/approval_fetch.rb | 112 +++ .../rest/content/v1/content_and_approvals.rb | 70 ++ .../rest/content/v1/legacy_content.rb | 70 ++ lib/twilio-ruby/rest/content/v2/content.rb | 91 +++ .../rest/content/v2/content_and_approvals.rb | 91 +++ .../conversations/v1/address_configuration.rb | 277 ++++++- .../rest/conversations/v1/configuration.rb | 151 ++++ .../conversations/v1/configuration/webhook.rb | 154 ++++ .../rest/conversations/v1/conversation.rb | 291 ++++++- .../conversations/v1/conversation/message.rb | 269 ++++++- .../conversation/message/delivery_receipt.rb | 136 ++++ .../v1/conversation/participant.rb | 273 ++++++- .../conversations/v1/conversation/webhook.rb | 251 +++++- .../v1/conversation_with_participants.rb | 114 +++ .../rest/conversations/v1/credential.rb | 254 +++++- .../v1/participant_conversation.rb | 74 ++ lib/twilio-ruby/rest/conversations/v1/role.rb | 224 +++++- .../rest/conversations/v1/service.rb | 186 ++++- .../rest/conversations/v1/service/binding.rb | 162 +++- .../conversations/v1/service/configuration.rb | 153 ++++ .../v1/service/configuration/notification.rb | 180 +++++ .../v1/service/configuration/webhook.rb | 153 ++++ .../conversations/v1/service/conversation.rb | 294 ++++++- .../v1/service/conversation/message.rb | 272 ++++++- .../conversation/message/delivery_receipt.rb | 137 ++++ .../v1/service/conversation/participant.rb | 276 ++++++- .../v1/service/conversation/webhook.rb | 254 +++++- .../service/conversation_with_participants.rb | 115 +++ .../v1/service/participant_conversation.rb | 74 ++ .../rest/conversations/v1/service/role.rb | 227 +++++- .../rest/conversations/v1/service/user.rb | 243 +++++- .../v1/service/user/user_conversation.rb | 197 ++++- lib/twilio-ruby/rest/conversations/v1/user.rb | 240 +++++- .../v1/user/user_conversation.rb | 195 ++++- lib/twilio-ruby/rest/events/v1/event_type.rb | 136 ++++ lib/twilio-ruby/rest/events/v1/schema.rb | 112 +++ .../rest/events/v1/schema/schema_version.rb | 135 ++++ lib/twilio-ruby/rest/events/v1/sink.rb | 228 +++++- .../rest/events/v1/sink/sink_test.rb | 73 ++ .../rest/events/v1/sink/sink_validate.rb | 80 ++ .../rest/events/v1/subscription.rb | 226 +++++- .../v1/subscription/subscribed_event.rb | 224 +++++- .../rest/flex_api/v1/assessments.rb | 213 +++++ lib/twilio-ruby/rest/flex_api/v1/channel.rb | 213 ++++- .../rest/flex_api/v1/configuration.rb | 143 ++++ lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb | 316 +++++++- .../v1/insights_assessments_comment.rb | 124 +++ .../flex_api/v1/insights_conversations.rb | 74 ++ .../flex_api/v1/insights_questionnaires.rb | 250 +++++- .../v1/insights_questionnaires_category.rb | 202 ++++- .../v1/insights_questionnaires_question.rb | 229 +++++- .../rest/flex_api/v1/insights_segments.rb | 77 ++ .../rest/flex_api/v1/insights_session.rb | 114 +++ .../v1/insights_settings_answer_sets.rb | 75 ++ .../flex_api/v1/insights_settings_comment.rb | 75 ++ .../rest/flex_api/v1/insights_user_roles.rb | 114 +++ .../rest/flex_api/v1/interaction.rb | 184 +++++ .../v1/interaction/interaction_channel.rb | 171 ++++ .../interaction_channel_invite.rb | 103 +++ .../interaction_channel_participant.rb | 182 +++++ .../interaction_transfer.rb | 171 ++++ lib/twilio-ruby/rest/flex_api/v1/plugin.rb | 215 +++++ .../flex_api/v1/plugin/plugin_versions.rb | 189 +++++ .../rest/flex_api/v1/plugin_archive.rb | 115 +++ .../rest/flex_api/v1/plugin_configuration.rb | 178 ++++ .../plugin_configuration/configured_plugin.rb | 140 ++++ .../v1/plugin_configuration_archive.rb | 115 +++ .../rest/flex_api/v1/plugin_release.rb | 172 ++++ .../flex_api/v1/plugin_version_archive.rb | 116 +++ .../rest/flex_api/v1/provisioning_status.rb | 111 +++ .../rest/flex_api/v1/web_channel.rb | 236 +++++- lib/twilio-ruby/rest/flex_api/v2/flex_user.rb | 152 ++++ .../rest/flex_api/v2/web_channels.rb | 93 +++ lib/twilio-ruby/rest/frontline_api/v1/user.rb | 153 ++++ lib/twilio-ruby/rest/iam/v1/api_key.rb | 168 +++- lib/twilio-ruby/rest/iam/v1/get_api_keys.rb | 72 ++ lib/twilio-ruby/rest/iam/v1/new_api_key.rb | 88 ++ lib/twilio-ruby/rest/iam/v1/o_auth_app.rb | 161 +++- lib/twilio-ruby/rest/iam/v1/token.rb | 100 +++ lib/twilio-ruby/rest/insights/v1/call.rb | 112 +++ .../rest/insights/v1/call/annotation.rb | 162 ++++ .../rest/insights/v1/call/call_summary.rb | 118 +++ .../rest/insights/v1/call/event.rb | 72 ++ .../rest/insights/v1/call/metric.rb | 74 ++ .../rest/insights/v1/call_summaries.rb | 142 ++++ .../rest/insights/v1/conference.rb | 154 ++++ .../v1/conference/conference_participant.rb | 150 ++++ lib/twilio-ruby/rest/insights/v1/room.rb | 146 ++++ .../rest/insights/v1/room/participant.rb | 135 ++++ lib/twilio-ruby/rest/insights/v1/setting.rb | 154 ++++ .../rest/intelligence/v2/custom_operator.rb | 233 +++++- .../rest/intelligence/v2/operator.rb | 138 ++++ .../intelligence/v2/operator_attachment.rb | 134 ++- .../intelligence/v2/operator_attachments.rb | 112 +++ .../rest/intelligence/v2/operator_type.rb | 134 +++ .../rest/intelligence/v2/prebuilt_operator.rb | 138 ++++ .../rest/intelligence/v2/service.rb | 271 ++++++- .../rest/intelligence/v2/transcript.rb | 211 ++++- .../transcript/encrypted_operator_results.rb | 118 +++ .../v2/transcript/encrypted_sentences.rb | 118 +++ .../rest/intelligence/v2/transcript/media.rb | 118 +++ .../v2/transcript/operator_result.rb | 143 ++++ .../intelligence/v2/transcript/sentence.rb | 74 ++ .../rest/ip_messaging/v1/credential.rb | 251 +++++- .../rest/ip_messaging/v1/service.rb | 377 ++++++++- .../rest/ip_messaging/v1/service/channel.rb | 239 +++++- .../ip_messaging/v1/service/channel/invite.rb | 196 ++++- .../ip_messaging/v1/service/channel/member.rb | 233 +++++- .../v1/service/channel/message.rb | 235 +++++- .../rest/ip_messaging/v1/service/role.rb | 227 +++++- .../rest/ip_messaging/v1/service/user.rb | 236 +++++- .../v1/service/user/user_channel.rb | 70 ++ .../rest/ip_messaging/v2/credential.rb | 251 +++++- .../rest/ip_messaging/v2/service.rb | 308 ++++++- .../rest/ip_messaging/v2/service/binding.rb | 162 +++- .../rest/ip_messaging/v2/service/channel.rb | 264 +++++- .../ip_messaging/v2/service/channel/invite.rb | 196 ++++- .../ip_messaging/v2/service/channel/member.rb | 267 +++++- .../v2/service/channel/message.rb | 266 +++++- .../v2/service/channel/webhook.rb | 257 +++++- .../rest/ip_messaging/v2/service/role.rb | 227 +++++- .../rest/ip_messaging/v2/service/user.rb | 240 +++++- .../v2/service/user/user_binding.rb | 160 +++- .../v2/service/user/user_channel.rb | 197 ++++- .../rest/knowledge/v1/knowledge.rb | 210 ++++- .../rest/knowledge/v1/knowledge/chunk.rb | 70 ++ .../v1/knowledge/knowledge_status.rb | 112 +++ .../rest/lookups/v1/phone_number.rb | 127 +++ lib/twilio-ruby/rest/lookups/v2/bucket.rb | 162 +++- .../rest/lookups/v2/lookup_override.rb | 190 ++++- .../rest/lookups/v2/phone_number.rb | 160 ++++ lib/twilio-ruby/rest/lookups/v2/query.rb | 74 ++ lib/twilio-ruby/rest/lookups/v2/rate_limit.rb | 78 ++ .../rest/marketplace/v1/available_add_on.rb | 134 +++ .../available_add_on_extension.rb | 135 ++++ .../rest/marketplace/v1/installed_add_on.rb | 230 +++++- .../installed_add_on_extension.rb | 168 ++++ .../installed_add_on_usage.rb | 75 ++ .../rest/marketplace/v1/module_data.rb | 106 +++ .../marketplace/v1/module_data_management.rb | 162 ++++ .../marketplace/v1/referral_conversion.rb | 74 ++ .../rest/messaging/v1/brand_registration.rb | 202 +++++ .../brand_registration_otp.rb | 73 ++ .../v1/brand_registration/brand_vetting.rb | 172 ++++ .../rest/messaging/v1/deactivations.rb | 117 +++ .../rest/messaging/v1/domain_certs.rb | 165 +++- .../rest/messaging/v1/domain_config.rb | 153 ++++ .../v1/domain_config_messaging_service.rb | 112 +++ .../rest/messaging/v1/domain_validate_dn.rb | 112 +++ .../rest/messaging/v1/external_campaign.rb | 85 ++ .../v1/linkshortening_messaging_service.rb | 134 ++- ...ng_messaging_service_domain_association.rb | 112 +++ .../rest/messaging/v1/request_managed_cert.rb | 112 +++ lib/twilio-ruby/rest/messaging/v1/service.rb | 308 ++++++- .../rest/messaging/v1/service/alpha_sender.rb | 188 ++++- .../messaging/v1/service/channel_sender.rb | 188 ++++- .../v1/service/destination_alpha_sender.rb | 193 ++++- .../rest/messaging/v1/service/phone_number.rb | 188 ++++- .../rest/messaging/v1/service/short_code.rb | 188 ++++- .../messaging/v1/service/us_app_to_person.rb | 284 ++++++- .../v1/service/us_app_to_person_usecase.rb | 79 ++ .../messaging/v1/tollfree_verification.rb | 427 +++++++++- lib/twilio-ruby/rest/messaging/v1/usecase.rb | 72 ++ .../rest/messaging/v2/channels_sender.rb | 210 ++++- .../rest/messaging/v2/domain_certs.rb | 112 +++ .../rest/messaging/v2/typing_indicator.rb | 82 ++ lib/twilio-ruby/rest/monitor/v1/alert.rb | 140 ++++ lib/twilio-ruby/rest/monitor/v1/event.rb | 146 ++++ lib/twilio-ruby/rest/notify/v1/credential.rb | 251 +++++- lib/twilio-ruby/rest/notify/v1/service.rb | 298 ++++++- .../rest/notify/v1/service/binding.rb | 216 ++++- .../rest/notify/v1/service/notification.rb | 131 +++ .../rest/numbers/v1/bulk_eligibility.rb | 138 ++++ .../rest/numbers/v1/eligibility.rb | 74 ++ .../rest/numbers/v1/porting_all_port_in.rb | 82 ++ .../rest/numbers/v1/porting_port_in.rb | 159 +++- .../v1/porting_port_in_phone_number.rb | 134 ++- .../rest/numbers/v1/porting_portability.rb | 121 +++ .../v1/porting_webhook_configuration.rb | 74 ++ .../porting_webhook_configuration_delete.rb | 108 ++- .../v1/signing_request_configuration.rb | 100 +++ lib/twilio-ruby/rest/numbers/v1/webhook.rb | 72 ++ .../rest/numbers/v2/application.rb | 160 ++++ .../rest/numbers/v2/authorization_document.rb | 205 ++++- .../dependent_hosted_number_order.rb | 78 ++ .../numbers/v2/bulk_hosted_number_order.rb | 144 ++++ .../rest/numbers/v2/bundle_clone.rb | 125 +++ .../rest/numbers/v2/hosted_number_order.rb | 279 ++++++- .../rest/numbers/v2/regulatory_compliance.rb | 48 ++ .../v2/regulatory_compliance/bundle.rb | 270 ++++++- .../bundle/bundle_copy.rb | 102 +++ .../bundle/evaluation.rb | 160 ++++ .../bundle/item_assignment.rb | 188 ++++- .../bundle/replace_items.rb | 80 ++ .../v2/regulatory_compliance/end_user.rb | 227 +++++- .../v2/regulatory_compliance/end_user_type.rb | 134 +++ .../v2/regulatory_compliance/regulation.rb | 148 ++++ .../supporting_document.rb | 227 +++++- .../supporting_document_type.rb | 134 +++ .../rest/numbers/v3/hosted_number_order.rb | 127 +++ lib/twilio-ruby/rest/oauth/v1/authorize.rb | 90 +++ lib/twilio-ruby/rest/oauth/v1/token.rb | 100 +++ lib/twilio-ruby/rest/oauth/v2/token.rb | 105 +++ .../hosted_numbers/authorization_document.rb | 234 ++++++ .../dependent_hosted_number_order.rb | 80 ++ .../hosted_numbers/hosted_number_order.rb | 303 ++++++- .../preview/marketplace/available_add_on.rb | 134 +++ .../available_add_on_extension.rb | 135 ++++ .../preview/marketplace/installed_add_on.rb | 230 +++++- .../installed_add_on_extension.rb | 168 ++++ .../rest/preview/wireless/command.rb | 191 +++++ .../rest/preview/wireless/rate_plan.rb | 248 +++++- lib/twilio-ruby/rest/preview/wireless/sim.rb | 221 +++++ .../rest/preview/wireless/sim/usage.rb | 121 +++ .../rest/preview_iam/v1/authorize.rb | 90 +++ lib/twilio-ruby/rest/preview_iam/v1/token.rb | 100 +++ .../preview_iam/versionless/organization.rb | 112 +++ .../versionless/organization/account.rb | 135 ++++ .../organization/role_assignment.rb | 161 +++- .../versionless/organization/user.rb | 215 ++++- lib/twilio-ruby/rest/pricing/v1/messaging.rb | 48 ++ .../rest/pricing/v1/messaging/country.rb | 134 +++ .../rest/pricing/v1/phone_number.rb | 48 ++ .../rest/pricing/v1/phone_number/country.rb | 134 +++ lib/twilio-ruby/rest/pricing/v1/voice.rb | 48 ++ .../rest/pricing/v1/voice/country.rb | 134 +++ .../rest/pricing/v1/voice/number.rb | 112 +++ lib/twilio-ruby/rest/pricing/v2/country.rb | 134 +++ lib/twilio-ruby/rest/pricing/v2/number.rb | 118 +++ lib/twilio-ruby/rest/pricing/v2/voice.rb | 48 ++ .../rest/pricing/v2/voice/country.rb | 134 +++ .../rest/pricing/v2/voice/number.rb | 118 +++ lib/twilio-ruby/rest/proxy/v1/service.rb | 260 +++++- .../rest/proxy/v1/service/phone_number.rb | 227 +++++- .../rest/proxy/v1/service/session.rb | 242 +++++- .../proxy/v1/service/session/interaction.rb | 157 +++- .../proxy/v1/service/session/participant.rb | 199 ++++- .../participant/message_interaction.rb | 174 ++++ .../rest/routes/v2/phone_number.rb | 147 ++++ lib/twilio-ruby/rest/routes/v2/sip_domain.rb | 147 ++++ lib/twilio-ruby/rest/routes/v2/trunk.rb | 147 ++++ lib/twilio-ruby/rest/serverless/v1/service.rb | 233 +++++- .../rest/serverless/v1/service/asset.rb | 221 ++++- .../v1/service/asset/asset_version.rb | 136 ++++ .../rest/serverless/v1/service/build.rb | 197 ++++- .../v1/service/build/build_status.rb | 113 +++ .../rest/serverless/v1/service/environment.rb | 191 ++++- .../v1/service/environment/deployment.rb | 172 ++++ .../serverless/v1/service/environment/log.rb | 142 ++++ .../v1/service/environment/variable.rb | 230 +++++- .../rest/serverless/v1/service/function.rb | 221 ++++- .../v1/service/function/function_version.rb | 136 ++++ .../function_version_content.rb | 114 +++ lib/twilio-ruby/rest/studio/v1/flow.rb | 155 +++- .../rest/studio/v1/flow/engagement.rb | 194 ++++- .../v1/flow/engagement/engagement_context.rb | 113 +++ .../rest/studio/v1/flow/engagement/step.rb | 136 ++++ .../v1/flow/engagement/step/step_context.rb | 114 +++ .../rest/studio/v1/flow/execution.rb | 231 +++++- .../v1/flow/execution/execution_context.rb | 113 +++ .../v1/flow/execution/execution_step.rb | 136 ++++ .../execution_step/execution_step_context.rb | 114 +++ lib/twilio-ruby/rest/studio/v2/flow.rb | 236 +++++- .../rest/studio/v2/flow/execution.rb | 231 +++++- .../v2/flow/execution/execution_context.rb | 113 +++ .../v2/flow/execution/execution_step.rb | 136 ++++ .../execution_step/execution_step_context.rb | 114 +++ .../rest/studio/v2/flow/flow_revision.rb | 135 ++++ .../rest/studio/v2/flow/flow_test_user.rb | 144 ++++ .../rest/studio/v2/flow_validate.rb | 88 ++ .../rest/supersim/v1/esim_profile.rb | 180 +++++ lib/twilio-ruby/rest/supersim/v1/fleet.rb | 241 ++++++ .../rest/supersim/v1/ip_command.rb | 188 +++++ lib/twilio-ruby/rest/supersim/v1/network.rb | 140 ++++ .../supersim/v1/network_access_profile.rb | 200 +++++ .../network_access_profile_network.rb | 188 ++++- .../rest/supersim/v1/settings_update.rb | 74 ++ lib/twilio-ruby/rest/supersim/v1/sim.rb | 221 +++++ .../rest/supersim/v1/sim/billing_period.rb | 70 ++ .../rest/supersim/v1/sim/sim_ip_address.rb | 70 ++ .../rest/supersim/v1/sms_command.rb | 180 +++++ .../rest/supersim/v1/usage_record.rb | 86 ++ lib/twilio-ruby/rest/sync/v1/service.rb | 254 +++++- .../rest/sync/v1/service/document.rb | 232 +++++- .../service/document/document_permission.rb | 197 ++++- .../rest/sync/v1/service/sync_list.rb | 230 +++++- .../v1/service/sync_list/sync_list_item.rb | 253 +++++- .../service/sync_list/sync_list_permission.rb | 197 ++++- .../rest/sync/v1/service/sync_map.rb | 230 +++++- .../sync/v1/service/sync_map/sync_map_item.rb | 256 +++++- .../service/sync_map/sync_map_permission.rb | 197 ++++- .../rest/sync/v1/service/sync_stream.rb | 224 +++++- .../v1/service/sync_stream/stream_message.rb | 81 ++ .../rest/taskrouter/v1/workspace.rb | 253 +++++- .../rest/taskrouter/v1/workspace/activity.rb | 228 +++++- .../rest/taskrouter/v1/workspace/event.rb | 157 ++++ .../rest/taskrouter/v1/workspace/task.rb | 286 ++++++- .../v1/workspace/task/reservation.rb | 335 ++++++++ .../taskrouter/v1/workspace/task_channel.rb | 230 +++++- .../taskrouter/v1/workspace/task_queue.rb | 259 +++++- .../task_queue_bulk_real_time_statistics.rb | 75 ++ .../task_queue_cumulative_statistics.rb | 131 +++ .../task_queue_real_time_statistics.rb | 119 +++ .../task_queue/task_queue_statistics.rb | 131 +++ .../task_queue/task_queues_statistics.rb | 82 ++ .../rest/taskrouter/v1/workspace/worker.rb | 257 +++++- .../v1/workspace/worker/reservation.rb | 327 ++++++++ .../v1/workspace/worker/worker_channel.rb | 173 ++++ .../v1/workspace/worker/worker_statistics.rb | 128 +++ .../worker/workers_cumulative_statistics.rb | 127 +++ .../worker/workers_real_time_statistics.rb | 118 +++ .../v1/workspace/worker/workers_statistics.rb | 136 ++++ .../rest/taskrouter/v1/workspace/workflow.rb | 250 +++++- .../workflow_cumulative_statistics.rb | 131 +++ .../workflow/workflow_real_time_statistics.rb | 119 +++ .../workspace/workflow/workflow_statistics.rb | 131 +++ .../workspace_cumulative_statistics.rb | 130 +++ .../workspace_real_time_statistics.rb | 118 +++ .../v1/workspace/workspace_statistics.rb | 130 +++ lib/twilio-ruby/rest/trunking/v1/trunk.rb | 260 +++++- .../rest/trunking/v1/trunk/credential_list.rb | 188 ++++- .../v1/trunk/ip_access_control_list.rb | 188 ++++- .../rest/trunking/v1/trunk/origination_url.rb | 245 +++++- .../rest/trunking/v1/trunk/phone_number.rb | 188 ++++- .../rest/trunking/v1/trunk/recording.rb | 147 ++++ .../rest/trusthub/v1/compliance_inquiries.rb | 159 ++++ .../v1/compliance_registration_inquiries.rb | 267 ++++++ .../v1/compliance_tollfree_inquiries.rb | 184 +++++ .../rest/trusthub/v1/customer_profiles.rb | 242 +++++- ...er_profiles_channel_endpoint_assignment.rb | 195 ++++- .../customer_profiles_entity_assignments.rb | 190 ++++- .../customer_profiles_evaluations.rb | 167 ++++ lib/twilio-ruby/rest/trusthub/v1/end_user.rb | 227 +++++- .../rest/trusthub/v1/end_user_type.rb | 134 +++ lib/twilio-ruby/rest/trusthub/v1/policies.rb | 134 +++ .../rest/trusthub/v1/supporting_document.rb | 227 +++++- .../trusthub/v1/supporting_document_type.rb | 134 +++ .../rest/trusthub/v1/trust_products.rb | 242 +++++- ...st_products_channel_endpoint_assignment.rb | 195 ++++- .../trust_products_entity_assignments.rb | 190 ++++- .../trust_products_evaluations.rb | 167 ++++ lib/twilio-ruby/rest/verify/v2/form.rb | 112 +++ lib/twilio-ruby/rest/verify/v2/safelist.rb | 164 +++- lib/twilio-ruby/rest/verify/v2/service.rb | 368 ++++++++- .../rest/verify/v2/service/access_token.rb | 154 ++++ .../verify/v2/service/approve_challenge.rb | 75 ++ .../rest/verify/v2/service/entity.rb | 188 ++++- .../verify/v2/service/entity/challenge.rb | 227 ++++++ .../service/entity/challenge/notification.rb | 82 ++ .../rest/verify/v2/service/entity/factor.rb | 215 ++++- .../verify/v2/service/entity/new_factor.rb | 120 +++ .../v2/service/messaging_configuration.rb | 224 +++++- .../rest/verify/v2/service/new_challenge.rb | 114 +++ .../rest/verify/v2/service/new_factor.rb | 75 ++ .../verify/v2/service/new_verify_factor.rb | 75 ++ .../rest/verify/v2/service/rate_limit.rb | 224 +++++- .../verify/v2/service/rate_limit/bucket.rb | 230 +++++- .../rest/verify/v2/service/verification.rb | 229 ++++++ .../verify/v2/service/verification_check.rb | 95 +++ .../rest/verify/v2/service/webhook.rb | 245 +++++- lib/twilio-ruby/rest/verify/v2/template.rb | 72 ++ .../rest/verify/v2/verification_attempt.rb | 150 ++++ .../v2/verification_attempts_summary.rb | 132 +++ lib/twilio-ruby/rest/video/v1/composition.rb | 218 ++++- .../rest/video/v1/composition_hook.rb | 280 ++++++- .../rest/video/v1/composition_settings.rb | 157 ++++ lib/twilio-ruby/rest/video/v1/recording.rb | 168 +++- .../rest/video/v1/recording_settings.rb | 157 ++++ lib/twilio-ruby/rest/video/v1/room.rb | 253 ++++++ .../rest/video/v1/room/participant.rb | 176 ++++ .../video/v1/room/participant/anonymize.rb | 113 +++ .../v1/room/participant/published_track.rb | 136 ++++ .../v1/room/participant/subscribe_rules.rb | 107 +++ .../v1/room/participant/subscribed_track.rb | 136 ++++ .../rest/video/v1/room/recording_rules.rb | 105 +++ .../rest/video/v1/room/room_recording.rb | 164 +++- .../rest/video/v1/room/transcriptions.rb | 200 +++++ .../rest/voice/v1/archived_call.rb | 108 ++- lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb | 272 ++++++- .../rest/voice/v1/connection_policy.rb | 218 ++++- .../connection_policy_target.rb | 245 +++++- .../rest/voice/v1/dialing_permissions.rb | 48 ++ .../bulk_country_update.rb | 79 ++ .../voice/v1/dialing_permissions/country.rb | 146 ++++ .../country/highrisk_special_prefix.rb | 70 ++ .../voice/v1/dialing_permissions/settings.rb | 142 ++++ lib/twilio-ruby/rest/voice/v1/ip_record.rb | 224 +++++- .../rest/voice/v1/source_ip_mapping.rb | 221 ++++- lib/twilio-ruby/rest/wireless/v1/command.rb | 212 ++++- lib/twilio-ruby/rest/wireless/v1/rate_plan.rb | 254 +++++- lib/twilio-ruby/rest/wireless/v1/sim.rb | 248 +++++- .../rest/wireless/v1/sim/data_session.rb | 70 ++ .../rest/wireless/v1/sim/usage_record.rb | 76 ++ .../rest/wireless/v1/usage_record.rb | 76 ++ test.rb | 35 +- 527 files changed, 87210 insertions(+), 576 deletions(-) diff --git a/lib/twilio-ruby/framework/rest/page_metadata.rb b/lib/twilio-ruby/framework/rest/page_metadata.rb index 4b7ec6b64..a51ce6261 100644 --- a/lib/twilio-ruby/framework/rest/page_metadata.rb +++ b/lib/twilio-ruby/framework/rest/page_metadata.rb @@ -4,7 +4,6 @@ module Twilio module REST # Page Base Class class PageMetadata - META_KEYS = [ 'end', 'first_page_uri', @@ -74,8 +73,6 @@ def get_instance(payload) end def previous_page - return nil unless previous_page_url - @version.domain.request('GET', previous_page_url) end @@ -85,6 +82,16 @@ def next_page @version.domain.request('GET', next_page_url) end + def page_size + if @payload.body['meta'] && @payload.body['meta']['page_size'] + return @payload.body['meta']['page_size'] + elsif @payload.body['page_size'] + return @payload.body['page_size'] + end + + 0 + end + def to_s '#' end diff --git a/lib/twilio-ruby/framework/rest/resource.rb b/lib/twilio-ruby/framework/rest/resource.rb index 07657238e..fc1bc91a8 100644 --- a/lib/twilio-ruby/framework/rest/resource.rb +++ b/lib/twilio-ruby/framework/rest/resource.rb @@ -21,6 +21,22 @@ def initialize(version) end class InstanceResourceMetadata + def initialize(payload, headers, status_code) + @payload = payload + @headers = headers + @status_code = status_code + end + + def headers + @headers + end + + def status_code + @status_code + end + end + + class InstanceListResource def initialize(version, headers, status_code) @version = version @headers = headers @@ -30,6 +46,7 @@ def initialize(version, headers, status_code) def headers @headers end + def status_code @status_code end diff --git a/lib/twilio-ruby/framework/rest/version.rb b/lib/twilio-ruby/framework/rest/version.rb index 8e65d403b..af5e0e31d 100644 --- a/lib/twilio-ruby/framework/rest/version.rb +++ b/lib/twilio-ruby/framework/rest/version.rb @@ -157,10 +157,6 @@ def stream(page, limit: nil, page_limit: nil) RecordStream.new(page, limit: limit, page_limit: page_limit) end - def stream_with_metadata(page, limit: nil, page_limit: nil) - RecordStream.new(page, limit: limit, page_limit: page_limit) - end - def create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) response = request(method, uri, params, data, headers, auth, timeout) @@ -217,6 +213,24 @@ def update_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: n response end + + def delete_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) + response = request( + method, + uri, + params, + data, + headers, + auth, + timeout + ) + + if response.status_code < 200 || response.status_code >= 400 + raise exception(response, 'Unable to delete record') + end + + response + end end end end diff --git a/lib/twilio-ruby/rest/accounts/v1/auth_token_promotion.rb b/lib/twilio-ruby/rest/accounts/v1/auth_token_promotion.rb index aaf785c66..aa4295711 100644 --- a/lib/twilio-ruby/rest/accounts/v1/auth_token_promotion.rb +++ b/lib/twilio-ruby/rest/accounts/v1/auth_token_promotion.rb @@ -72,6 +72,30 @@ def update ) end + ## + # Update the AuthTokenPromotionInstanceMetadata + # @return [AuthTokenPromotionInstance] Updated AuthTokenPromotionInstance + def update_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers) + authTokenPromotion_instance = AuthTokenPromotionInstance.new( + @version, + response.body, + ) + AuthTokenPromotionInstanceMetadata.new( + @version, + authTokenPromotion_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -88,6 +112,45 @@ def inspect end end + class AuthTokenPromotionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AuthTokenPromotionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AuthTokenPromotionInstance] auth_token_promotion_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AuthTokenPromotionInstanceMetadata] The initialized instance with metadata. + def initialize(version, auth_token_promotion_instance, headers, status_code) + super(version, headers, status_code) + @auth_token_promotion_instance = auth_token_promotion_instance + end + + def auth_token_promotion + @auth_token_promotion_instance + end + + def to_s + "" + end + end + + class AuthTokenPromotionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_token_promotion_instance = payload.body[key].map do |data| + AuthTokenPromotionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_token_promotion_instance + @instance + end + end + class AuthTokenPromotionPage < Page ## # Initialize the AuthTokenPromotionPage @@ -116,6 +179,54 @@ def to_s '' end end + + class AuthTokenPromotionPageMetadata < PageMetadata + attr_reader :auth_token_promotion_page + + def initialize(version, response, solution, limit) + super(version, response) + @auth_token_promotion_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @auth_token_promotion_page << AuthTokenPromotionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @auth_token_promotion_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthTokenPromotionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_token_promotion = payload.body[key].map do |data| + AuthTokenPromotionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_token_promotion + @auth_token_promotion + end + end + class AuthTokenPromotionInstance < InstanceResource ## # Initialize the AuthTokenPromotionInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/bulk_consents.rb b/lib/twilio-ruby/rest/accounts/v1/bulk_consents.rb index 6ae8123b6..b1ae4125d 100644 --- a/lib/twilio-ruby/rest/accounts/v1/bulk_consents.rb +++ b/lib/twilio-ruby/rest/accounts/v1/bulk_consents.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the BulkConsentsInstanceMetadata + # @param [Array[Hash]] items This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty. + # @return [BulkConsentsInstance] Created BulkConsentsInstance + def create_with_metadata( + items: nil + ) + + data = Twilio::Values.of({ + 'Items' => Twilio.serialize_list(items) { |e| Twilio.serialize_object(e) }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + bulkConsents_instance = BulkConsentsInstance.new( + @version, + response.body, + ) + BulkConsentsInstanceMetadata.new( + @version, + bulkConsents_instance, + response.headers, + response.status_code + ) + end + @@ -92,6 +123,54 @@ def to_s '' end end + + class BulkConsentsPageMetadata < PageMetadata + attr_reader :bulk_consents_page + + def initialize(version, response, solution, limit) + super(version, response) + @bulk_consents_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bulk_consents_page << BulkConsentsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bulk_consents_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BulkConsentsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bulk_consents = payload.body[key].map do |data| + BulkConsentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bulk_consents + @bulk_consents + end + end + class BulkConsentsInstance < InstanceResource ## # Initialize the BulkConsentsInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/bulk_contacts.rb b/lib/twilio-ruby/rest/accounts/v1/bulk_contacts.rb index d7bda89ff..adab7253b 100644 --- a/lib/twilio-ruby/rest/accounts/v1/bulk_contacts.rb +++ b/lib/twilio-ruby/rest/accounts/v1/bulk_contacts.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the BulkContactsInstanceMetadata + # @param [Array[Hash]] items A list of objects where each object represents a contact's details. Each object includes the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID that maps the response to the original request; `country_iso_code`, a string representing the country using the ISO format (e.g., US for the United States); and `zip_code`, a string representing the postal code. + # @return [BulkContactsInstance] Created BulkContactsInstance + def create_with_metadata( + items: nil + ) + + data = Twilio::Values.of({ + 'Items' => Twilio.serialize_list(items) { |e| Twilio.serialize_object(e) }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + bulkContacts_instance = BulkContactsInstance.new( + @version, + response.body, + ) + BulkContactsInstanceMetadata.new( + @version, + bulkContacts_instance, + response.headers, + response.status_code + ) + end + @@ -92,6 +123,54 @@ def to_s '' end end + + class BulkContactsPageMetadata < PageMetadata + attr_reader :bulk_contacts_page + + def initialize(version, response, solution, limit) + super(version, response) + @bulk_contacts_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bulk_contacts_page << BulkContactsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bulk_contacts_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BulkContactsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bulk_contacts = payload.body[key].map do |data| + BulkContactsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bulk_contacts + @bulk_contacts + end + end + class BulkContactsInstance < InstanceResource ## # Initialize the BulkContactsInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/credential.rb b/lib/twilio-ruby/rest/accounts/v1/credential.rb index 3721fdbd7..a18c6faa7 100644 --- a/lib/twilio-ruby/rest/accounts/v1/credential.rb +++ b/lib/twilio-ruby/rest/accounts/v1/credential.rb @@ -95,6 +95,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/credential/aws.rb b/lib/twilio-ruby/rest/accounts/v1/credential/aws.rb index 497e5f45b..05409d96e 100644 --- a/lib/twilio-ruby/rest/accounts/v1/credential/aws.rb +++ b/lib/twilio-ruby/rest/accounts/v1/credential/aws.rb @@ -63,6 +63,43 @@ def create( ) end + ## + # Create the AwsInstanceMetadata + # @param [String] credentials A string that contains the AWS access credentials in the format `:`. For example, `AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] account_sid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request. + # @return [AwsInstance] Created AwsInstance + def create_with_metadata( + credentials: nil, + friendly_name: :unset, + account_sid: :unset + ) + + data = Twilio::Values.of({ + 'Credentials' => credentials, + 'FriendlyName' => friendly_name, + 'AccountSid' => account_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + aws_instance = AwsInstance.new( + @version, + response.body, + ) + AwsInstanceMetadata.new( + @version, + aws_instance, + response.headers, + response.status_code + ) + end + ## # Lists AwsInstance records from the API as a list. @@ -102,6 +139,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AwsPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AwsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AwsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +243,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AwsInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + aws_instance = AwsInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AwsInstanceMetadata.new(@version, aws_instance, response.headers, response.status_code) end ## @@ -206,6 +284,31 @@ def fetch ) end + ## + # Fetch the AwsInstanceMetadata + # @return [AwsInstance] Fetched AwsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + aws_instance = AwsInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AwsInstanceMetadata.new( + @version, + aws_instance, + response.headers, + response.status_code + ) + end + ## # Update the AwsInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -232,6 +335,38 @@ def update( ) end + ## + # Update the AwsInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [AwsInstance] Updated AwsInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + aws_instance = AwsInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AwsInstanceMetadata.new( + @version, + aws_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -248,6 +383,45 @@ def inspect end end + class AwsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AwsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AwsInstance] aws_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AwsInstanceMetadata] The initialized instance with metadata. + def initialize(version, aws_instance, headers, status_code) + super(version, headers, status_code) + @aws_instance = aws_instance + end + + def aws + @aws_instance + end + + def to_s + "" + end + end + + class AwsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @aws_instance = payload.body[key].map do |data| + AwsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def aws_instance + @instance + end + end + class AwsPage < Page ## # Initialize the AwsPage @@ -276,6 +450,54 @@ def to_s '' end end + + class AwsPageMetadata < PageMetadata + attr_reader :aws_page + + def initialize(version, response, solution, limit) + super(version, response) + @aws_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @aws_page << AwsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @aws_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AwsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @aws = payload.body[key].map do |data| + AwsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def aws + @aws + end + end + class AwsInstance < InstanceResource ## # Initialize the AwsInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb b/lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb index 68ced229f..8fd04c775 100644 --- a/lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb +++ b/lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb @@ -63,6 +63,43 @@ def create( ) end + ## + # Create the PublicKeyInstanceMetadata + # @param [String] public_key A URL encoded representation of the public key. For example, `-----BEGIN PUBLIC KEY-----MIIBIjANB.pa9xQIDAQAB-----END PUBLIC KEY-----` + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] account_sid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request + # @return [PublicKeyInstance] Created PublicKeyInstance + def create_with_metadata( + public_key: nil, + friendly_name: :unset, + account_sid: :unset + ) + + data = Twilio::Values.of({ + 'PublicKey' => public_key, + 'FriendlyName' => friendly_name, + 'AccountSid' => account_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + publicKey_instance = PublicKeyInstance.new( + @version, + response.body, + ) + PublicKeyInstanceMetadata.new( + @version, + publicKey_instance, + response.headers, + response.status_code + ) + end + ## # Lists PublicKeyInstance records from the API as a list. @@ -102,6 +139,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PublicKeyPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PublicKeyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PublicKeyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +243,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PublicKeyInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + publicKey_instance = PublicKeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PublicKeyInstanceMetadata.new(@version, publicKey_instance, response.headers, response.status_code) end ## @@ -206,6 +284,31 @@ def fetch ) end + ## + # Fetch the PublicKeyInstanceMetadata + # @return [PublicKeyInstance] Fetched PublicKeyInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + publicKey_instance = PublicKeyInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PublicKeyInstanceMetadata.new( + @version, + publicKey_instance, + response.headers, + response.status_code + ) + end + ## # Update the PublicKeyInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -232,6 +335,38 @@ def update( ) end + ## + # Update the PublicKeyInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [PublicKeyInstance] Updated PublicKeyInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + publicKey_instance = PublicKeyInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PublicKeyInstanceMetadata.new( + @version, + publicKey_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -248,6 +383,45 @@ def inspect end end + class PublicKeyInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PublicKeyInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PublicKeyInstance] public_key_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PublicKeyInstanceMetadata] The initialized instance with metadata. + def initialize(version, public_key_instance, headers, status_code) + super(version, headers, status_code) + @public_key_instance = public_key_instance + end + + def public_key + @public_key_instance + end + + def to_s + "" + end + end + + class PublicKeyListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @public_key_instance = payload.body[key].map do |data| + PublicKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def public_key_instance + @instance + end + end + class PublicKeyPage < Page ## # Initialize the PublicKeyPage @@ -276,6 +450,54 @@ def to_s '' end end + + class PublicKeyPageMetadata < PageMetadata + attr_reader :public_key_page + + def initialize(version, response, solution, limit) + super(version, response) + @public_key_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @public_key_page << PublicKeyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @public_key_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PublicKeyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @public_key = payload.body[key].map do |data| + PublicKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def public_key + @public_key + end + end + class PublicKeyInstance < InstanceResource ## # Initialize the PublicKeyInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb b/lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb index b932f23cf..fdc72b416 100644 --- a/lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb +++ b/lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb @@ -54,6 +54,36 @@ def fetch( ) end + ## + # Fetch the MessagingGeopermissionsInstanceMetadata + # @param [String] country_code The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned. + # @return [MessagingGeopermissionsInstance] Fetched MessagingGeopermissionsInstance + def fetch_with_metadata( + country_code: :unset + ) + + params = Twilio::Values.of({ + 'CountryCode' => country_code, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + messagingGeopermissions_instance = MessagingGeopermissionsInstance.new( + @version, + response.body, + ) + MessagingGeopermissionsInstanceMetadata.new( + @version, + messagingGeopermissions_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessagingGeopermissionsInstance # @param [Array[Hash]] permissions A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission. @@ -79,6 +109,37 @@ def update( ) end + ## + # Update the MessagingGeopermissionsInstanceMetadata + # @param [Array[Hash]] permissions A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission. + # @return [MessagingGeopermissionsInstance] Updated MessagingGeopermissionsInstance + def update_with_metadata( + permissions: nil + ) + + data = Twilio::Values.of({ + 'Permissions' => Twilio.serialize_list(permissions) { |e| Twilio.serialize_object(e) }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('PATCH', @uri, data: data, headers: headers) + messagingGeopermissions_instance = MessagingGeopermissionsInstance.new( + @version, + response.body, + ) + MessagingGeopermissionsInstanceMetadata.new( + @version, + messagingGeopermissions_instance, + response.headers, + response.status_code + ) + end + @@ -116,6 +177,54 @@ def to_s '' end end + + class MessagingGeopermissionsPageMetadata < PageMetadata + attr_reader :messaging_geopermissions_page + + def initialize(version, response, solution, limit) + super(version, response) + @messaging_geopermissions_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @messaging_geopermissions_page << MessagingGeopermissionsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @messaging_geopermissions_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessagingGeopermissionsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @messaging_geopermissions = payload.body[key].map do |data| + MessagingGeopermissionsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def messaging_geopermissions + @messaging_geopermissions + end + end + class MessagingGeopermissionsInstance < InstanceResource ## # Initialize the MessagingGeopermissionsInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/safelist.rb b/lib/twilio-ruby/rest/accounts/v1/safelist.rb index 64fcfdf43..49c811296 100644 --- a/lib/twilio-ruby/rest/accounts/v1/safelist.rb +++ b/lib/twilio-ruby/rest/accounts/v1/safelist.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the SafelistInstanceMetadata + # @param [String] phone_number The phone number or phone number 1k prefix to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + # @return [SafelistInstance] Created SafelistInstance + def create_with_metadata( + phone_number: nil + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + safelist_instance = SafelistInstance.new( + @version, + response.body, + ) + SafelistInstanceMetadata.new( + @version, + safelist_instance, + response.headers, + response.status_code + ) + end + ## # Delete the SafelistInstance # @param [String] phone_number The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). @@ -70,7 +101,32 @@ def delete( - @version.delete('DELETE', @uri, params: params, headers: headers) + @version.delete('DELETE', @uri, params: params, headers: headers) + end + + ## + # Delete the SafelistInstanceMetadata + # @param [String] phone_number The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + phone_number: :unset + ) + + params = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, params: params, headers: headers) + safelist_instance = SafelistInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SafelistInstanceMetadata.new(@version, safelist_instance, response.headers, response.status_code) end ## @@ -97,6 +153,36 @@ def fetch( ) end + ## + # Fetch the SafelistInstanceMetadata + # @param [String] phone_number The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + # @return [SafelistInstance] Fetched SafelistInstance + def fetch_with_metadata( + phone_number: :unset + ) + + params = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + safelist_instance = SafelistInstance.new( + @version, + response.body, + ) + SafelistInstanceMetadata.new( + @version, + safelist_instance, + response.headers, + response.status_code + ) + end + @@ -134,6 +220,54 @@ def to_s '' end end + + class SafelistPageMetadata < PageMetadata + attr_reader :safelist_page + + def initialize(version, response, solution, limit) + super(version, response) + @safelist_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @safelist_page << SafelistListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @safelist_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SafelistListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @safelist = payload.body[key].map do |data| + SafelistInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def safelist + @safelist + end + end + class SafelistInstance < InstanceResource ## # Initialize the SafelistInstance diff --git a/lib/twilio-ruby/rest/accounts/v1/secondary_auth_token.rb b/lib/twilio-ruby/rest/accounts/v1/secondary_auth_token.rb index 6806e1528..ab3fcb7b4 100644 --- a/lib/twilio-ruby/rest/accounts/v1/secondary_auth_token.rb +++ b/lib/twilio-ruby/rest/accounts/v1/secondary_auth_token.rb @@ -72,6 +72,30 @@ def create ) end + ## + # Create the SecondaryAuthTokenInstanceMetadata + # @return [SecondaryAuthTokenInstance] Created SecondaryAuthTokenInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + secondaryAuthToken_instance = SecondaryAuthTokenInstance.new( + @version, + response.body, + ) + SecondaryAuthTokenInstanceMetadata.new( + @version, + secondaryAuthToken_instance, + response.headers, + response.status_code + ) + end + ## # Delete the SecondaryAuthTokenInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -81,7 +105,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SecondaryAuthTokenInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + secondaryAuthToken_instance = SecondaryAuthTokenInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SecondaryAuthTokenInstanceMetadata.new(@version, secondaryAuthToken_instance, response.headers, response.status_code) end @@ -100,6 +143,45 @@ def inspect end end + class SecondaryAuthTokenInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SecondaryAuthTokenInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SecondaryAuthTokenInstance] secondary_auth_token_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SecondaryAuthTokenInstanceMetadata] The initialized instance with metadata. + def initialize(version, secondary_auth_token_instance, headers, status_code) + super(version, headers, status_code) + @secondary_auth_token_instance = secondary_auth_token_instance + end + + def secondary_auth_token + @secondary_auth_token_instance + end + + def to_s + "" + end + end + + class SecondaryAuthTokenListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @secondary_auth_token_instance = payload.body[key].map do |data| + SecondaryAuthTokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def secondary_auth_token_instance + @instance + end + end + class SecondaryAuthTokenPage < Page ## # Initialize the SecondaryAuthTokenPage @@ -128,6 +210,54 @@ def to_s '' end end + + class SecondaryAuthTokenPageMetadata < PageMetadata + attr_reader :secondary_auth_token_page + + def initialize(version, response, solution, limit) + super(version, response) + @secondary_auth_token_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @secondary_auth_token_page << SecondaryAuthTokenListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @secondary_auth_token_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SecondaryAuthTokenListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @secondary_auth_token = payload.body[key].map do |data| + SecondaryAuthTokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def secondary_auth_token + @secondary_auth_token + end + end + class SecondaryAuthTokenInstance < InstanceResource ## # Initialize the SecondaryAuthTokenInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account.rb b/lib/twilio-ruby/rest/api/v2010/account.rb index 1be3e297f..ebd9c06fc 100644 --- a/lib/twilio-ruby/rest/api/v2010/account.rb +++ b/lib/twilio-ruby/rest/api/v2010/account.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the AccountInstanceMetadata + # @param [String] friendly_name A human readable description of the account to create, defaults to `SubAccount Created at {YYYY-MM-DD HH:MM meridian}` + # @return [AccountInstance] Created AccountInstance + def create_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + account_instance = AccountInstance.new( + @version, + response.body, + ) + AccountInstanceMetadata.new( + @version, + account_instance, + response.headers, + response.status_code + ) + end + ## # Lists AccountInstance records from the API as a list. @@ -102,6 +133,32 @@ def stream(friendly_name: :unset, status: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AccountPageMetadata records from the API as a list. + # @param [String] friendly_name Only return the Account resources with friendly names that exactly match this name. + # @param [Status] status Only return Account resources with the given status. Can be `closed`, `suspended` or `active`. + # @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_with_metadata(friendly_name: :unset, status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Status' => status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AccountPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AccountInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -222,6 +279,31 @@ def fetch ) end + ## + # Fetch the AccountInstanceMetadata + # @return [AccountInstance] Fetched AccountInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + account_instance = AccountInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AccountInstanceMetadata.new( + @version, + account_instance, + response.headers, + response.status_code + ) + end + ## # Update the AccountInstance # @param [String] friendly_name Update the human-readable description of this Account @@ -251,6 +333,41 @@ def update( ) end + ## + # Update the AccountInstanceMetadata + # @param [String] friendly_name Update the human-readable description of this Account + # @param [Status] status + # @return [AccountInstance] Updated AccountInstance + def update_with_metadata( + friendly_name: :unset, + status: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + account_instance = AccountInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AccountInstanceMetadata.new( + @version, + account_instance, + response.headers, + response.status_code + ) + end + ## # Access the usage # @return [UsageList] @@ -667,6 +784,45 @@ def inspect end end + class AccountInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AccountInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AccountInstance] account_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AccountInstanceMetadata] The initialized instance with metadata. + def initialize(version, account_instance, headers, status_code) + super(version, headers, status_code) + @account_instance = account_instance + end + + def account + @account_instance + end + + def to_s + "" + end + end + + class AccountListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @account_instance = payload.body[key].map do |data| + AccountInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def account_instance + @instance + end + end + class AccountPage < Page ## # Initialize the AccountPage @@ -695,6 +851,54 @@ def to_s '' end end + + class AccountPageMetadata < PageMetadata + attr_reader :account_page + + def initialize(version, response, solution, limit) + super(version, response) + @account_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @account_page << AccountListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @account_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AccountListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @account = payload.body[key].map do |data| + AccountInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def account + @account + end + end + class AccountInstance < InstanceResource ## # Initialize the AccountInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/address.rb b/lib/twilio-ruby/rest/api/v2010/account/address.rb index 02a18fb4a..e61677210 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/address.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/address.rb @@ -85,6 +85,65 @@ def create( ) end + ## + # Create the AddressInstanceMetadata + # @param [String] customer_name The name to associate with the new address. + # @param [String] street The number and street address of the new address. + # @param [String] city The city of the new address. + # @param [String] region The state or region of the new address. + # @param [String] postal_code The postal code of the new address. + # @param [String] iso_country The ISO country code of the new address. + # @param [String] friendly_name A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses. + # @param [Boolean] emergency_enabled Whether to enable emergency calling on the new address. Can be: `true` or `false`. + # @param [Boolean] auto_correct_address Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide. + # @param [String] street_secondary The additional number and street address of the address. + # @return [AddressInstance] Created AddressInstance + def create_with_metadata( + customer_name: nil, + street: nil, + city: nil, + region: nil, + postal_code: nil, + iso_country: nil, + friendly_name: :unset, + emergency_enabled: :unset, + auto_correct_address: :unset, + street_secondary: :unset + ) + + data = Twilio::Values.of({ + 'CustomerName' => customer_name, + 'Street' => street, + 'City' => city, + 'Region' => region, + 'PostalCode' => postal_code, + 'IsoCountry' => iso_country, + 'FriendlyName' => friendly_name, + 'EmergencyEnabled' => emergency_enabled, + 'AutoCorrectAddress' => auto_correct_address, + 'StreetSecondary' => street_secondary, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + address_instance = AddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + AddressInstanceMetadata.new( + @version, + address_instance, + response.headers, + response.status_code + ) + end + ## # Lists AddressInstance records from the API as a list. @@ -140,6 +199,36 @@ def stream(customer_name: :unset, friendly_name: :unset, emergency_enabled: :uns @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AddressPageMetadata records from the API as a list. + # @param [String] customer_name The `customer_name` of the Address resources to read. + # @param [String] friendly_name The string that identifies the Address resources to read. + # @param [Boolean] emergency_enabled Whether the address can be associated to a number for emergency calling. + # @param [String] iso_country The ISO country code of the Address resources to read. + # @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_with_metadata(customer_name: :unset, friendly_name: :unset, emergency_enabled: :unset, iso_country: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'CustomerName' => customer_name, + 'FriendlyName' => friendly_name, + 'EmergencyEnabled' => emergency_enabled, + 'IsoCountry' => iso_country, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AddressPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AddressInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -232,7 +321,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AddressInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + address_instance = AddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AddressInstanceMetadata.new(@version, address_instance, response.headers, response.status_code) end ## @@ -255,6 +363,32 @@ def fetch ) end + ## + # Fetch the AddressInstanceMetadata + # @return [AddressInstance] Fetched AddressInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + address_instance = AddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AddressInstanceMetadata.new( + @version, + address_instance, + response.headers, + response.status_code + ) + end + ## # Update the AddressInstance # @param [String] friendly_name A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses. @@ -306,6 +440,63 @@ def update( ) end + ## + # Update the AddressInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses. + # @param [String] customer_name The name to associate with the address. + # @param [String] street The number and street address of the address. + # @param [String] city The city of the address. + # @param [String] region The state or region of the address. + # @param [String] postal_code The postal code of the address. + # @param [Boolean] emergency_enabled Whether to enable emergency calling on the address. Can be: `true` or `false`. + # @param [Boolean] auto_correct_address Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide. + # @param [String] street_secondary The additional number and street address of the address. + # @return [AddressInstance] Updated AddressInstance + def update_with_metadata( + friendly_name: :unset, + customer_name: :unset, + street: :unset, + city: :unset, + region: :unset, + postal_code: :unset, + emergency_enabled: :unset, + auto_correct_address: :unset, + street_secondary: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'CustomerName' => customer_name, + 'Street' => street, + 'City' => city, + 'Region' => region, + 'PostalCode' => postal_code, + 'EmergencyEnabled' => emergency_enabled, + 'AutoCorrectAddress' => auto_correct_address, + 'StreetSecondary' => street_secondary, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + address_instance = AddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AddressInstanceMetadata.new( + @version, + address_instance, + response.headers, + response.status_code + ) + end + ## # Access the dependent_phone_numbers # @return [DependentPhoneNumberList] @@ -333,6 +524,45 @@ def inspect end end + class AddressInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AddressInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AddressInstance] address_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AddressInstanceMetadata] The initialized instance with metadata. + def initialize(version, address_instance, headers, status_code) + super(version, headers, status_code) + @address_instance = address_instance + end + + def address + @address_instance + end + + def to_s + "" + end + end + + class AddressListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @address_instance = payload.body[key].map do |data| + AddressInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def address_instance + @instance + end + end + class AddressPage < Page ## # Initialize the AddressPage @@ -361,6 +591,54 @@ def to_s '' end end + + class AddressPageMetadata < PageMetadata + attr_reader :address_page + + def initialize(version, response, solution, limit) + super(version, response) + @address_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @address_page << AddressListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @address_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AddressListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @address = payload.body[key].map do |data| + AddressInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def address + @address + end + end + class AddressInstance < InstanceResource ## # Initialize the AddressInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb b/lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb index f9df31755..df0e1dcd3 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DependentPhoneNumberPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DependentPhoneNumberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DependentPhoneNumberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -157,6 +179,54 @@ def to_s '' end end + + class DependentPhoneNumberPageMetadata < PageMetadata + attr_reader :dependent_phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @dependent_phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @dependent_phone_number_page << DependentPhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @dependent_phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DependentPhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @dependent_phone_number = payload.body[key].map do |data| + DependentPhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def dependent_phone_number + @dependent_phone_number + end + end + class DependentPhoneNumberInstance < InstanceResource ## # Initialize the DependentPhoneNumberInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/application.rb b/lib/twilio-ruby/rest/api/v2010/account/application.rb index cdb754d16..44e1ab584 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/application.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/application.rb @@ -103,6 +103,83 @@ def create( ) end + ## + # Create the ApplicationInstanceMetadata + # @param [String] api_version The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is the account's default API version. + # @param [String] voice_url The URL we should call when the phone number assigned to this application receives a call. + # @param [String] voice_method The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`. + # @param [String] voice_fallback_method The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`. + # @param [Boolean] voice_caller_id_lookup Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`. + # @param [String] sms_url The URL we should call when the phone number receives an incoming SMS message. + # @param [String] sms_method The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. + # @param [String] sms_fallback_url The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`. + # @param [String] sms_fallback_method The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. + # @param [String] sms_status_callback The URL we should call using a POST method to send status information about SMS messages sent by the application. + # @param [String] message_status_callback The URL we should call using a POST method to send message status information to your application. + # @param [String] friendly_name A descriptive string that you create to describe the new application. It can be up to 64 characters long. + # @param [Boolean] public_application_connect_enabled Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`. + # @return [ApplicationInstance] Created ApplicationInstance + def create_with_metadata( + api_version: :unset, + voice_url: :unset, + voice_method: :unset, + voice_fallback_url: :unset, + voice_fallback_method: :unset, + status_callback: :unset, + status_callback_method: :unset, + voice_caller_id_lookup: :unset, + sms_url: :unset, + sms_method: :unset, + sms_fallback_url: :unset, + sms_fallback_method: :unset, + sms_status_callback: :unset, + message_status_callback: :unset, + friendly_name: :unset, + public_application_connect_enabled: :unset + ) + + data = Twilio::Values.of({ + 'ApiVersion' => api_version, + 'VoiceUrl' => voice_url, + 'VoiceMethod' => voice_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceFallbackMethod' => voice_fallback_method, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'VoiceCallerIdLookup' => voice_caller_id_lookup, + 'SmsUrl' => sms_url, + 'SmsMethod' => sms_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsStatusCallback' => sms_status_callback, + 'MessageStatusCallback' => message_status_callback, + 'FriendlyName' => friendly_name, + 'PublicApplicationConnectEnabled' => public_application_connect_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + application_instance = ApplicationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + ApplicationInstanceMetadata.new( + @version, + application_instance, + response.headers, + response.status_code + ) + end + ## # Lists ApplicationInstance records from the API as a list. @@ -146,6 +223,30 @@ def stream(friendly_name: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ApplicationPageMetadata records from the API as a list. + # @param [String] friendly_name The string that identifies the Application resources to read. + # @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_with_metadata(friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ApplicationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ApplicationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -231,7 +332,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ApplicationInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + application_instance = ApplicationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ApplicationInstanceMetadata.new(@version, application_instance, response.headers, response.status_code) end ## @@ -254,6 +374,32 @@ def fetch ) end + ## + # Fetch the ApplicationInstanceMetadata + # @return [ApplicationInstance] Fetched ApplicationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + application_instance = ApplicationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ApplicationInstanceMetadata.new( + @version, + application_instance, + response.headers, + response.status_code + ) + end + ## # Update the ApplicationInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -326,6 +472,84 @@ def update( ) end + ## + # Update the ApplicationInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] api_version The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version. + # @param [String] voice_url The URL we should call when the phone number assigned to this application receives a call. + # @param [String] voice_method The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`. + # @param [String] voice_fallback_method The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`. + # @param [Boolean] voice_caller_id_lookup Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`. + # @param [String] sms_url The URL we should call when the phone number receives an incoming SMS message. + # @param [String] sms_method The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. + # @param [String] sms_fallback_url The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`. + # @param [String] sms_fallback_method The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. + # @param [String] sms_status_callback Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility. + # @param [String] message_status_callback The URL we should call using a POST method to send message status information to your application. + # @param [Boolean] public_application_connect_enabled Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`. + # @return [ApplicationInstance] Updated ApplicationInstance + def update_with_metadata( + friendly_name: :unset, + api_version: :unset, + voice_url: :unset, + voice_method: :unset, + voice_fallback_url: :unset, + voice_fallback_method: :unset, + status_callback: :unset, + status_callback_method: :unset, + voice_caller_id_lookup: :unset, + sms_url: :unset, + sms_method: :unset, + sms_fallback_url: :unset, + sms_fallback_method: :unset, + sms_status_callback: :unset, + message_status_callback: :unset, + public_application_connect_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'ApiVersion' => api_version, + 'VoiceUrl' => voice_url, + 'VoiceMethod' => voice_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceFallbackMethod' => voice_fallback_method, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'VoiceCallerIdLookup' => voice_caller_id_lookup, + 'SmsUrl' => sms_url, + 'SmsMethod' => sms_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsStatusCallback' => sms_status_callback, + 'MessageStatusCallback' => message_status_callback, + 'PublicApplicationConnectEnabled' => public_application_connect_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + application_instance = ApplicationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ApplicationInstanceMetadata.new( + @version, + application_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -342,6 +566,45 @@ def inspect end end + class ApplicationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ApplicationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ApplicationInstance] application_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ApplicationInstanceMetadata] The initialized instance with metadata. + def initialize(version, application_instance, headers, status_code) + super(version, headers, status_code) + @application_instance = application_instance + end + + def application + @application_instance + end + + def to_s + "" + end + end + + class ApplicationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @application_instance = payload.body[key].map do |data| + ApplicationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def application_instance + @instance + end + end + class ApplicationPage < Page ## # Initialize the ApplicationPage @@ -370,6 +633,54 @@ def to_s '' end end + + class ApplicationPageMetadata < PageMetadata + attr_reader :application_page + + def initialize(version, response, solution, limit) + super(version, response) + @application_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @application_page << ApplicationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @application_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ApplicationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @application = payload.body[key].map do |data| + ApplicationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def application + @application + end + end + class ApplicationInstance < InstanceResource ## # Initialize the ApplicationInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb b/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb index 9e243dd7b..109fb52bc 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AuthorizedConnectAppPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AuthorizedConnectAppPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AuthorizedConnectAppInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the AuthorizedConnectAppInstanceMetadata + # @return [AuthorizedConnectAppInstance] Fetched AuthorizedConnectAppInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + authorizedConnectApp_instance = AuthorizedConnectAppInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + connect_app_sid: @solution[:connect_app_sid], + ) + AuthorizedConnectAppInstanceMetadata.new( + @version, + authorizedConnectApp_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class AuthorizedConnectAppInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AuthorizedConnectAppInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AuthorizedConnectAppInstance] authorized_connect_app_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AuthorizedConnectAppInstanceMetadata] The initialized instance with metadata. + def initialize(version, authorized_connect_app_instance, headers, status_code) + super(version, headers, status_code) + @authorized_connect_app_instance = authorized_connect_app_instance + end + + def authorized_connect_app + @authorized_connect_app_instance + end + + def to_s + "" + end + end + + class AuthorizedConnectAppListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorized_connect_app_instance = payload.body[key].map do |data| + AuthorizedConnectAppInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorized_connect_app_instance + @instance + end + end + class AuthorizedConnectAppPage < Page ## # Initialize the AuthorizedConnectAppPage @@ -209,6 +296,54 @@ def to_s '' end end + + class AuthorizedConnectAppPageMetadata < PageMetadata + attr_reader :authorized_connect_app_page + + def initialize(version, response, solution, limit) + super(version, response) + @authorized_connect_app_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @authorized_connect_app_page << AuthorizedConnectAppListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @authorized_connect_app_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthorizedConnectAppListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorized_connect_app = payload.body[key].map do |data| + AuthorizedConnectAppInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorized_connect_app + @authorized_connect_app + end + end + class AuthorizedConnectAppInstance < InstanceResource ## # Initialize the AuthorizedConnectAppInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country.rb index 16e95d19b..835ef025d 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AvailablePhoneNumberCountryPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AvailablePhoneNumberCountryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AvailablePhoneNumberCountryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -172,6 +194,32 @@ def fetch ) end + ## + # Fetch the AvailablePhoneNumberCountryInstanceMetadata + # @return [AvailablePhoneNumberCountryInstance] Fetched AvailablePhoneNumberCountryInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + availablePhoneNumberCountry_instance = AvailablePhoneNumberCountryInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + country_code: @solution[:country_code], + ) + AvailablePhoneNumberCountryInstanceMetadata.new( + @version, + availablePhoneNumberCountry_instance, + response.headers, + response.status_code + ) + end + ## # Access the voip # @return [VoipList] @@ -265,6 +313,45 @@ def inspect end end + class AvailablePhoneNumberCountryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AvailablePhoneNumberCountryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AvailablePhoneNumberCountryInstance] available_phone_number_country_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AvailablePhoneNumberCountryInstanceMetadata] The initialized instance with metadata. + def initialize(version, available_phone_number_country_instance, headers, status_code) + super(version, headers, status_code) + @available_phone_number_country_instance = available_phone_number_country_instance + end + + def available_phone_number_country + @available_phone_number_country_instance + end + + def to_s + "" + end + end + + class AvailablePhoneNumberCountryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_phone_number_country_instance = payload.body[key].map do |data| + AvailablePhoneNumberCountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_phone_number_country_instance + @instance + end + end + class AvailablePhoneNumberCountryPage < Page ## # Initialize the AvailablePhoneNumberCountryPage @@ -293,6 +380,54 @@ def to_s '' end end + + class AvailablePhoneNumberCountryPageMetadata < PageMetadata + attr_reader :available_phone_number_country_page + + def initialize(version, response, solution, limit) + super(version, response) + @available_phone_number_country_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @available_phone_number_country_page << AvailablePhoneNumberCountryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @available_phone_number_country_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AvailablePhoneNumberCountryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_phone_number_country = payload.body[key].map do |data| + AvailablePhoneNumberCountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_phone_number_country + @available_phone_number_country + end + end + class AvailablePhoneNumberCountryInstance < InstanceResource ## # Initialize the AvailablePhoneNumberCountryInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/local.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/local.rb index a46cd3df1..c0cd7571a 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/local.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/local.rb @@ -144,6 +144,64 @@ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists LocalPageMetadata records from the API as a list. + # @param [String] area_code The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada. + # @param [String] contains Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: `*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can't be adjacent to each other. + # @param [Boolean] sms_enabled Whether the phone numbers can receive text messages. Can be: `true` or `false`. + # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages. Can be: `true` or `false`. + # @param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can be: `true` or `false`. + # @param [Boolean] exclude_all_address_required Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_local_address_required Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_foreign_address_required Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] beta Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] near_number Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada. + # @param [String] near_lat_long Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada. + # @param [String] distance The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada. + # @param [String] in_postal_code Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_region Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_rate_center Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada. + # @param [String] in_lata Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_locality Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number. + # @param [Boolean] fax_enabled Whether the phone numbers can receive faxes. Can be: `true` or `false`. + # @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_with_metadata(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AreaCode' => area_code, + 'Contains' => contains, + 'SmsEnabled' => sms_enabled, + 'MmsEnabled' => mms_enabled, + 'VoiceEnabled' => voice_enabled, + 'ExcludeAllAddressRequired' => exclude_all_address_required, + 'ExcludeLocalAddressRequired' => exclude_local_address_required, + 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, + 'Beta' => beta, + 'NearNumber' => near_number, + 'NearLatLong' => near_lat_long, + 'Distance' => distance, + 'InPostalCode' => in_postal_code, + 'InRegion' => in_region, + 'InRateCenter' => in_rate_center, + 'InLata' => in_lata, + 'InLocality' => in_locality, + 'FaxEnabled' => fax_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + LocalPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields LocalInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -265,6 +323,54 @@ def to_s '' end end + + class LocalPageMetadata < PageMetadata + attr_reader :local_page + + def initialize(version, response, solution, limit) + super(version, response) + @local_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @local_page << LocalListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @local_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LocalListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @local = payload.body[key].map do |data| + LocalInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def local + @local + end + end + class LocalInstance < InstanceResource ## # Initialize the LocalInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/machine_to_machine.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/machine_to_machine.rb index 5ddb68a0f..099aa9c67 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/machine_to_machine.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/machine_to_machine.rb @@ -144,6 +144,64 @@ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MachineToMachinePageMetadata records from the API as a list. + # @param [String] area_code The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada. + # @param [String] contains Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: `*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can't be adjacent to each other. + # @param [Boolean] sms_enabled Whether the phone numbers can receive text messages. Can be: `true` or `false`. + # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages. Can be: `true` or `false`. + # @param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can be: `true` or `false`. + # @param [Boolean] exclude_all_address_required Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_local_address_required Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_foreign_address_required Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] beta Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] near_number Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada. + # @param [String] near_lat_long Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada. + # @param [String] distance The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada. + # @param [String] in_postal_code Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_region Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_rate_center Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada. + # @param [String] in_lata Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_locality Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number. + # @param [Boolean] fax_enabled Whether the phone numbers can receive faxes. Can be: `true` or `false`. + # @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_with_metadata(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AreaCode' => area_code, + 'Contains' => contains, + 'SmsEnabled' => sms_enabled, + 'MmsEnabled' => mms_enabled, + 'VoiceEnabled' => voice_enabled, + 'ExcludeAllAddressRequired' => exclude_all_address_required, + 'ExcludeLocalAddressRequired' => exclude_local_address_required, + 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, + 'Beta' => beta, + 'NearNumber' => near_number, + 'NearLatLong' => near_lat_long, + 'Distance' => distance, + 'InPostalCode' => in_postal_code, + 'InRegion' => in_region, + 'InRateCenter' => in_rate_center, + 'InLata' => in_lata, + 'InLocality' => in_locality, + 'FaxEnabled' => fax_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MachineToMachinePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MachineToMachineInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -265,6 +323,54 @@ def to_s '' end end + + class MachineToMachinePageMetadata < PageMetadata + attr_reader :machine_to_machine_page + + def initialize(version, response, solution, limit) + super(version, response) + @machine_to_machine_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @machine_to_machine_page << MachineToMachineListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @machine_to_machine_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MachineToMachineListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @machine_to_machine = payload.body[key].map do |data| + MachineToMachineInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def machine_to_machine + @machine_to_machine + end + end + class MachineToMachineInstance < InstanceResource ## # Initialize the MachineToMachineInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/mobile.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/mobile.rb index 1927bdfab..4be1ace62 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/mobile.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/mobile.rb @@ -144,6 +144,64 @@ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MobilePageMetadata records from the API as a list. + # @param [String] area_code The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada. + # @param [String] contains Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: `*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can't be adjacent to each other. + # @param [Boolean] sms_enabled Whether the phone numbers can receive text messages. Can be: `true` or `false`. + # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages. Can be: `true` or `false`. + # @param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can be: `true` or `false`. + # @param [Boolean] exclude_all_address_required Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_local_address_required Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_foreign_address_required Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] beta Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] near_number Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada. + # @param [String] near_lat_long Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada. + # @param [String] distance The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada. + # @param [String] in_postal_code Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_region Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_rate_center Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada. + # @param [String] in_lata Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_locality Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number. + # @param [Boolean] fax_enabled Whether the phone numbers can receive faxes. Can be: `true` or `false`. + # @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_with_metadata(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AreaCode' => area_code, + 'Contains' => contains, + 'SmsEnabled' => sms_enabled, + 'MmsEnabled' => mms_enabled, + 'VoiceEnabled' => voice_enabled, + 'ExcludeAllAddressRequired' => exclude_all_address_required, + 'ExcludeLocalAddressRequired' => exclude_local_address_required, + 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, + 'Beta' => beta, + 'NearNumber' => near_number, + 'NearLatLong' => near_lat_long, + 'Distance' => distance, + 'InPostalCode' => in_postal_code, + 'InRegion' => in_region, + 'InRateCenter' => in_rate_center, + 'InLata' => in_lata, + 'InLocality' => in_locality, + 'FaxEnabled' => fax_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MobilePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MobileInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -265,6 +323,54 @@ def to_s '' end end + + class MobilePageMetadata < PageMetadata + attr_reader :mobile_page + + def initialize(version, response, solution, limit) + super(version, response) + @mobile_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @mobile_page << MobileListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @mobile_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MobileListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @mobile = payload.body[key].map do |data| + MobileInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def mobile + @mobile + end + end + class MobileInstance < InstanceResource ## # Initialize the MobileInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb index e908a3c9f..7a7f96865 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb @@ -144,6 +144,64 @@ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists NationalPageMetadata records from the API as a list. + # @param [String] area_code The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada. + # @param [String] contains Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: `*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can't be adjacent to each other. + # @param [Boolean] sms_enabled Whether the phone numbers can receive text messages. Can be: `true` or `false`. + # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages. Can be: `true` or `false`. + # @param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can be: `true` or `false`. + # @param [Boolean] exclude_all_address_required Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_local_address_required Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_foreign_address_required Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] beta Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] near_number Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada. + # @param [String] near_lat_long Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada. + # @param [String] distance The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada. + # @param [String] in_postal_code Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_region Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_rate_center Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada. + # @param [String] in_lata Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_locality Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number. + # @param [Boolean] fax_enabled Whether the phone numbers can receive faxes. Can be: `true` or `false`. + # @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_with_metadata(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AreaCode' => area_code, + 'Contains' => contains, + 'SmsEnabled' => sms_enabled, + 'MmsEnabled' => mms_enabled, + 'VoiceEnabled' => voice_enabled, + 'ExcludeAllAddressRequired' => exclude_all_address_required, + 'ExcludeLocalAddressRequired' => exclude_local_address_required, + 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, + 'Beta' => beta, + 'NearNumber' => near_number, + 'NearLatLong' => near_lat_long, + 'Distance' => distance, + 'InPostalCode' => in_postal_code, + 'InRegion' => in_region, + 'InRateCenter' => in_rate_center, + 'InLata' => in_lata, + 'InLocality' => in_locality, + 'FaxEnabled' => fax_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + NationalPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields NationalInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -265,6 +323,54 @@ def to_s '' end end + + class NationalPageMetadata < PageMetadata + attr_reader :national_page + + def initialize(version, response, solution, limit) + super(version, response) + @national_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @national_page << NationalListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @national_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NationalListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @national = payload.body[key].map do |data| + NationalInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def national + @national + end + end + class NationalInstance < InstanceResource ## # Initialize the NationalInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/shared_cost.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/shared_cost.rb index 116b3eadb..90babf788 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/shared_cost.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/shared_cost.rb @@ -144,6 +144,64 @@ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SharedCostPageMetadata records from the API as a list. + # @param [String] area_code The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada. + # @param [String] contains Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: `*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can't be adjacent to each other. + # @param [Boolean] sms_enabled Whether the phone numbers can receive text messages. Can be: `true` or `false`. + # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages. Can be: `true` or `false`. + # @param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can be: `true` or `false`. + # @param [Boolean] exclude_all_address_required Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_local_address_required Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_foreign_address_required Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] beta Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] near_number Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada. + # @param [String] near_lat_long Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada. + # @param [String] distance The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada. + # @param [String] in_postal_code Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_region Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_rate_center Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada. + # @param [String] in_lata Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_locality Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number. + # @param [Boolean] fax_enabled Whether the phone numbers can receive faxes. Can be: `true` or `false`. + # @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_with_metadata(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AreaCode' => area_code, + 'Contains' => contains, + 'SmsEnabled' => sms_enabled, + 'MmsEnabled' => mms_enabled, + 'VoiceEnabled' => voice_enabled, + 'ExcludeAllAddressRequired' => exclude_all_address_required, + 'ExcludeLocalAddressRequired' => exclude_local_address_required, + 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, + 'Beta' => beta, + 'NearNumber' => near_number, + 'NearLatLong' => near_lat_long, + 'Distance' => distance, + 'InPostalCode' => in_postal_code, + 'InRegion' => in_region, + 'InRateCenter' => in_rate_center, + 'InLata' => in_lata, + 'InLocality' => in_locality, + 'FaxEnabled' => fax_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SharedCostPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SharedCostInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -265,6 +323,54 @@ def to_s '' end end + + class SharedCostPageMetadata < PageMetadata + attr_reader :shared_cost_page + + def initialize(version, response, solution, limit) + super(version, response) + @shared_cost_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @shared_cost_page << SharedCostListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @shared_cost_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SharedCostListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @shared_cost = payload.body[key].map do |data| + SharedCostInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def shared_cost + @shared_cost + end + end + class SharedCostInstance < InstanceResource ## # Initialize the SharedCostInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/toll_free.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/toll_free.rb index 719dd4720..79134ef79 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/toll_free.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/toll_free.rb @@ -144,6 +144,64 @@ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TollFreePageMetadata records from the API as a list. + # @param [String] area_code The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada. + # @param [String] contains Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: `*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can't be adjacent to each other. + # @param [Boolean] sms_enabled Whether the phone numbers can receive text messages. Can be: `true` or `false`. + # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages. Can be: `true` or `false`. + # @param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can be: `true` or `false`. + # @param [Boolean] exclude_all_address_required Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_local_address_required Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_foreign_address_required Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] beta Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] near_number Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada. + # @param [String] near_lat_long Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada. + # @param [String] distance The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada. + # @param [String] in_postal_code Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_region Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_rate_center Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada. + # @param [String] in_lata Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_locality Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number. + # @param [Boolean] fax_enabled Whether the phone numbers can receive faxes. Can be: `true` or `false`. + # @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_with_metadata(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AreaCode' => area_code, + 'Contains' => contains, + 'SmsEnabled' => sms_enabled, + 'MmsEnabled' => mms_enabled, + 'VoiceEnabled' => voice_enabled, + 'ExcludeAllAddressRequired' => exclude_all_address_required, + 'ExcludeLocalAddressRequired' => exclude_local_address_required, + 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, + 'Beta' => beta, + 'NearNumber' => near_number, + 'NearLatLong' => near_lat_long, + 'Distance' => distance, + 'InPostalCode' => in_postal_code, + 'InRegion' => in_region, + 'InRateCenter' => in_rate_center, + 'InLata' => in_lata, + 'InLocality' => in_locality, + 'FaxEnabled' => fax_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TollFreePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TollFreeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -265,6 +323,54 @@ def to_s '' end end + + class TollFreePageMetadata < PageMetadata + attr_reader :toll_free_page + + def initialize(version, response, solution, limit) + super(version, response) + @toll_free_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @toll_free_page << TollFreeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @toll_free_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TollFreeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @toll_free = payload.body[key].map do |data| + TollFreeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def toll_free + @toll_free + end + end + class TollFreeInstance < InstanceResource ## # Initialize the TollFreeInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/voip.rb b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/voip.rb index 82cc0be0c..a438aee6d 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/voip.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/voip.rb @@ -144,6 +144,64 @@ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists VoipPageMetadata records from the API as a list. + # @param [String] area_code The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada. + # @param [String] contains Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: `*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can't be adjacent to each other. + # @param [Boolean] sms_enabled Whether the phone numbers can receive text messages. Can be: `true` or `false`. + # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages. Can be: `true` or `false`. + # @param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can be: `true` or `false`. + # @param [Boolean] exclude_all_address_required Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_local_address_required Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] exclude_foreign_address_required Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`. + # @param [Boolean] beta Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] near_number Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada. + # @param [String] near_lat_long Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada. + # @param [String] distance The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada. + # @param [String] in_postal_code Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_region Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_rate_center Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada. + # @param [String] in_lata Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada. + # @param [String] in_locality Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number. + # @param [Boolean] fax_enabled Whether the phone numbers can receive faxes. Can be: `true` or `false`. + # @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_with_metadata(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AreaCode' => area_code, + 'Contains' => contains, + 'SmsEnabled' => sms_enabled, + 'MmsEnabled' => mms_enabled, + 'VoiceEnabled' => voice_enabled, + 'ExcludeAllAddressRequired' => exclude_all_address_required, + 'ExcludeLocalAddressRequired' => exclude_local_address_required, + 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, + 'Beta' => beta, + 'NearNumber' => near_number, + 'NearLatLong' => near_lat_long, + 'Distance' => distance, + 'InPostalCode' => in_postal_code, + 'InRegion' => in_region, + 'InRateCenter' => in_rate_center, + 'InLata' => in_lata, + 'InLocality' => in_locality, + 'FaxEnabled' => fax_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + VoipPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields VoipInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -265,6 +323,54 @@ def to_s '' end end + + class VoipPageMetadata < PageMetadata + attr_reader :voip_page + + def initialize(version, response, solution, limit) + super(version, response) + @voip_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @voip_page << VoipListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @voip_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VoipListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @voip = payload.body[key].map do |data| + VoipInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def voip + @voip + end + end + class VoipInstance < InstanceResource ## # Initialize the VoipInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/balance.rb b/lib/twilio-ruby/rest/api/v2010/account/balance.rb index 61c274e4c..5493e0089 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/balance.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/balance.rb @@ -51,6 +51,31 @@ def fetch ) end + ## + # Fetch the BalanceInstanceMetadata + # @return [BalanceInstance] Fetched BalanceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + balance_instance = BalanceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + BalanceInstanceMetadata.new( + @version, + balance_instance, + response.headers, + response.status_code + ) + end + @@ -88,6 +113,54 @@ def to_s '' end end + + class BalancePageMetadata < PageMetadata + attr_reader :balance_page + + def initialize(version, response, solution, limit) + super(version, response) + @balance_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @balance_page << BalanceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @balance_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BalanceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @balance = payload.body[key].map do |data| + BalanceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def balance + @balance + end + end + class BalanceInstance < InstanceResource ## # Initialize the BalanceInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call.rb b/lib/twilio-ruby/rest/api/v2010/account/call.rb index 2dbf60c3e..f825681fb 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call.rb @@ -160,6 +160,140 @@ def create( ) end + ## + # Create the CallInstanceMetadata + # @param [String] to The phone number, SIP address, or client identifier to call. + # @param [String] from The phone number or client identifier to use as the caller id. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `From` must also be a phone number. + # @param [String] method The HTTP method we should use when calling the `url` parameter's value. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [String] fallback_url The URL that we call using the `fallback_method` if an error occurs when requesting or executing the TwiML at `url`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [String] fallback_method The HTTP method that we should use to request the `fallback_url`. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. If no `status_callback_event` is specified, we will send the `completed` status. If an `application_sid` parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted). + # @param [Array[String]] status_callback_event The call progress events that we will send to the `status_callback` URL. Can be: `initiated`, `ringing`, `answered`, and `completed`. If no event is specified, we send the `completed` status. If you want to receive multiple events, specify each one in a separate `status_callback_event` parameter. See the code sample for [monitoring call progress](https://www.twilio.com/docs/voice/api/call-resource?code-sample=code-create-a-call-resource-and-specify-a-statuscallbackevent&code-sdk-version=json). If an `application_sid` is present, this parameter is ignored. + # @param [String] status_callback_method The HTTP method we should use when calling the `status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [String] send_digits The string of keys to dial after connecting to the number, with a maximum length of 32 digits. Valid digits in the string include any digit (`0`-`9`), '`A`', '`B`', '`C`', '`D`', '`#`', and '`*`'. You can also use '`w`' to insert a half-second pause and '`W`' to insert a one-second pause. For example, to pause for one second after connecting and then dial extension 1234 followed by the # key, set this parameter to `W1234#`. Be sure to URL-encode this string because the '`#`' character has special meaning in a URL. If both `SendDigits` and `MachineDetection` parameters are provided, then `MachineDetection` will be ignored. + # @param [String] timeout The integer number of seconds that we should allow the phone to ring before assuming there is no answer. The default is `60` seconds and the maximum is `600` seconds. For some call flows, we will add a 5-second buffer to the timeout value you provide. For this reason, a timeout value of 10 seconds could result in an actual timeout closer to 15 seconds. You can set this to a short time, such as `15` seconds, to hang up before reaching an answering machine or voicemail. + # @param [Boolean] record Whether to record the call. Can be `true` to record the phone call, or `false` to not. The default is `false`. The `recording_url` is sent to the `status_callback` URL. + # @param [String] recording_channels The number of channels in the final recording. Can be: `mono` or `dual`. The default is `mono`. `mono` records both legs of the call in a single channel of the recording file. `dual` records each leg to a separate channel of the recording file. The first channel of a dual-channel recording contains the parent call and the second channel contains the child call. + # @param [String] recording_status_callback The URL that we call when the recording is available to be accessed. + # @param [String] recording_status_callback_method The HTTP method we should use when calling the `recording_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + # @param [String] sip_auth_username The username used to authenticate the caller making a SIP call. + # @param [String] sip_auth_password The password required to authenticate the user account specified in `sip_auth_username`. + # @param [String] machine_detection Whether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. If `send_digits` is provided, this parameter is ignored. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection). + # @param [String] machine_detection_timeout The number of seconds that we should attempt to detect an answering machine before timing out and sending a voice request with `AnsweredBy` of `unknown`. The default timeout is 30 seconds. + # @param [Array[String]] recording_status_callback_event The recording status events that will trigger calls to the URL specified in `recording_status_callback`. Can be: `in-progress`, `completed` and `absent`. Defaults to `completed`. Separate multiple values with a space. + # @param [String] trim Whether to trim any leading and trailing silence from the recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. + # @param [String] caller_id The phone number, SIP address, or Client identifier that made this call. Phone numbers are in [E.164 format](https://wwnw.twilio.com/docs/glossary/what-e164) (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. + # @param [String] machine_detection_speech_threshold The number of milliseconds that is used as the measuring stick for the length of the speech activity, where durations lower than this value will be interpreted as a human and longer than this value as a machine. Possible Values: 1000-6000. Default: 2400. + # @param [String] machine_detection_speech_end_threshold The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200. + # @param [String] machine_detection_silence_timeout The number of milliseconds of initial silence after which an `unknown` AnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000. + # @param [String] async_amd Select whether to perform answering machine detection in the background. Default, blocks the execution of the call until Answering Machine Detection is completed. Can be: `true` or `false`. + # @param [String] async_amd_status_callback The URL that we should call using the `async_amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. + # @param [String] async_amd_status_callback_method The HTTP method we should use when calling the `async_amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + # @param [String] byoc The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta) + # @param [String] call_reason The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) + # @param [String] call_token A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. + # @param [String] recording_track The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio. + # @param [String] time_limit The maximum duration of the call in seconds. Constraints depend on account and configuration. + # @param [String] url The absolute URL that returns the TwiML instructions for the call. We will call this URL using the `method` when the call connects. For more information, see the [Url Parameter](https://www.twilio.com/docs/voice/make-calls#specify-a-url-parameter) section in [Making Calls](https://www.twilio.com/docs/voice/make-calls). + # @param [String] twiml TwiML instructions for the call Twilio will use without fetching Twiml from url parameter. If both `twiml` and `url` are provided then `twiml` parameter will be ignored. Max 4000 characters. + # @param [String] application_sid The SID of the Application resource that will handle the call, if the call will be handled by an application. + # @return [CallInstance] Created CallInstance + def create_with_metadata( + to: nil, + from: nil, + method: :unset, + fallback_url: :unset, + fallback_method: :unset, + status_callback: :unset, + status_callback_event: :unset, + status_callback_method: :unset, + send_digits: :unset, + timeout: :unset, + record: :unset, + recording_channels: :unset, + recording_status_callback: :unset, + recording_status_callback_method: :unset, + sip_auth_username: :unset, + sip_auth_password: :unset, + machine_detection: :unset, + machine_detection_timeout: :unset, + recording_status_callback_event: :unset, + trim: :unset, + caller_id: :unset, + machine_detection_speech_threshold: :unset, + machine_detection_speech_end_threshold: :unset, + machine_detection_silence_timeout: :unset, + async_amd: :unset, + async_amd_status_callback: :unset, + async_amd_status_callback_method: :unset, + byoc: :unset, + call_reason: :unset, + call_token: :unset, + recording_track: :unset, + time_limit: :unset, + url: :unset, + twiml: :unset, + application_sid: :unset + ) + + data = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'Method' => method, + 'FallbackUrl' => fallback_url, + 'FallbackMethod' => fallback_method, + 'StatusCallback' => status_callback, + 'StatusCallbackEvent' => Twilio.serialize_list(status_callback_event) { |e| e }, + 'StatusCallbackMethod' => status_callback_method, + 'SendDigits' => send_digits, + 'Timeout' => timeout, + 'Record' => record, + 'RecordingChannels' => recording_channels, + 'RecordingStatusCallback' => recording_status_callback, + 'RecordingStatusCallbackMethod' => recording_status_callback_method, + 'SipAuthUsername' => sip_auth_username, + 'SipAuthPassword' => sip_auth_password, + 'MachineDetection' => machine_detection, + 'MachineDetectionTimeout' => machine_detection_timeout, + 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e }, + 'Trim' => trim, + 'CallerId' => caller_id, + 'MachineDetectionSpeechThreshold' => machine_detection_speech_threshold, + 'MachineDetectionSpeechEndThreshold' => machine_detection_speech_end_threshold, + 'MachineDetectionSilenceTimeout' => machine_detection_silence_timeout, + 'AsyncAmd' => async_amd, + 'AsyncAmdStatusCallback' => async_amd_status_callback, + 'AsyncAmdStatusCallbackMethod' => async_amd_status_callback_method, + 'Byoc' => byoc, + 'CallReason' => call_reason, + 'CallToken' => call_token, + 'RecordingTrack' => recording_track, + 'TimeLimit' => time_limit, + 'Url' => url, + 'Twiml' => twiml, + 'ApplicationSid' => application_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + call_instance = CallInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + CallInstanceMetadata.new( + @version, + call_instance, + response.headers, + response.status_code + ) + end + ## # Lists CallInstance records from the API as a list. @@ -239,6 +373,48 @@ def stream(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, st @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CallPageMetadata records from the API as a list. + # @param [String] to Only show calls made to this phone number, SIP address, Client identifier or SIM SID. + # @param [String] from Only include calls from this phone number, SIP address, Client identifier or SIM SID. + # @param [String] parent_call_sid Only include calls spawned by calls with this SID. + # @param [Status] status The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`. + # @param [Time] start_time Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + # @param [Time] start_time_before Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + # @param [Time] start_time_after Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + # @param [Time] end_time Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + # @param [Time] end_time_before Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + # @param [Time] end_time_after Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + # @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_with_metadata(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time: :unset, start_time_before: :unset, start_time_after: :unset, end_time: :unset, end_time_before: :unset, end_time_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'ParentCallSid' => parent_call_sid, + 'Status' => status, + 'StartTime' => Twilio.serialize_iso8601_datetime(start_time), + 'StartTime<' => Twilio.serialize_iso8601_datetime(start_time_before), + 'StartTime>' => Twilio.serialize_iso8601_datetime(start_time_after), + 'EndTime' => Twilio.serialize_iso8601_datetime(end_time), + 'EndTime<' => Twilio.serialize_iso8601_datetime(end_time_before), + 'EndTime>' => Twilio.serialize_iso8601_datetime(end_time_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CallPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CallInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -351,7 +527,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CallInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + call_instance = CallInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CallInstanceMetadata.new(@version, call_instance, response.headers, response.status_code) end ## @@ -374,6 +569,32 @@ def fetch ) end + ## + # Fetch the CallInstanceMetadata + # @return [CallInstance] Fetched CallInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + call_instance = CallInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CallInstanceMetadata.new( + @version, + call_instance, + response.headers, + response.status_code + ) + end + ## # Update the CallInstance # @param [String] url The absolute URL that returns the TwiML instructions for the call. We will call this URL using the `method` when the call connects. For more information, see the [Url Parameter](https://www.twilio.com/docs/voice/make-calls#specify-a-url-parameter) section in [Making Calls](https://www.twilio.com/docs/voice/make-calls). @@ -425,6 +646,63 @@ def update( ) end + ## + # Update the CallInstanceMetadata + # @param [String] url The absolute URL that returns the TwiML instructions for the call. We will call this URL using the `method` when the call connects. For more information, see the [Url Parameter](https://www.twilio.com/docs/voice/make-calls#specify-a-url-parameter) section in [Making Calls](https://www.twilio.com/docs/voice/make-calls). + # @param [String] method The HTTP method we should use when calling the `url`. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [UpdateStatus] status + # @param [String] fallback_url The URL that we call using the `fallback_method` if an error occurs when requesting or executing the TwiML at `url`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [String] fallback_method The HTTP method that we should use to request the `fallback_url`. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. If no `status_callback_event` is specified, we will send the `completed` status. If an `application_sid` parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted). + # @param [String] status_callback_method The HTTP method we should use when requesting the `status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. + # @param [String] twiml TwiML instructions for the call Twilio will use without fetching Twiml from url. Twiml and url parameters are mutually exclusive + # @param [String] time_limit The maximum duration of the call in seconds. Constraints depend on account and configuration. + # @return [CallInstance] Updated CallInstance + def update_with_metadata( + url: :unset, + method: :unset, + status: :unset, + fallback_url: :unset, + fallback_method: :unset, + status_callback: :unset, + status_callback_method: :unset, + twiml: :unset, + time_limit: :unset + ) + + data = Twilio::Values.of({ + 'Url' => url, + 'Method' => method, + 'Status' => status, + 'FallbackUrl' => fallback_url, + 'FallbackMethod' => fallback_method, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'Twiml' => twiml, + 'TimeLimit' => time_limit, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + call_instance = CallInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CallInstanceMetadata.new( + @version, + call_instance, + response.headers, + response.status_code + ) + end + ## # Access the events # @return [EventList] @@ -596,6 +874,45 @@ def inspect end end + class CallInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CallInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CallInstance] call_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CallInstanceMetadata] The initialized instance with metadata. + def initialize(version, call_instance, headers, status_code) + super(version, headers, status_code) + @call_instance = call_instance + end + + def call + @call_instance + end + + def to_s + "" + end + end + + class CallListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @call_instance = payload.body[key].map do |data| + CallInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def call_instance + @instance + end + end + class CallPage < Page ## # Initialize the CallPage @@ -624,6 +941,54 @@ def to_s '' end end + + class CallPageMetadata < PageMetadata + attr_reader :call_page + + def initialize(version, response, solution, limit) + super(version, response) + @call_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @call_page << CallListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @call_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CallListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @call = payload.body[key].map do |data| + CallInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def call + @call + end + end + class CallInstance < InstanceResource ## # Initialize the CallInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/event.rb b/lib/twilio-ruby/rest/api/v2010/account/call/event.rb index b542390c4..5f3eeb010 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/event.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/event.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EventPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EventPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EventInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -157,6 +179,54 @@ def to_s '' end end + + class EventPageMetadata < PageMetadata + attr_reader :event_page + + def initialize(version, response, solution, limit) + super(version, response) + @event_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @event_page << EventListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @event_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EventListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event = payload.body[key].map do |data| + EventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event + @event + end + end + class EventInstance < InstanceResource ## # Initialize the EventInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/notification.rb b/lib/twilio-ruby/rest/api/v2010/account/call/notification.rb index 386248e4b..788b26b89 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/notification.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/notification.rb @@ -88,6 +88,36 @@ def stream(log: :unset, message_date: :unset, message_date_before: :unset, messa @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists NotificationPageMetadata records from the API as a list. + # @param [String] log Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read. + # @param [Date] message_date Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date. + # @param [Date] message_date_before Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date. + # @param [Date] message_date_after Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date. + # @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_with_metadata(log: :unset, message_date: :unset, message_date_before: :unset, message_date_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Log' => log, + 'MessageDate' => Twilio.serialize_iso8601_date(message_date), + 'MessageDate<' => Twilio.serialize_iso8601_date(message_date_before), + 'MessageDate>' => Twilio.serialize_iso8601_date(message_date_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + NotificationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields NotificationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -192,6 +222,33 @@ def fetch ) end + ## + # Fetch the NotificationInstanceMetadata + # @return [NotificationInstance] Fetched NotificationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + notification_instance = NotificationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + NotificationInstanceMetadata.new( + @version, + notification_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -208,6 +265,45 @@ def inspect end end + class NotificationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NotificationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NotificationInstance] notification_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NotificationInstanceMetadata] The initialized instance with metadata. + def initialize(version, notification_instance, headers, status_code) + super(version, headers, status_code) + @notification_instance = notification_instance + end + + def notification + @notification_instance + end + + def to_s + "" + end + end + + class NotificationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification_instance = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification_instance + @instance + end + end + class NotificationPage < Page ## # Initialize the NotificationPage @@ -236,6 +332,54 @@ def to_s '' end end + + class NotificationPageMetadata < PageMetadata + attr_reader :notification_page + + def initialize(version, response, solution, limit) + super(version, response) + @notification_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @notification_page << NotificationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @notification_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NotificationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification + @notification + end + end + class NotificationInstance < InstanceResource ## # Initialize the NotificationInstance 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 d3fcd0e94..a1abe618f 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb @@ -105,6 +105,84 @@ def create( ) end + ## + # Create the PaymentInstanceMetadata + # @param [String] idempotency_key A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated. + # @param [String] status_callback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback) + # @param [BankAccountType] bank_account_type + # @param [Float] charge_amount A positive decimal value less than 1,000,000 to charge against the credit card or bank account. Default currency can be overwritten with `currency` field. Leave blank or set to 0 to tokenize. + # @param [String] currency The currency of the `charge_amount`, formatted as [ISO 4127](http://www.iso.org/iso/home/standards/currency_codes.htm) format. The default value is `USD` and all values allowed from the Pay Connector are accepted. + # @param [String] description The description can be used to provide more details regarding the transaction. This information is submitted along with the payment details to the Payment Connector which are then posted on the transactions. + # @param [String] input A list of inputs that should be accepted. Currently only `dtmf` is supported. All digits captured during a pay session are redacted from the logs. + # @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 [Object] 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 Pay Connector installed in the Twilio Add-ons. Learn more about [ Connectors](https://www.twilio.com/console/voice/pay-connectors). The default value is `Default`. + # @param [PaymentMethod] payment_method + # @param [Boolean] postal_code Indicates whether the credit card postal code (zip code) is a required piece of payment information that must be provided by the caller. The default is `true`. + # @param [Boolean] security_code Indicates whether the credit card security code is a required piece of payment information that must be provided by the caller. The default is `true`. + # @param [String] timeout The number of seconds that should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. The default is `5`, maximum is `600`. + # @param [TokenType] token_type + # @param [String] valid_card_types Credit card types separated by space that Pay should accept. The default value is `visa mastercard amex` + # @return [PaymentInstance] Created PaymentInstance + def create_with_metadata( + idempotency_key: nil, + status_callback: nil, + bank_account_type: :unset, + charge_amount: :unset, + currency: :unset, + description: :unset, + input: :unset, + min_postal_code_length: :unset, + parameter: :unset, + payment_connector: :unset, + payment_method: :unset, + postal_code: :unset, + security_code: :unset, + timeout: :unset, + token_type: :unset, + valid_card_types: :unset + ) + + data = Twilio::Values.of({ + 'IdempotencyKey' => idempotency_key, + 'StatusCallback' => status_callback, + 'BankAccountType' => bank_account_type, + 'ChargeAmount' => charge_amount, + 'Currency' => currency, + 'Description' => description, + 'Input' => input, + 'MinPostalCodeLength' => min_postal_code_length, + 'Parameter' => Twilio.serialize_object(parameter), + 'PaymentConnector' => payment_connector, + 'PaymentMethod' => payment_method, + 'PostalCode' => postal_code, + 'SecurityCode' => security_code, + 'Timeout' => timeout, + 'TokenType' => token_type, + 'ValidCardTypes' => valid_card_types, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + payment_instance = PaymentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + PaymentInstanceMetadata.new( + @version, + payment_instance, + response.headers, + response.status_code + ) + end + @@ -169,6 +247,49 @@ def update( ) end + ## + # Update the PaymentInstanceMetadata + # @param [String] idempotency_key A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated. + # @param [String] status_callback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests. + # @param [Capture] capture + # @param [Status] status + # @return [PaymentInstance] Updated PaymentInstance + def update_with_metadata( + idempotency_key: nil, + status_callback: nil, + capture: :unset, + status: :unset + ) + + data = Twilio::Values.of({ + 'IdempotencyKey' => idempotency_key, + 'StatusCallback' => status_callback, + 'Capture' => capture, + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + payment_instance = PaymentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + PaymentInstanceMetadata.new( + @version, + payment_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -185,6 +306,45 @@ def inspect end end + class PaymentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PaymentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PaymentInstance] payment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PaymentInstanceMetadata] The initialized instance with metadata. + def initialize(version, payment_instance, headers, status_code) + super(version, headers, status_code) + @payment_instance = payment_instance + end + + def payment + @payment_instance + end + + def to_s + "" + end + end + + class PaymentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @payment_instance = payload.body[key].map do |data| + PaymentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def payment_instance + @instance + end + end + class PaymentPage < Page ## # Initialize the PaymentPage @@ -213,6 +373,54 @@ def to_s '' end end + + class PaymentPageMetadata < PageMetadata + attr_reader :payment_page + + def initialize(version, response, solution, limit) + super(version, response) + @payment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @payment_page << PaymentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @payment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PaymentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @payment = payload.body[key].map do |data| + PaymentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def payment + @payment + end + end + class PaymentInstance < InstanceResource ## # Initialize the PaymentInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb b/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb index 9eabd6a2f..ee373bbf6 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb @@ -75,6 +75,54 @@ def create( ) end + ## + # Create the RecordingInstanceMetadata + # @param [Array[String]] recording_status_callback_event The recording status events on which we should call the `recording_status_callback` URL. Can be: `in-progress`, `completed` and `absent` and the default is `completed`. Separate multiple event values with a space. + # @param [String] recording_status_callback The URL we should call using the `recording_status_callback_method` on each recording event specified in `recording_status_callback_event`. For more information, see [RecordingStatusCallback parameters](https://www.twilio.com/docs/voice/api/recording#recordingstatuscallback). + # @param [String] recording_status_callback_method The HTTP method we should use to call `recording_status_callback`. Can be: `GET` or `POST` and the default is `POST`. + # @param [String] trim Whether to trim any leading and trailing silence in the recording. Can be: `trim-silence` or `do-not-trim` and the default is `do-not-trim`. `trim-silence` trims the silence from the beginning and end of the recording and `do-not-trim` does not. + # @param [String] recording_channels The number of channels used in the recording. Can be: `mono` or `dual` and the default is `mono`. `mono` records all parties of the call into one channel. `dual` records each party of a 2-party call into separate channels. + # @param [String] recording_track The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio. + # @return [RecordingInstance] Created RecordingInstance + def create_with_metadata( + recording_status_callback_event: :unset, + recording_status_callback: :unset, + recording_status_callback_method: :unset, + trim: :unset, + recording_channels: :unset, + recording_track: :unset + ) + + data = Twilio::Values.of({ + 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e }, + 'RecordingStatusCallback' => recording_status_callback, + 'RecordingStatusCallbackMethod' => recording_status_callback_method, + 'Trim' => trim, + 'RecordingChannels' => recording_channels, + 'RecordingTrack' => recording_track, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Lists RecordingInstance records from the API as a list. @@ -126,6 +174,34 @@ def stream(date_created: :unset, date_created_before: :unset, date_created_after @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RecordingPageMetadata records from the API as a list. + # @param [Date] date_created The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date. + # @param [Date] date_created_before The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date. + # @param [Date] date_created_after The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date. + # @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_with_metadata(date_created: :unset, date_created_before: :unset, date_created_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'DateCreated' => Twilio.serialize_iso8601_date(date_created), + 'DateCreated<' => Twilio.serialize_iso8601_date(date_created_before), + 'DateCreated>' => Twilio.serialize_iso8601_date(date_created_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RecordingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RecordingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -216,7 +292,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RecordingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new(@version, recording_instance, response.headers, response.status_code) end ## @@ -240,6 +335,33 @@ def fetch ) end + ## + # Fetch the RecordingInstanceMetadata + # @return [RecordingInstance] Fetched RecordingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Update the RecordingInstance # @param [Status] status @@ -271,6 +393,43 @@ def update( ) end + ## + # Update the RecordingInstanceMetadata + # @param [Status] status + # @param [String] pause_behavior Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`. + # @return [RecordingInstance] Updated RecordingInstance + def update_with_metadata( + status: nil, + pause_behavior: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'PauseBehavior' => pause_behavior, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -287,6 +446,45 @@ def inspect end end + class RecordingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RecordingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RecordingInstance] recording_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RecordingInstanceMetadata] The initialized instance with metadata. + def initialize(version, recording_instance, headers, status_code) + super(version, headers, status_code) + @recording_instance = recording_instance + end + + def recording + @recording_instance + end + + def to_s + "" + end + end + + class RecordingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_instance = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_instance + @instance + end + end + class RecordingPage < Page ## # Initialize the RecordingPage @@ -315,6 +513,54 @@ def to_s '' end end + + class RecordingPageMetadata < PageMetadata + attr_reader :recording_page + + def initialize(version, response, solution, limit) + super(version, response) + @recording_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @recording_page << RecordingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @recording_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording + @recording + end + end + class RecordingInstance < InstanceResource ## # Initialize the RecordingInstance 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 7201cc2bc..8bd3b7bef 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb @@ -666,6 +666,645 @@ def create( ) end + ## + # Create the SiprecInstanceMetadata + # @param [String] name The user-specified name of this Siprec, if one was given when the Siprec was created. This may be used to stop the Siprec. + # @param [String] connector_name Unique name used when configuring the connector via Marketplace Add-on. + # @param [Track] track + # @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 [SiprecInstance] Created SiprecInstance + def create_with_metadata( + name: :unset, + connector_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({ + 'Name' => name, + 'ConnectorName' => connector_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, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + siprec_instance = SiprecInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + SiprecInstanceMetadata.new( + @version, + siprec_instance, + response.headers, + response.status_code + ) + end + @@ -721,6 +1360,40 @@ def update( ) end + ## + # Update the SiprecInstanceMetadata + # @param [UpdateStatus] status + # @return [SiprecInstance] Updated SiprecInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + siprec_instance = SiprecInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + SiprecInstanceMetadata.new( + @version, + siprec_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -737,6 +1410,45 @@ def inspect end end + class SiprecInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SiprecInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SiprecInstance] siprec_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SiprecInstanceMetadata] The initialized instance with metadata. + def initialize(version, siprec_instance, headers, status_code) + super(version, headers, status_code) + @siprec_instance = siprec_instance + end + + def siprec + @siprec_instance + end + + def to_s + "" + end + end + + class SiprecListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @siprec_instance = payload.body[key].map do |data| + SiprecInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def siprec_instance + @instance + end + end + class SiprecPage < Page ## # Initialize the SiprecPage @@ -765,6 +1477,54 @@ def to_s '' end end + + class SiprecPageMetadata < PageMetadata + attr_reader :siprec_page + + def initialize(version, response, solution, limit) + super(version, response) + @siprec_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @siprec_page << SiprecListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @siprec_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SiprecListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @siprec = payload.body[key].map do |data| + SiprecInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def siprec + @siprec + end + end + class SiprecInstance < InstanceResource ## # Initialize the SiprecInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb b/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb index 23232a6c7..b7a40c418 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb @@ -666,6 +666,645 @@ def create( ) end + ## + # Create the StreamInstanceMetadata + # @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 can be used to stop the Stream. + # @param [Track] track + # @param [String] status_callback Absolute URL to which Twilio sends status callback HTTP requests. + # @param [String] status_callback_method The HTTP method Twilio uses when sending `status_callback` requests. Possible values are `GET` and `POST`. Default is `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_with_metadata( + 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, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + stream_instance = StreamInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + StreamInstanceMetadata.new( + @version, + stream_instance, + response.headers, + response.status_code + ) + end + @@ -721,6 +1360,40 @@ def update( ) end + ## + # Update the StreamInstanceMetadata + # @param [UpdateStatus] status + # @return [StreamInstance] Updated StreamInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + stream_instance = StreamInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + StreamInstanceMetadata.new( + @version, + stream_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -737,6 +1410,45 @@ def inspect end end + class StreamInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new StreamInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}StreamInstance] stream_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [StreamInstanceMetadata] The initialized instance with metadata. + def initialize(version, stream_instance, headers, status_code) + super(version, headers, status_code) + @stream_instance = stream_instance + end + + def stream + @stream_instance + end + + def to_s + "" + end + end + + class StreamListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @stream_instance = payload.body[key].map do |data| + StreamInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def stream_instance + @instance + end + end + class StreamPage < Page ## # Initialize the StreamPage @@ -765,6 +1477,54 @@ def to_s '' end end + + class StreamPageMetadata < PageMetadata + attr_reader :stream_page + + def initialize(version, response, solution, limit) + super(version, response) + @stream_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @stream_page << StreamListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @stream_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class StreamListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @stream = payload.body[key].map do |data| + StreamInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def stream + @stream + end + end + class StreamInstance < InstanceResource ## # Initialize the StreamInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/transcription.rb b/lib/twilio-ruby/rest/api/v2010/account/call/transcription.rb index 50919a398..82b6bbc8a 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/transcription.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/transcription.rb @@ -99,6 +99,78 @@ def create( ) end + ## + # Create the TranscriptionInstanceMetadata + # @param [String] name The user-specified name of this Transcription, if one was given when the Transcription was created. This may be used to stop the Transcription. + # @param [Track] track + # @param [String] status_callback_url Absolute URL of the status callback. + # @param [String] status_callback_method The http method for the status_callback (one of GET, POST). + # @param [String] inbound_track_label Friendly name given to the Inbound Track + # @param [String] outbound_track_label Friendly name given to the Outbound Track + # @param [Boolean] partial_results Indicates if partial results are going to be sent to the customer + # @param [String] language_code Language code used by the transcription engine, specified in [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) format + # @param [String] transcription_engine Definition of the transcription engine to be used, among those supported by Twilio + # @param [Boolean] profanity_filter indicates if the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks + # @param [String] speech_model Recognition model used by the transcription engine, among those supported by the provider + # @param [String] hints A Phrase contains words and phrase \\\"hints\\\" so that the speech recognition engine is more likely to recognize them. + # @param [Boolean] enable_automatic_punctuation The provider will add punctuation to recognition result + # @param [String] intelligence_service The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators . + # @return [TranscriptionInstance] Created TranscriptionInstance + def create_with_metadata( + name: :unset, + track: :unset, + status_callback_url: :unset, + status_callback_method: :unset, + inbound_track_label: :unset, + outbound_track_label: :unset, + partial_results: :unset, + language_code: :unset, + transcription_engine: :unset, + profanity_filter: :unset, + speech_model: :unset, + hints: :unset, + enable_automatic_punctuation: :unset, + intelligence_service: :unset + ) + + data = Twilio::Values.of({ + 'Name' => name, + 'Track' => track, + 'StatusCallbackUrl' => status_callback_url, + 'StatusCallbackMethod' => status_callback_method, + 'InboundTrackLabel' => inbound_track_label, + 'OutboundTrackLabel' => outbound_track_label, + 'PartialResults' => partial_results, + 'LanguageCode' => language_code, + 'TranscriptionEngine' => transcription_engine, + 'ProfanityFilter' => profanity_filter, + 'SpeechModel' => speech_model, + 'Hints' => hints, + 'EnableAutomaticPunctuation' => enable_automatic_punctuation, + 'IntelligenceService' => intelligence_service, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + transcription_instance = TranscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + TranscriptionInstanceMetadata.new( + @version, + transcription_instance, + response.headers, + response.status_code + ) + end + @@ -154,6 +226,40 @@ def update( ) end + ## + # Update the TranscriptionInstanceMetadata + # @param [UpdateStatus] status + # @return [TranscriptionInstance] Updated TranscriptionInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + transcription_instance = TranscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + sid: @solution[:sid], + ) + TranscriptionInstanceMetadata.new( + @version, + transcription_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -170,6 +276,45 @@ def inspect end end + class TranscriptionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TranscriptionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TranscriptionInstance] transcription_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TranscriptionInstanceMetadata] The initialized instance with metadata. + def initialize(version, transcription_instance, headers, status_code) + super(version, headers, status_code) + @transcription_instance = transcription_instance + end + + def transcription + @transcription_instance + end + + def to_s + "" + end + end + + class TranscriptionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcription_instance = payload.body[key].map do |data| + TranscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcription_instance + @instance + end + end + class TranscriptionPage < Page ## # Initialize the TranscriptionPage @@ -198,6 +343,54 @@ def to_s '' end end + + class TranscriptionPageMetadata < PageMetadata + attr_reader :transcription_page + + def initialize(version, response, solution, limit) + super(version, response) + @transcription_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @transcription_page << TranscriptionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @transcription_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TranscriptionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcription = payload.body[key].map do |data| + TranscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcription + @transcription + end + end + class TranscriptionInstance < InstanceResource ## # Initialize the TranscriptionInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message.rb b/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message.rb index 45a806f96..1d2fd1474 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the UserDefinedMessageInstanceMetadata + # @param [String] content The User Defined Message in the form of URL-encoded JSON string. + # @param [String] idempotency_key A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated. + # @return [UserDefinedMessageInstance] Created UserDefinedMessageInstance + def create_with_metadata( + content: nil, + idempotency_key: :unset + ) + + data = Twilio::Values.of({ + 'Content' => content, + 'IdempotencyKey' => idempotency_key, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + userDefinedMessage_instance = UserDefinedMessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + UserDefinedMessageInstanceMetadata.new( + @version, + userDefinedMessage_instance, + response.headers, + response.status_code + ) + end + @@ -100,6 +136,54 @@ def to_s '' end end + + class UserDefinedMessagePageMetadata < PageMetadata + attr_reader :user_defined_message_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_defined_message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_defined_message_page << UserDefinedMessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_defined_message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserDefinedMessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_defined_message = payload.body[key].map do |data| + UserDefinedMessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_defined_message + @user_defined_message + end + end + class UserDefinedMessageInstance < InstanceResource ## # Initialize the UserDefinedMessageInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message_subscription.rb b/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message_subscription.rb index 043005a5f..8eb589c80 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message_subscription.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message_subscription.rb @@ -66,6 +66,45 @@ def create( ) end + ## + # Create the UserDefinedMessageSubscriptionInstanceMetadata + # @param [String] callback The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted). + # @param [String] idempotency_key A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated. + # @param [String] method The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. Default is `POST`. + # @return [UserDefinedMessageSubscriptionInstance] Created UserDefinedMessageSubscriptionInstance + def create_with_metadata( + callback: nil, + idempotency_key: :unset, + method: :unset + ) + + data = Twilio::Values.of({ + 'Callback' => callback, + 'IdempotencyKey' => idempotency_key, + 'Method' => method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + userDefinedMessageSubscription_instance = UserDefinedMessageSubscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + call_sid: @solution[:call_sid], + ) + UserDefinedMessageSubscriptionInstanceMetadata.new( + @version, + userDefinedMessageSubscription_instance, + response.headers, + response.status_code + ) + end + @@ -102,7 +141,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserDefinedMessageSubscriptionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + userDefinedMessageSubscription_instance = UserDefinedMessageSubscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserDefinedMessageSubscriptionInstanceMetadata.new(@version, userDefinedMessageSubscription_instance, response.headers, response.status_code) end @@ -121,6 +179,45 @@ def inspect end end + class UserDefinedMessageSubscriptionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserDefinedMessageSubscriptionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserDefinedMessageSubscriptionInstance] user_defined_message_subscription_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserDefinedMessageSubscriptionInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_defined_message_subscription_instance, headers, status_code) + super(version, headers, status_code) + @user_defined_message_subscription_instance = user_defined_message_subscription_instance + end + + def user_defined_message_subscription + @user_defined_message_subscription_instance + end + + def to_s + "" + end + end + + class UserDefinedMessageSubscriptionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_defined_message_subscription_instance = payload.body[key].map do |data| + UserDefinedMessageSubscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_defined_message_subscription_instance + @instance + end + end + class UserDefinedMessageSubscriptionPage < Page ## # Initialize the UserDefinedMessageSubscriptionPage @@ -149,6 +246,54 @@ def to_s '' end end + + class UserDefinedMessageSubscriptionPageMetadata < PageMetadata + attr_reader :user_defined_message_subscription_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_defined_message_subscription_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_defined_message_subscription_page << UserDefinedMessageSubscriptionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_defined_message_subscription_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserDefinedMessageSubscriptionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_defined_message_subscription = payload.body[key].map do |data| + UserDefinedMessageSubscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_defined_message_subscription + @user_defined_message_subscription + end + end + class UserDefinedMessageSubscriptionInstance < InstanceResource ## # Initialize the UserDefinedMessageSubscriptionInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/conference.rb b/lib/twilio-ruby/rest/api/v2010/account/conference.rb index a30f2fe75..b8fd4aea4 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/conference.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/conference.rb @@ -103,6 +103,44 @@ def stream(date_created: :unset, date_created_before: :unset, date_created_after @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConferencePageMetadata records from the API as a list. + # @param [Date] date_created Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + # @param [Date] date_created_before Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + # @param [Date] date_created_after Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + # @param [Date] date_updated Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + # @param [Date] date_updated_before Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + # @param [Date] date_updated_after Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + # @param [String] friendly_name The string that identifies the Conference resources to read. + # @param [Status] status The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + # @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_with_metadata(date_created: :unset, date_created_before: :unset, date_created_after: :unset, date_updated: :unset, date_updated_before: :unset, date_updated_after: :unset, friendly_name: :unset, status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'DateCreated' => Twilio.serialize_iso8601_date(date_created), + 'DateCreated<' => Twilio.serialize_iso8601_date(date_created_before), + 'DateCreated>' => Twilio.serialize_iso8601_date(date_created_after), + 'DateUpdated' => Twilio.serialize_iso8601_date(date_updated), + 'DateUpdated<' => Twilio.serialize_iso8601_date(date_updated_before), + 'DateUpdated>' => Twilio.serialize_iso8601_date(date_updated_after), + 'FriendlyName' => friendly_name, + 'Status' => status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConferencePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConferenceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -215,6 +253,32 @@ def fetch ) end + ## + # Fetch the ConferenceInstanceMetadata + # @return [ConferenceInstance] Fetched ConferenceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + conference_instance = ConferenceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConferenceInstanceMetadata.new( + @version, + conference_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConferenceInstance # @param [UpdateStatus] status @@ -248,6 +312,45 @@ def update( ) end + ## + # Update the ConferenceInstanceMetadata + # @param [UpdateStatus] status + # @param [String] announce_url The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. + # @param [String] announce_method The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST` + # @return [ConferenceInstance] Updated ConferenceInstance + def update_with_metadata( + status: :unset, + announce_url: :unset, + announce_method: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'AnnounceUrl' => announce_url, + 'AnnounceMethod' => announce_method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + conference_instance = ConferenceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConferenceInstanceMetadata.new( + @version, + conference_instance, + response.headers, + response.status_code + ) + end + ## # Access the recordings # @return [RecordingList] @@ -302,6 +405,45 @@ def inspect end end + class ConferenceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConferenceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConferenceInstance] conference_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConferenceInstanceMetadata] The initialized instance with metadata. + def initialize(version, conference_instance, headers, status_code) + super(version, headers, status_code) + @conference_instance = conference_instance + end + + def conference + @conference_instance + end + + def to_s + "" + end + end + + class ConferenceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conference_instance = payload.body[key].map do |data| + ConferenceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conference_instance + @instance + end + end + class ConferencePage < Page ## # Initialize the ConferencePage @@ -330,6 +472,54 @@ def to_s '' end end + + class ConferencePageMetadata < PageMetadata + attr_reader :conference_page + + def initialize(version, response, solution, limit) + super(version, response) + @conference_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @conference_page << ConferenceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @conference_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConferenceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conference = payload.body[key].map do |data| + ConferenceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conference + @conference + end + end + class ConferenceInstance < InstanceResource ## # Initialize the ConferenceInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb b/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb index 10fad0b15..4971b1be5 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb @@ -204,6 +204,183 @@ def create( ) end + ## + # Create the ParticipantInstanceMetadata + # @param [String] from The phone number, Client identifier, or username portion of SIP address that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). Client identifiers are formatted `client:name`. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `from` must also be a phone number. If `to` is sip address, this value of `from` should be a username portion to be used to populate the P-Asserted-Identity header that is passed to the SIP endpoint. + # @param [String] to The phone number, SIP address, Client, TwiML App identifier that received this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `sip:name@company.com`. Client identifiers are formatted `client:name`. TwiML App identifiers are formatted `app:`. [Custom parameters](https://www.twilio.com/docs/voice/api/conference-participant-resource#custom-parameters) may also be specified. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` and `POST` and defaults to `POST`. + # @param [Array[String]] status_callback_event The conference state changes that should generate a call to `status_callback`. Can be: `initiated`, `ringing`, `answered`, and `completed`. Separate multiple values with a space. The default value is `completed`. + # @param [String] label A label for this participant. If one is supplied, it may subsequently be used to fetch, update or delete the participant. + # @param [String] timeout The number of seconds that we should allow the phone to ring before assuming there is no answer. Can be an integer between `5` and `600`, inclusive. The default value is `60`. We always add a 5-second timeout buffer to outgoing calls, so value of 10 would result in an actual timeout that was closer to 15 seconds. + # @param [Boolean] record Whether to record the participant and their conferences, including the time between conferences. Can be `true` or `false` and the default is `false`. + # @param [Boolean] muted Whether the agent is muted in the conference. Can be `true` or `false` and the default is `false`. + # @param [String] beep Whether to play a notification beep to the conference when the participant joins. Can be: `true`, `false`, `onEnter`, or `onExit`. The default value is `true`. + # @param [Boolean] start_conference_on_enter Whether to start the conference when the participant joins, if it has not already started. Can be: `true` or `false` and the default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference. + # @param [Boolean] end_conference_on_exit Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. + # @param [String] wait_url The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). + # @param [String] wait_method The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. + # @param [Boolean] early_media Whether to allow an agent to hear the state of the outbound call, including ringing or disconnect messages. Can be: `true` or `false` and defaults to `true`. + # @param [String] max_participants The maximum number of participants in the conference. Can be a positive integer from `2` to `250`. The default value is `250`. + # @param [String] conference_record Whether to record the conference the participant is joining. Can be: `true`, `false`, `record-from-start`, and `do-not-record`. The default value is `false`. + # @param [String] conference_trim Whether to trim leading and trailing silence from the conference recording. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. + # @param [String] conference_status_callback The URL we should call using the `conference_status_callback_method` when the conference events in `conference_status_callback_event` occur. Only the value set by the first participant to join the conference is used. Subsequent `conference_status_callback` values are ignored. + # @param [String] conference_status_callback_method The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [Array[String]] conference_status_callback_event The conference state changes that should generate a call to `conference_status_callback`. Can be: `start`, `end`, `join`, `leave`, `mute`, `hold`, `modify`, `speaker`, and `announcement`. Separate multiple values with a space. Defaults to `start end`. + # @param [String] recording_channels The recording channels for the final recording. Can be: `mono` or `dual` and the default is `mono`. + # @param [String] recording_status_callback The URL that we should call using the `recording_status_callback_method` when the recording status changes. + # @param [String] recording_status_callback_method The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sip_auth_username The SIP username used for authentication. + # @param [String] sip_auth_password The SIP password for authentication. + # @param [String] region The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + # @param [String] conference_recording_status_callback The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. + # @param [String] conference_recording_status_callback_method The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [Array[String]] recording_status_callback_event The recording state changes that should generate a call to `recording_status_callback`. Can be: `started`, `in-progress`, `paused`, `resumed`, `stopped`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'`. + # @param [Array[String]] conference_recording_status_callback_event The conference recording state changes that generate a call to `conference_recording_status_callback`. Can be: `in-progress`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'` + # @param [Boolean] coaching Whether the participant is coaching another call. Can be: `true` or `false`. If not present, defaults to `false` unless `call_sid_to_coach` is defined. If `true`, `call_sid_to_coach` must be defined. + # @param [String] call_sid_to_coach The SID of the participant who is being `coached`. The participant being coached is the only participant who can hear the participant who is `coaching`. + # @param [String] jitter_buffer_size Jitter buffer size for the connecting participant. Twilio will use this setting to apply Jitter Buffer before participant's audio is mixed into the conference. Can be: `off`, `small`, `medium`, and `large`. Default to `large`. + # @param [String] byoc The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta) + # @param [String] caller_id The phone number, Client identifier, or username portion of SIP address that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). Client identifiers are formatted `client:name`. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `callerId` must also be a phone number. If `to` is sip address, this value of `callerId` should be a username portion to be used to populate the From header that is passed to the SIP endpoint. + # @param [String] call_reason The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) + # @param [String] recording_track The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is sent from Twilio. `both` records the audio that is received and sent by Twilio. + # @param [String] time_limit The maximum duration of the call in seconds. Constraints depend on account and configuration. + # @param [String] machine_detection Whether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection). + # @param [String] machine_detection_timeout The number of seconds that we should attempt to detect an answering machine before timing out and sending a voice request with `AnsweredBy` of `unknown`. The default timeout is 30 seconds. + # @param [String] machine_detection_speech_threshold The number of milliseconds that is used as the measuring stick for the length of the speech activity, where durations lower than this value will be interpreted as a human and longer than this value as a machine. Possible Values: 1000-6000. Default: 2400. + # @param [String] machine_detection_speech_end_threshold The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200. + # @param [String] machine_detection_silence_timeout The number of milliseconds of initial silence after which an `unknown` AnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000. + # @param [String] amd_status_callback The URL that we should call using the `amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. + # @param [String] amd_status_callback_method The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + # @param [String] trim Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. + # @param [String] call_token A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. + # @param [String] caller_display_name The name that populates the display name in the From header. Must be between 2 and 255 characters. Only applicable for calls to sip address. + # @return [ParticipantInstance] Created ParticipantInstance + def create_with_metadata( + from: nil, + to: nil, + status_callback: :unset, + status_callback_method: :unset, + status_callback_event: :unset, + label: :unset, + timeout: :unset, + record: :unset, + muted: :unset, + beep: :unset, + start_conference_on_enter: :unset, + end_conference_on_exit: :unset, + wait_url: :unset, + wait_method: :unset, + early_media: :unset, + max_participants: :unset, + conference_record: :unset, + conference_trim: :unset, + conference_status_callback: :unset, + conference_status_callback_method: :unset, + conference_status_callback_event: :unset, + recording_channels: :unset, + recording_status_callback: :unset, + recording_status_callback_method: :unset, + sip_auth_username: :unset, + sip_auth_password: :unset, + region: :unset, + conference_recording_status_callback: :unset, + conference_recording_status_callback_method: :unset, + recording_status_callback_event: :unset, + conference_recording_status_callback_event: :unset, + coaching: :unset, + call_sid_to_coach: :unset, + jitter_buffer_size: :unset, + byoc: :unset, + caller_id: :unset, + call_reason: :unset, + recording_track: :unset, + time_limit: :unset, + machine_detection: :unset, + machine_detection_timeout: :unset, + machine_detection_speech_threshold: :unset, + machine_detection_speech_end_threshold: :unset, + machine_detection_silence_timeout: :unset, + amd_status_callback: :unset, + amd_status_callback_method: :unset, + trim: :unset, + call_token: :unset, + caller_display_name: :unset + ) + + data = Twilio::Values.of({ + 'From' => from, + 'To' => to, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'StatusCallbackEvent' => Twilio.serialize_list(status_callback_event) { |e| e }, + 'Label' => label, + 'Timeout' => timeout, + 'Record' => record, + 'Muted' => muted, + 'Beep' => beep, + 'StartConferenceOnEnter' => start_conference_on_enter, + 'EndConferenceOnExit' => end_conference_on_exit, + 'WaitUrl' => wait_url, + 'WaitMethod' => wait_method, + 'EarlyMedia' => early_media, + 'MaxParticipants' => max_participants, + 'ConferenceRecord' => conference_record, + 'ConferenceTrim' => conference_trim, + 'ConferenceStatusCallback' => conference_status_callback, + 'ConferenceStatusCallbackMethod' => conference_status_callback_method, + 'ConferenceStatusCallbackEvent' => Twilio.serialize_list(conference_status_callback_event) { |e| e }, + 'RecordingChannels' => recording_channels, + 'RecordingStatusCallback' => recording_status_callback, + 'RecordingStatusCallbackMethod' => recording_status_callback_method, + 'SipAuthUsername' => sip_auth_username, + 'SipAuthPassword' => sip_auth_password, + 'Region' => region, + 'ConferenceRecordingStatusCallback' => conference_recording_status_callback, + 'ConferenceRecordingStatusCallbackMethod' => conference_recording_status_callback_method, + 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e }, + 'ConferenceRecordingStatusCallbackEvent' => Twilio.serialize_list(conference_recording_status_callback_event) { |e| e }, + 'Coaching' => coaching, + 'CallSidToCoach' => call_sid_to_coach, + 'JitterBufferSize' => jitter_buffer_size, + 'Byoc' => byoc, + 'CallerId' => caller_id, + 'CallReason' => call_reason, + 'RecordingTrack' => recording_track, + 'TimeLimit' => time_limit, + 'MachineDetection' => machine_detection, + 'MachineDetectionTimeout' => machine_detection_timeout, + 'MachineDetectionSpeechThreshold' => machine_detection_speech_threshold, + 'MachineDetectionSpeechEndThreshold' => machine_detection_speech_end_threshold, + 'MachineDetectionSilenceTimeout' => machine_detection_silence_timeout, + 'AmdStatusCallback' => amd_status_callback, + 'AmdStatusCallbackMethod' => amd_status_callback_method, + 'Trim' => trim, + 'CallToken' => call_token, + 'CallerDisplayName' => caller_display_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + conference_sid: @solution[:conference_sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Lists ParticipantInstance records from the API as a list. @@ -255,6 +432,34 @@ def stream(muted: :unset, hold: :unset, coaching: :unset, limit: nil, page_size: @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantPageMetadata records from the API as a list. + # @param [Boolean] muted Whether to return only participants that are muted. Can be: `true` or `false`. + # @param [Boolean] hold Whether to return only participants that are on hold. Can be: `true` or `false`. + # @param [Boolean] coaching Whether to return only participants who are coaching another call. Can be: `true` or `false`. + # @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_with_metadata(muted: :unset, hold: :unset, coaching: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Muted' => muted, + 'Hold' => hold, + 'Coaching' => coaching, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -345,7 +550,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ParticipantInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new(@version, participant_instance, response.headers, response.status_code) end ## @@ -369,6 +593,33 @@ def fetch ) end + ## + # Fetch the ParticipantInstanceMetadata + # @return [ParticipantInstance] Fetched ParticipantInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + conference_sid: @solution[:conference_sid], + call_sid: @solution[:call_sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Update the ParticipantInstance # @param [Boolean] muted Whether the participant should be muted. Can be `true` or `false`. `true` will mute the participant, and `false` will un-mute them. Anything value other than `true` or `false` is interpreted as `false`. @@ -430,6 +681,73 @@ def update( ) end + ## + # Update the ParticipantInstanceMetadata + # @param [Boolean] muted Whether the participant should be muted. Can be `true` or `false`. `true` will mute the participant, and `false` will un-mute them. Anything value other than `true` or `false` is interpreted as `false`. + # @param [Boolean] hold Whether the participant should be on hold. Can be: `true` or `false`. `true` puts the participant on hold, and `false` lets them rejoin the conference. + # @param [String] hold_url The URL we call using the `hold_method` for music that plays when the participant is on hold. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. + # @param [String] hold_method The HTTP method we should use to call `hold_url`. Can be: `GET` or `POST` and the default is `GET`. + # @param [String] announce_url The URL we call using the `announce_method` for an announcement to the participant. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. + # @param [String] announce_method The HTTP method we should use to call `announce_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] wait_url The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). + # @param [String] wait_method The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. + # @param [Boolean] beep_on_exit Whether to play a notification beep to the conference when the participant exits. Can be: `true` or `false`. + # @param [Boolean] end_conference_on_exit Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. + # @param [Boolean] coaching Whether the participant is coaching another call. Can be: `true` or `false`. If not present, defaults to `false` unless `call_sid_to_coach` is defined. If `true`, `call_sid_to_coach` must be defined. + # @param [String] call_sid_to_coach The SID of the participant who is being `coached`. The participant being coached is the only participant who can hear the participant who is `coaching`. + # @return [ParticipantInstance] Updated ParticipantInstance + def update_with_metadata( + muted: :unset, + hold: :unset, + hold_url: :unset, + hold_method: :unset, + announce_url: :unset, + announce_method: :unset, + wait_url: :unset, + wait_method: :unset, + beep_on_exit: :unset, + end_conference_on_exit: :unset, + coaching: :unset, + call_sid_to_coach: :unset + ) + + data = Twilio::Values.of({ + 'Muted' => muted, + 'Hold' => hold, + 'HoldUrl' => hold_url, + 'HoldMethod' => hold_method, + 'AnnounceUrl' => announce_url, + 'AnnounceMethod' => announce_method, + 'WaitUrl' => wait_url, + 'WaitMethod' => wait_method, + 'BeepOnExit' => beep_on_exit, + 'EndConferenceOnExit' => end_conference_on_exit, + 'Coaching' => coaching, + 'CallSidToCoach' => call_sid_to_coach, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + conference_sid: @solution[:conference_sid], + call_sid: @solution[:call_sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -446,6 +764,45 @@ def inspect end end + class ParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ParticipantInstance] participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, participant_instance, headers, status_code) + super(version, headers, status_code) + @participant_instance = participant_instance + end + + def participant + @participant_instance + end + + def to_s + "" + end + end + + class ParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_instance = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_instance + @instance + end + end + class ParticipantPage < Page ## # Initialize the ParticipantPage @@ -474,6 +831,54 @@ def to_s '' end end + + class ParticipantPageMetadata < PageMetadata + attr_reader :participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_page << ParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant + @participant + end + end + class ParticipantInstance < InstanceResource ## # Initialize the ParticipantInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb b/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb index 9adad397f..e33c6d385 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb @@ -84,6 +84,34 @@ def stream(date_created: :unset, date_created_before: :unset, date_created_after @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RecordingPageMetadata records from the API as a list. + # @param [Date] date_created The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date. + # @param [Date] date_created_before The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date. + # @param [Date] date_created_after The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date. + # @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_with_metadata(date_created: :unset, date_created_before: :unset, date_created_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'DateCreated' => Twilio.serialize_iso8601_date(date_created), + 'DateCreated<' => Twilio.serialize_iso8601_date(date_created_before), + 'DateCreated>' => Twilio.serialize_iso8601_date(date_created_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RecordingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RecordingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -174,7 +202,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RecordingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new(@version, recording_instance, response.headers, response.status_code) end ## @@ -198,6 +245,33 @@ def fetch ) end + ## + # Fetch the RecordingInstanceMetadata + # @return [RecordingInstance] Fetched RecordingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + conference_sid: @solution[:conference_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Update the RecordingInstance # @param [Status] status @@ -229,6 +303,43 @@ def update( ) end + ## + # Update the RecordingInstanceMetadata + # @param [Status] status + # @param [String] pause_behavior Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`. + # @return [RecordingInstance] Updated RecordingInstance + def update_with_metadata( + status: nil, + pause_behavior: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'PauseBehavior' => pause_behavior, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + conference_sid: @solution[:conference_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -245,6 +356,45 @@ def inspect end end + class RecordingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RecordingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RecordingInstance] recording_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RecordingInstanceMetadata] The initialized instance with metadata. + def initialize(version, recording_instance, headers, status_code) + super(version, headers, status_code) + @recording_instance = recording_instance + end + + def recording + @recording_instance + end + + def to_s + "" + end + end + + class RecordingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_instance = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_instance + @instance + end + end + class RecordingPage < Page ## # Initialize the RecordingPage @@ -273,6 +423,54 @@ def to_s '' end end + + class RecordingPageMetadata < PageMetadata + attr_reader :recording_page + + def initialize(version, response, solution, limit) + super(version, response) + @recording_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @recording_page << RecordingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @recording_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording + @recording + end + end + class RecordingInstance < InstanceResource ## # Initialize the RecordingInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb b/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb index e8c69093f..e11f89a72 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConnectAppPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConnectAppPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConnectAppInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -154,7 +176,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ConnectAppInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + connectApp_instance = ConnectAppInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConnectAppInstanceMetadata.new(@version, connectApp_instance, response.headers, response.status_code) end ## @@ -177,6 +218,32 @@ def fetch ) end + ## + # Fetch the ConnectAppInstanceMetadata + # @return [ConnectAppInstance] Fetched ConnectAppInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + connectApp_instance = ConnectAppInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConnectAppInstanceMetadata.new( + @version, + connectApp_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConnectAppInstance # @param [String] authorize_redirect_url The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App. @@ -225,6 +292,60 @@ def update( ) end + ## + # Update the ConnectAppInstanceMetadata + # @param [String] authorize_redirect_url The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App. + # @param [String] company_name The company name to set for the Connect App. + # @param [String] deauthorize_callback_method The HTTP method to use when calling `deauthorize_callback_url`. + # @param [String] deauthorize_callback_url The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App. + # @param [String] description A description of the Connect App. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] homepage_url A public URL where users can obtain more information about this Connect App. + # @param [Array[Permission]] permissions A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`. + # @return [ConnectAppInstance] Updated ConnectAppInstance + def update_with_metadata( + authorize_redirect_url: :unset, + company_name: :unset, + deauthorize_callback_method: :unset, + deauthorize_callback_url: :unset, + description: :unset, + friendly_name: :unset, + homepage_url: :unset, + permissions: :unset + ) + + data = Twilio::Values.of({ + 'AuthorizeRedirectUrl' => authorize_redirect_url, + 'CompanyName' => company_name, + 'DeauthorizeCallbackMethod' => deauthorize_callback_method, + 'DeauthorizeCallbackUrl' => deauthorize_callback_url, + 'Description' => description, + 'FriendlyName' => friendly_name, + 'HomepageUrl' => homepage_url, + 'Permissions' => Twilio.serialize_list(permissions) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + connectApp_instance = ConnectAppInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConnectAppInstanceMetadata.new( + @version, + connectApp_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -241,6 +362,45 @@ def inspect end end + class ConnectAppInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConnectAppInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConnectAppInstance] connect_app_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConnectAppInstanceMetadata] The initialized instance with metadata. + def initialize(version, connect_app_instance, headers, status_code) + super(version, headers, status_code) + @connect_app_instance = connect_app_instance + end + + def connect_app + @connect_app_instance + end + + def to_s + "" + end + end + + class ConnectAppListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @connect_app_instance = payload.body[key].map do |data| + ConnectAppInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def connect_app_instance + @instance + end + end + class ConnectAppPage < Page ## # Initialize the ConnectAppPage @@ -269,6 +429,54 @@ def to_s '' end end + + class ConnectAppPageMetadata < PageMetadata + attr_reader :connect_app_page + + def initialize(version, response, solution, limit) + super(version, response) + @connect_app_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @connect_app_page << ConnectAppListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @connect_app_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConnectAppListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @connect_app = payload.body[key].map do |data| + ConnectAppInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def connect_app + @connect_app + end + end + class ConnectAppInstance < InstanceResource ## # Initialize the ConnectAppInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb index 56cb676b8..67e435c34 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb @@ -130,6 +130,107 @@ def create( ) end + ## + # Create the IncomingPhoneNumberInstanceMetadata + # @param [String] api_version The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`. + # @param [String] friendly_name A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the new phone number. + # @param [String] sms_application_sid The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those set on the application. + # @param [String] sms_fallback_method The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_fallback_url The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`. + # @param [String] sms_method The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_url The URL we should call when the new phone number receives an incoming SMS message. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_application_sid The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa. + # @param [Boolean] voice_caller_id_lookup Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`. + # @param [String] voice_fallback_method The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`. + # @param [String] voice_method The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_url The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set. + # @param [EmergencyStatus] emergency_status + # @param [String] emergency_address_sid The SID of the emergency address configuration to use for emergency calling from the new phone number. + # @param [String] trunk_sid The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa. + # @param [String] identity_sid The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations. + # @param [String] address_sid The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations. + # @param [VoiceReceiveMode] voice_receive_mode + # @param [String] bundle_sid The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations. + # @param [String] phone_number The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234. + # @param [String] area_code The desired area code for your new incoming phone number. Can be any three-digit, US or Canada area code. We will provision an available phone number within this area code for you. **You must provide an `area_code` or a `phone_number`.** (US and Canada only). + # @return [IncomingPhoneNumberInstance] Created IncomingPhoneNumberInstance + def create_with_metadata( + api_version: :unset, + friendly_name: :unset, + sms_application_sid: :unset, + sms_fallback_method: :unset, + sms_fallback_url: :unset, + sms_method: :unset, + sms_url: :unset, + status_callback: :unset, + status_callback_method: :unset, + voice_application_sid: :unset, + voice_caller_id_lookup: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_url: :unset, + emergency_status: :unset, + emergency_address_sid: :unset, + trunk_sid: :unset, + identity_sid: :unset, + address_sid: :unset, + voice_receive_mode: :unset, + bundle_sid: :unset, + phone_number: :unset, + area_code: :unset + ) + + data = Twilio::Values.of({ + 'ApiVersion' => api_version, + 'FriendlyName' => friendly_name, + 'SmsApplicationSid' => sms_application_sid, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsMethod' => sms_method, + 'SmsUrl' => sms_url, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'VoiceApplicationSid' => voice_application_sid, + 'VoiceCallerIdLookup' => voice_caller_id_lookup, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceUrl' => voice_url, + 'EmergencyStatus' => emergency_status, + 'EmergencyAddressSid' => emergency_address_sid, + 'TrunkSid' => trunk_sid, + 'IdentitySid' => identity_sid, + 'AddressSid' => address_sid, + 'VoiceReceiveMode' => voice_receive_mode, + 'BundleSid' => bundle_sid, + 'PhoneNumber' => phone_number, + 'AreaCode' => area_code, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + incomingPhoneNumber_instance = IncomingPhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + IncomingPhoneNumberInstanceMetadata.new( + @version, + incomingPhoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Lists IncomingPhoneNumberInstance records from the API as a list. @@ -185,6 +286,36 @@ def stream(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :u @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists IncomingPhoneNumberPageMetadata records from the API as a list. + # @param [Boolean] beta Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] friendly_name A string that identifies the IncomingPhoneNumber resources to read. + # @param [String] phone_number The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit. + # @param [String] origin Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included. + # @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_with_metadata(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Beta' => beta, + 'FriendlyName' => friendly_name, + 'PhoneNumber' => phone_number, + 'Origin' => origin, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + IncomingPhoneNumberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields IncomingPhoneNumberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -298,7 +429,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the IncomingPhoneNumberInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + incomingPhoneNumber_instance = IncomingPhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IncomingPhoneNumberInstanceMetadata.new(@version, incomingPhoneNumber_instance, response.headers, response.status_code) end ## @@ -321,6 +471,32 @@ def fetch ) end + ## + # Fetch the IncomingPhoneNumberInstanceMetadata + # @return [IncomingPhoneNumberInstance] Fetched IncomingPhoneNumberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + incomingPhoneNumber_instance = IncomingPhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IncomingPhoneNumberInstanceMetadata.new( + @version, + incomingPhoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Update the IncomingPhoneNumberInstance # @param [String] account_sid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the IncomingPhoneNumber resource to update. For more information, see [Exchanging Numbers Between Subaccounts](https://www.twilio.com/docs/iam/api/subaccounts#exchanging-numbers). @@ -414,6 +590,105 @@ def update( ) end + ## + # Update the IncomingPhoneNumberInstanceMetadata + # @param [String] account_sid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the IncomingPhoneNumber resource to update. For more information, see [Exchanging Numbers Between Subaccounts](https://www.twilio.com/docs/iam/api/subaccounts#exchanging-numbers). + # @param [String] api_version The API version to use for incoming calls made to the phone number. The default is `2010-04-01`. + # @param [String] friendly_name A descriptive string that you created to describe this phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number. + # @param [String] sms_application_sid The SID of the application that should handle SMS messages sent to the number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those set on the application. + # @param [String] sms_fallback_method The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_fallback_url The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`. + # @param [String] sms_method The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_url The URL we should call when the phone number receives an incoming SMS message. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_application_sid The SID of the application we should use to handle phone calls to the phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa. + # @param [Boolean] voice_caller_id_lookup Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`. + # @param [String] voice_fallback_method The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`. + # @param [String] voice_method The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_url The URL that we should call to answer a call to the phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set. + # @param [EmergencyStatus] emergency_status + # @param [String] emergency_address_sid The SID of the emergency address configuration to use for emergency calling from this phone number. + # @param [String] trunk_sid The SID of the Trunk we should use to handle phone calls to the phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa. + # @param [VoiceReceiveMode] voice_receive_mode + # @param [String] identity_sid The SID of the Identity resource that we should associate with the phone number. Some regions require an identity to meet local regulations. + # @param [String] address_sid The SID of the Address resource we should associate with the phone number. Some regions require addresses to meet local regulations. + # @param [String] bundle_sid The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations. + # @return [IncomingPhoneNumberInstance] Updated IncomingPhoneNumberInstance + def update_with_metadata( + account_sid: :unset, + api_version: :unset, + friendly_name: :unset, + sms_application_sid: :unset, + sms_fallback_method: :unset, + sms_fallback_url: :unset, + sms_method: :unset, + sms_url: :unset, + status_callback: :unset, + status_callback_method: :unset, + voice_application_sid: :unset, + voice_caller_id_lookup: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_url: :unset, + emergency_status: :unset, + emergency_address_sid: :unset, + trunk_sid: :unset, + voice_receive_mode: :unset, + identity_sid: :unset, + address_sid: :unset, + bundle_sid: :unset + ) + + data = Twilio::Values.of({ + 'AccountSid' => account_sid, + 'ApiVersion' => api_version, + 'FriendlyName' => friendly_name, + 'SmsApplicationSid' => sms_application_sid, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsMethod' => sms_method, + 'SmsUrl' => sms_url, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'VoiceApplicationSid' => voice_application_sid, + 'VoiceCallerIdLookup' => voice_caller_id_lookup, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceUrl' => voice_url, + 'EmergencyStatus' => emergency_status, + 'EmergencyAddressSid' => emergency_address_sid, + 'TrunkSid' => trunk_sid, + 'VoiceReceiveMode' => voice_receive_mode, + 'IdentitySid' => identity_sid, + 'AddressSid' => address_sid, + 'BundleSid' => bundle_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + incomingPhoneNumber_instance = IncomingPhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IncomingPhoneNumberInstanceMetadata.new( + @version, + incomingPhoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Access the assigned_add_ons # @return [AssignedAddOnList] @@ -449,6 +724,45 @@ def inspect end end + class IncomingPhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new IncomingPhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}IncomingPhoneNumberInstance] incoming_phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [IncomingPhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, incoming_phone_number_instance, headers, status_code) + super(version, headers, status_code) + @incoming_phone_number_instance = incoming_phone_number_instance + end + + def incoming_phone_number + @incoming_phone_number_instance + end + + def to_s + "" + end + end + + class IncomingPhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @incoming_phone_number_instance = payload.body[key].map do |data| + IncomingPhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def incoming_phone_number_instance + @instance + end + end + class IncomingPhoneNumberPage < Page ## # Initialize the IncomingPhoneNumberPage @@ -477,6 +791,54 @@ def to_s '' end end + + class IncomingPhoneNumberPageMetadata < PageMetadata + attr_reader :incoming_phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @incoming_phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @incoming_phone_number_page << IncomingPhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @incoming_phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class IncomingPhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @incoming_phone_number = payload.body[key].map do |data| + IncomingPhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def incoming_phone_number + @incoming_phone_number + end + end + class IncomingPhoneNumberInstance < InstanceResource ## # Initialize the IncomingPhoneNumberInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb index fb6e1ca46..8bd786284 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb @@ -60,6 +60,39 @@ def create( ) end + ## + # Create the AssignedAddOnInstanceMetadata + # @param [String] installed_add_on_sid The SID that identifies the Add-on installation. + # @return [AssignedAddOnInstance] Created AssignedAddOnInstance + def create_with_metadata( + installed_add_on_sid: nil + ) + + data = Twilio::Values.of({ + 'InstalledAddOnSid' => installed_add_on_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + assignedAddOn_instance = AssignedAddOnInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + resource_sid: @solution[:resource_sid], + ) + AssignedAddOnInstanceMetadata.new( + @version, + assignedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Lists AssignedAddOnInstance records from the API as a list. @@ -99,6 +132,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssignedAddOnPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssignedAddOnPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssignedAddOnInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +239,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AssignedAddOnInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + assignedAddOn_instance = AssignedAddOnInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AssignedAddOnInstanceMetadata.new(@version, assignedAddOn_instance, response.headers, response.status_code) end ## @@ -208,6 +282,33 @@ def fetch ) end + ## + # Fetch the AssignedAddOnInstanceMetadata + # @return [AssignedAddOnInstance] Fetched AssignedAddOnInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + assignedAddOn_instance = AssignedAddOnInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + resource_sid: @solution[:resource_sid], + sid: @solution[:sid], + ) + AssignedAddOnInstanceMetadata.new( + @version, + assignedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Access the extensions # @return [AssignedAddOnExtensionList] @@ -243,6 +344,45 @@ def inspect end end + class AssignedAddOnInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssignedAddOnInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssignedAddOnInstance] assigned_add_on_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssignedAddOnInstanceMetadata] The initialized instance with metadata. + def initialize(version, assigned_add_on_instance, headers, status_code) + super(version, headers, status_code) + @assigned_add_on_instance = assigned_add_on_instance + end + + def assigned_add_on + @assigned_add_on_instance + end + + def to_s + "" + end + end + + class AssignedAddOnListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assigned_add_on_instance = payload.body[key].map do |data| + AssignedAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assigned_add_on_instance + @instance + end + end + class AssignedAddOnPage < Page ## # Initialize the AssignedAddOnPage @@ -271,6 +411,54 @@ def to_s '' end end + + class AssignedAddOnPageMetadata < PageMetadata + attr_reader :assigned_add_on_page + + def initialize(version, response, solution, limit) + super(version, response) + @assigned_add_on_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @assigned_add_on_page << AssignedAddOnListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @assigned_add_on_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssignedAddOnListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assigned_add_on = payload.body[key].map do |data| + AssignedAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assigned_add_on + @assigned_add_on + end + end + class AssignedAddOnInstance < InstanceResource ## # Initialize the AssignedAddOnInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb index 2f1e9c8b9..71e58ef92 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb @@ -73,6 +73,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssignedAddOnExtensionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssignedAddOnExtensionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssignedAddOnExtensionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -171,6 +193,34 @@ def fetch ) end + ## + # Fetch the AssignedAddOnExtensionInstanceMetadata + # @return [AssignedAddOnExtensionInstance] Fetched AssignedAddOnExtensionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + assignedAddOnExtension_instance = AssignedAddOnExtensionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + resource_sid: @solution[:resource_sid], + assigned_add_on_sid: @solution[:assigned_add_on_sid], + sid: @solution[:sid], + ) + AssignedAddOnExtensionInstanceMetadata.new( + @version, + assignedAddOnExtension_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -187,6 +237,45 @@ def inspect end end + class AssignedAddOnExtensionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssignedAddOnExtensionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssignedAddOnExtensionInstance] assigned_add_on_extension_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssignedAddOnExtensionInstanceMetadata] The initialized instance with metadata. + def initialize(version, assigned_add_on_extension_instance, headers, status_code) + super(version, headers, status_code) + @assigned_add_on_extension_instance = assigned_add_on_extension_instance + end + + def assigned_add_on_extension + @assigned_add_on_extension_instance + end + + def to_s + "" + end + end + + class AssignedAddOnExtensionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assigned_add_on_extension_instance = payload.body[key].map do |data| + AssignedAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assigned_add_on_extension_instance + @instance + end + end + class AssignedAddOnExtensionPage < Page ## # Initialize the AssignedAddOnExtensionPage @@ -215,6 +304,54 @@ def to_s '' end end + + class AssignedAddOnExtensionPageMetadata < PageMetadata + attr_reader :assigned_add_on_extension_page + + def initialize(version, response, solution, limit) + super(version, response) + @assigned_add_on_extension_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @assigned_add_on_extension_page << AssignedAddOnExtensionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @assigned_add_on_extension_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssignedAddOnExtensionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assigned_add_on_extension = payload.body[key].map do |data| + AssignedAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assigned_add_on_extension + @assigned_add_on_extension + end + end + class AssignedAddOnExtensionInstance < InstanceResource ## # Initialize the AssignedAddOnExtensionInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb index 36851b267..86cb12805 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb @@ -125,6 +125,104 @@ def create( ) end + ## + # Create the LocalInstanceMetadata + # @param [String] phone_number The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234. + # @param [String] api_version The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`. + # @param [String] friendly_name A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number. + # @param [String] sms_application_sid The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those set on the application. + # @param [String] sms_fallback_method The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_fallback_url The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`. + # @param [String] sms_method The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_url The URL we should call when the new phone number receives an incoming SMS message. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_application_sid The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa. + # @param [Boolean] voice_caller_id_lookup Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`. + # @param [String] voice_fallback_method The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`. + # @param [String] voice_method The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_url The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set. + # @param [String] identity_sid The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations. + # @param [String] address_sid The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations. + # @param [EmergencyStatus] emergency_status + # @param [String] emergency_address_sid The SID of the emergency address configuration to use for emergency calling from the new phone number. + # @param [String] trunk_sid The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa. + # @param [VoiceReceiveMode] voice_receive_mode + # @param [String] bundle_sid The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations. + # @return [LocalInstance] Created LocalInstance + def create_with_metadata( + phone_number: nil, + api_version: :unset, + friendly_name: :unset, + sms_application_sid: :unset, + sms_fallback_method: :unset, + sms_fallback_url: :unset, + sms_method: :unset, + sms_url: :unset, + status_callback: :unset, + status_callback_method: :unset, + voice_application_sid: :unset, + voice_caller_id_lookup: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_url: :unset, + identity_sid: :unset, + address_sid: :unset, + emergency_status: :unset, + emergency_address_sid: :unset, + trunk_sid: :unset, + voice_receive_mode: :unset, + bundle_sid: :unset + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + 'ApiVersion' => api_version, + 'FriendlyName' => friendly_name, + 'SmsApplicationSid' => sms_application_sid, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsMethod' => sms_method, + 'SmsUrl' => sms_url, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'VoiceApplicationSid' => voice_application_sid, + 'VoiceCallerIdLookup' => voice_caller_id_lookup, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceUrl' => voice_url, + 'IdentitySid' => identity_sid, + 'AddressSid' => address_sid, + 'EmergencyStatus' => emergency_status, + 'EmergencyAddressSid' => emergency_address_sid, + 'TrunkSid' => trunk_sid, + 'VoiceReceiveMode' => voice_receive_mode, + 'BundleSid' => bundle_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + local_instance = LocalInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + LocalInstanceMetadata.new( + @version, + local_instance, + response.headers, + response.status_code + ) + end + ## # Lists LocalInstance records from the API as a list. @@ -180,6 +278,36 @@ def stream(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :u @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists LocalPageMetadata records from the API as a list. + # @param [Boolean] beta Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] friendly_name A string that identifies the resources to read. + # @param [String] phone_number The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit. + # @param [String] origin Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included. + # @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_with_metadata(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Beta' => beta, + 'FriendlyName' => friendly_name, + 'PhoneNumber' => phone_number, + 'Origin' => origin, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + LocalPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields LocalInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -273,6 +401,54 @@ def to_s '' end end + + class LocalPageMetadata < PageMetadata + attr_reader :local_page + + def initialize(version, response, solution, limit) + super(version, response) + @local_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @local_page << LocalListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @local_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LocalListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @local = payload.body[key].map do |data| + LocalInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def local + @local + end + end + class LocalInstance < InstanceResource ## # Initialize the LocalInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb index 9b4e90770..dd18647a8 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb @@ -125,6 +125,104 @@ def create( ) end + ## + # Create the MobileInstanceMetadata + # @param [String] phone_number The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234. + # @param [String] api_version The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`. + # @param [String] friendly_name A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, the is a formatted version of the phone number. + # @param [String] sms_application_sid The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those of the application. + # @param [String] sms_fallback_method The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_fallback_url The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`. + # @param [String] sms_method The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_url The URL we should call when the new phone number receives an incoming SMS message. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_application_sid The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa. + # @param [Boolean] voice_caller_id_lookup Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`. + # @param [String] voice_fallback_method The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`. + # @param [String] voice_method The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_url The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set. + # @param [String] identity_sid The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations. + # @param [String] address_sid The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations. + # @param [EmergencyStatus] emergency_status + # @param [String] emergency_address_sid The SID of the emergency address configuration to use for emergency calling from the new phone number. + # @param [String] trunk_sid The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa. + # @param [VoiceReceiveMode] voice_receive_mode + # @param [String] bundle_sid The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations. + # @return [MobileInstance] Created MobileInstance + def create_with_metadata( + phone_number: nil, + api_version: :unset, + friendly_name: :unset, + sms_application_sid: :unset, + sms_fallback_method: :unset, + sms_fallback_url: :unset, + sms_method: :unset, + sms_url: :unset, + status_callback: :unset, + status_callback_method: :unset, + voice_application_sid: :unset, + voice_caller_id_lookup: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_url: :unset, + identity_sid: :unset, + address_sid: :unset, + emergency_status: :unset, + emergency_address_sid: :unset, + trunk_sid: :unset, + voice_receive_mode: :unset, + bundle_sid: :unset + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + 'ApiVersion' => api_version, + 'FriendlyName' => friendly_name, + 'SmsApplicationSid' => sms_application_sid, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsMethod' => sms_method, + 'SmsUrl' => sms_url, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'VoiceApplicationSid' => voice_application_sid, + 'VoiceCallerIdLookup' => voice_caller_id_lookup, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceUrl' => voice_url, + 'IdentitySid' => identity_sid, + 'AddressSid' => address_sid, + 'EmergencyStatus' => emergency_status, + 'EmergencyAddressSid' => emergency_address_sid, + 'TrunkSid' => trunk_sid, + 'VoiceReceiveMode' => voice_receive_mode, + 'BundleSid' => bundle_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + mobile_instance = MobileInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + MobileInstanceMetadata.new( + @version, + mobile_instance, + response.headers, + response.status_code + ) + end + ## # Lists MobileInstance records from the API as a list. @@ -180,6 +278,36 @@ def stream(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :u @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MobilePageMetadata records from the API as a list. + # @param [Boolean] beta Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] friendly_name A string that identifies the resources to read. + # @param [String] phone_number The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit. + # @param [String] origin Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included. + # @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_with_metadata(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Beta' => beta, + 'FriendlyName' => friendly_name, + 'PhoneNumber' => phone_number, + 'Origin' => origin, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MobilePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MobileInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -273,6 +401,54 @@ def to_s '' end end + + class MobilePageMetadata < PageMetadata + attr_reader :mobile_page + + def initialize(version, response, solution, limit) + super(version, response) + @mobile_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @mobile_page << MobileListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @mobile_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MobileListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @mobile = payload.body[key].map do |data| + MobileInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def mobile + @mobile + end + end + class MobileInstance < InstanceResource ## # Initialize the MobileInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb index a032fadf3..d2f71d875 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb @@ -125,6 +125,104 @@ def create( ) end + ## + # Create the TollFreeInstanceMetadata + # @param [String] phone_number The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234. + # @param [String] api_version The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`. + # @param [String] friendly_name A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number. + # @param [String] sms_application_sid The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application. + # @param [String] sms_fallback_method The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_fallback_url The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`. + # @param [String] sms_method The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] sms_url The URL we should call when the new phone number receives an incoming SMS message. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_application_sid The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa. + # @param [Boolean] voice_caller_id_lookup Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`. + # @param [String] voice_fallback_method The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`. + # @param [String] voice_method The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] voice_url The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set. + # @param [String] identity_sid The SID of the Identity resource that we should associate with the new phone number. Some regions require an Identity to meet local regulations. + # @param [String] address_sid The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations. + # @param [EmergencyStatus] emergency_status + # @param [String] emergency_address_sid The SID of the emergency address configuration to use for emergency calling from the new phone number. + # @param [String] trunk_sid The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa. + # @param [VoiceReceiveMode] voice_receive_mode + # @param [String] bundle_sid The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations. + # @return [TollFreeInstance] Created TollFreeInstance + def create_with_metadata( + phone_number: nil, + api_version: :unset, + friendly_name: :unset, + sms_application_sid: :unset, + sms_fallback_method: :unset, + sms_fallback_url: :unset, + sms_method: :unset, + sms_url: :unset, + status_callback: :unset, + status_callback_method: :unset, + voice_application_sid: :unset, + voice_caller_id_lookup: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_url: :unset, + identity_sid: :unset, + address_sid: :unset, + emergency_status: :unset, + emergency_address_sid: :unset, + trunk_sid: :unset, + voice_receive_mode: :unset, + bundle_sid: :unset + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + 'ApiVersion' => api_version, + 'FriendlyName' => friendly_name, + 'SmsApplicationSid' => sms_application_sid, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsMethod' => sms_method, + 'SmsUrl' => sms_url, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'VoiceApplicationSid' => voice_application_sid, + 'VoiceCallerIdLookup' => voice_caller_id_lookup, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceUrl' => voice_url, + 'IdentitySid' => identity_sid, + 'AddressSid' => address_sid, + 'EmergencyStatus' => emergency_status, + 'EmergencyAddressSid' => emergency_address_sid, + 'TrunkSid' => trunk_sid, + 'VoiceReceiveMode' => voice_receive_mode, + 'BundleSid' => bundle_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + tollFree_instance = TollFreeInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + TollFreeInstanceMetadata.new( + @version, + tollFree_instance, + response.headers, + response.status_code + ) + end + ## # Lists TollFreeInstance records from the API as a list. @@ -180,6 +278,36 @@ def stream(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :u @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TollFreePageMetadata records from the API as a list. + # @param [Boolean] beta Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`. + # @param [String] friendly_name A string that identifies the resources to read. + # @param [String] phone_number The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit. + # @param [String] origin Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included. + # @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_with_metadata(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Beta' => beta, + 'FriendlyName' => friendly_name, + 'PhoneNumber' => phone_number, + 'Origin' => origin, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TollFreePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TollFreeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -273,6 +401,54 @@ def to_s '' end end + + class TollFreePageMetadata < PageMetadata + attr_reader :toll_free_page + + def initialize(version, response, solution, limit) + super(version, response) + @toll_free_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @toll_free_page << TollFreeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @toll_free_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TollFreeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @toll_free = payload.body[key].map do |data| + TollFreeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def toll_free + @toll_free + end + end + class TollFreeInstance < InstanceResource ## # Initialize the TollFreeInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/key.rb b/lib/twilio-ruby/rest/api/v2010/account/key.rb index 6e3f1037a..91ef4f03c 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/key.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/key.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists KeyPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + KeyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields KeyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -154,7 +176,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the KeyInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + key_instance = KeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + KeyInstanceMetadata.new(@version, key_instance, response.headers, response.status_code) end ## @@ -177,6 +218,32 @@ def fetch ) end + ## + # Fetch the KeyInstanceMetadata + # @return [KeyInstance] Fetched KeyInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + key_instance = KeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + KeyInstanceMetadata.new( + @version, + key_instance, + response.headers, + response.status_code + ) + end + ## # Update the KeyInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -204,6 +271,39 @@ def update( ) end + ## + # Update the KeyInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [KeyInstance] Updated KeyInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + key_instance = KeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + KeyInstanceMetadata.new( + @version, + key_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -220,6 +320,45 @@ def inspect end end + class KeyInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new KeyInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}KeyInstance] key_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [KeyInstanceMetadata] The initialized instance with metadata. + def initialize(version, key_instance, headers, status_code) + super(version, headers, status_code) + @key_instance = key_instance + end + + def key + @key_instance + end + + def to_s + "" + end + end + + class KeyListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @key_instance = payload.body[key].map do |data| + KeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def key_instance + @instance + end + end + class KeyPage < Page ## # Initialize the KeyPage @@ -248,6 +387,54 @@ def to_s '' end end + + class KeyPageMetadata < PageMetadata + attr_reader :key_page + + def initialize(version, response, solution, limit) + super(version, response) + @key_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @key_page << KeyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @key_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class KeyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @key = payload.body[key].map do |data| + KeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def key + @key + end + end + class KeyInstance < InstanceResource ## # Initialize the KeyInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/message.rb b/lib/twilio-ruby/rest/api/v2010/account/message.rb index 5fff1b205..c4090e983 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message.rb @@ -20,7 +20,7 @@ class V2010 < Version class AccountContext < InstanceContext class MessageList < ListResource - + ## # Initialize the MessageList # @param [Version] version Version that contains the resource @@ -30,29 +30,29 @@ def initialize(version, account_sid: nil) # Path Solution @solution = { account_sid: account_sid } @uri = "/Accounts/#{@solution[:account_sid]}/Messages.json" - + end ## # Create the MessageInstance # @param [String] to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`. - # @param [String] status_callback The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). + # @param [String] status_callback The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). # @param [String] application_sid The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored. # @param [Float] max_price [OBSOLETE] This parameter will no longer have any effect as of 2024-06-03. # @param [Boolean] provide_feedback Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`. # @param [String] attempt Total number of attempts made (including this request) to send the message regardless of the provider used # @param [String] validity_period The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `36000`. Default value is `36000`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) # @param [Boolean] force_delivery Reserved - # @param [ContentRetention] content_retention - # @param [AddressRetention] address_retention + # @param [ContentRetention] content_retention + # @param [AddressRetention] address_retention # @param [Boolean] smart_encoded Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. # @param [Array[String]] persistent_action Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). - # @param [TrafficType] traffic_type + # @param [TrafficType] traffic_type # @param [Boolean] shorten_urls For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. - # @param [ScheduleType] schedule_type + # @param [ScheduleType] schedule_type # @param [Time] send_at The time that Twilio will send the message. Must be in ISO 8601 format. # @param [Boolean] send_as_mms If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. # @param [String] content_variables For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. - # @param [RiskCheck] risk_check + # @param [RiskCheck] risk_check # @param [String] from The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool. # @param [String] body The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages). @@ -60,29 +60,29 @@ def initialize(version, account_sid: nil) # @param [String] content_sid For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources). # @return [MessageInstance] Created MessageInstance def create( - to: nil, - status_callback: :unset, - application_sid: :unset, - max_price: :unset, - provide_feedback: :unset, - attempt: :unset, - validity_period: :unset, - force_delivery: :unset, - content_retention: :unset, - address_retention: :unset, - smart_encoded: :unset, - persistent_action: :unset, - traffic_type: :unset, - shorten_urls: :unset, - schedule_type: :unset, - send_at: :unset, - send_as_mms: :unset, - content_variables: :unset, - risk_check: :unset, - from: :unset, - messaging_service_sid: :unset, - body: :unset, - media_url: :unset, + to: nil, + status_callback: :unset, + application_sid: :unset, + max_price: :unset, + provide_feedback: :unset, + attempt: :unset, + validity_period: :unset, + force_delivery: :unset, + content_retention: :unset, + address_retention: :unset, + smart_encoded: :unset, + persistent_action: :unset, + traffic_type: :unset, + shorten_urls: :unset, + schedule_type: :unset, + send_at: :unset, + send_as_mms: :unset, + content_variables: :unset, + risk_check: :unset, + from: :unset, + messaging_service_sid: :unset, + body: :unset, + media_url: :unset, content_sid: :unset ) @@ -114,11 +114,11 @@ def create( }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - - + + + + + payload = @version.create('POST', @uri, data: data, headers: headers) MessageInstance.new( @version, @@ -127,61 +127,61 @@ def create( ) end - ## - # Create the MessageInstance - # @param [String] to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`. - # @param [String] status_callback The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). - # @param [String] application_sid The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored. - # @param [Float] max_price [OBSOLETE] This parameter will no longer have any effect as of 2024-06-03. - # @param [Boolean] provide_feedback Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`. - # @param [String] attempt Total number of attempts made (including this request) to send the message regardless of the provider used - # @param [String] validity_period The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `36000`. Default value is `36000`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) - # @param [Boolean] force_delivery Reserved - # @param [ContentRetention] content_retention - # @param [AddressRetention] address_retention - # @param [Boolean] smart_encoded Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. - # @param [Array[String]] persistent_action Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). - # @param [TrafficType] traffic_type - # @param [Boolean] shorten_urls For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. - # @param [ScheduleType] schedule_type - # @param [Time] send_at The time that Twilio will send the message. Must be in ISO 8601 format. - # @param [Boolean] send_as_mms If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. - # @param [String] content_variables For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. - # @param [RiskCheck] risk_check - # @param [String] from The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. - # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool. - # @param [String] body The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages). - # @param [Array[String]] media_url The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/messaging/guides/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply. - # @param [String] content_sid For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources). - # @return [MessageInstance] Created MessageInstance - def create_with_metadata( - to: nil, - status_callback: :unset, - application_sid: :unset, - max_price: :unset, - provide_feedback: :unset, - attempt: :unset, - validity_period: :unset, - force_delivery: :unset, - content_retention: :unset, - address_retention: :unset, - smart_encoded: :unset, - persistent_action: :unset, - traffic_type: :unset, - shorten_urls: :unset, - schedule_type: :unset, - send_at: :unset, - send_as_mms: :unset, - content_variables: :unset, - risk_check: :unset, - from: :unset, - messaging_service_sid: :unset, - body: :unset, - media_url: :unset, - content_sid: :unset - ) - - data = Twilio::Values.of({ + ## + # Create the MessageInstanceMetadata + # @param [String] to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`. + # @param [String] status_callback The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). + # @param [String] application_sid The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored. + # @param [Float] max_price [OBSOLETE] This parameter will no longer have any effect as of 2024-06-03. + # @param [Boolean] provide_feedback Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`. + # @param [String] attempt Total number of attempts made (including this request) to send the message regardless of the provider used + # @param [String] validity_period The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `36000`. Default value is `36000`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) + # @param [Boolean] force_delivery Reserved + # @param [ContentRetention] content_retention + # @param [AddressRetention] address_retention + # @param [Boolean] smart_encoded Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. + # @param [Array[String]] persistent_action Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). + # @param [TrafficType] traffic_type + # @param [Boolean] shorten_urls For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. + # @param [ScheduleType] schedule_type + # @param [Time] send_at The time that Twilio will send the message. Must be in ISO 8601 format. + # @param [Boolean] send_as_mms If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. + # @param [String] content_variables For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + # @param [RiskCheck] risk_check + # @param [String] from The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. + # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool. + # @param [String] body The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages). + # @param [Array[String]] media_url The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/messaging/guides/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply. + # @param [String] content_sid For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources). + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + to: nil, + status_callback: :unset, + application_sid: :unset, + max_price: :unset, + provide_feedback: :unset, + attempt: :unset, + validity_period: :unset, + force_delivery: :unset, + content_retention: :unset, + address_retention: :unset, + smart_encoded: :unset, + persistent_action: :unset, + traffic_type: :unset, + shorten_urls: :unset, + schedule_type: :unset, + send_at: :unset, + send_as_mms: :unset, + content_variables: :unset, + risk_check: :unset, + from: :unset, + messaging_service_sid: :unset, + body: :unset, + media_url: :unset, + content_sid: :unset + ) + + data = Twilio::Values.of({ 'To' => to, 'StatusCallback' => status_callback, 'ApplicationSid' => application_sid, @@ -193,42 +193,42 @@ def create_with_metadata( 'ContentRetention' => content_retention, 'AddressRetention' => address_retention, 'SmartEncoded' => smart_encoded, - 'PersistentAction' => Twilio.serialize_list(persistent_action) { |e| e }, + 'PersistentAction' => Twilio.serialize_list(persistent_action) { |e| e }, 'TrafficType' => traffic_type, 'ShortenUrls' => shorten_urls, 'ScheduleType' => schedule_type, - 'SendAt' => Twilio.serialize_iso8601_datetime(send_at), + 'SendAt' => Twilio.serialize_iso8601_datetime(send_at), 'SendAsMms' => send_as_mms, 'ContentVariables' => content_variables, 'RiskCheck' => risk_check, 'From' => from, 'MessagingServiceSid' => messaging_service_sid, 'Body' => body, - 'MediaUrl' => Twilio.serialize_list(media_url) { |e| e }, + 'MediaUrl' => Twilio.serialize_list(media_url) { |e| e }, 'ContentSid' => content_sid, - }) - - headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - + }) - response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) - message_instance = MessageInstance.new( - @version, - response.body, - account_sid: @solution[:account_sid], + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], ) - MessageInstanceMetadata.new( - @version, - message_instance, - response.headers, - response.status_code - ) - end - + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInstance records from the API as a list. # Unlike stream(), this operation is eager and will load `limit` records into @@ -257,23 +257,6 @@ def list(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, ).entries end - def list_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, limit: nil, page_size: nil) - limits = @version.read_limits(limit, page_size) - params = Twilio::Values.of({ - 'To' => to, - 'From' => from, - 'DateSent' => Twilio.serialize_iso8601_datetime(date_sent), - 'DateSent<' => Twilio.serialize_iso8601_datetime(date_sent_before), - 'DateSent>' => Twilio.serialize_iso8601_datetime(date_sent_after), - 'PageSize' => page_size, - }) - headers = Twilio::Values.of({}) - - response = @version.page('GET', @uri, params: params, headers: headers) - - MessagePageMetadata.new(@version, response, @solution, limits[:limit]) - end - ## # Streams Instance records from the API as an Enumerable. # This operation lazily loads records as efficiently as possible until the limit @@ -304,6 +287,38 @@ def stream(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @param [String] to Filter by recipient. For example: Set this parameter to `+15558881111` to retrieve a list of Message resources sent to `+15558881111`. + # @param [String] from Filter by sender. For example: Set this parameter to `+15552229999` to retrieve a list of Message resources sent by `+15552229999`. + # @param [Time] date_sent Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + # @param [Time] date_sent_before Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + # @param [Time] date_sent_after Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + # @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_with_metadata(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, date_sent_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'DateSent' => Twilio.serialize_iso8601_datetime(date_sent), + 'DateSent<' => Twilio.serialize_iso8601_datetime(date_sent_before), + 'DateSent>' => Twilio.serialize_iso8601_datetime(date_sent_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -342,11 +357,14 @@ def page(to: :unset, from: :unset, date_sent: :unset, date_sent_before: :unset, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) MessagePage.new(@version, response, @solution) end + ## # Retrieve a single page of MessageInstance records from the API. # Request is executed immediately. @@ -359,7 +377,7 @@ def get_page(target_url) ) MessagePage.new(@version, response, @solution) end - + # Provide a user friendly representation @@ -393,23 +411,30 @@ def initialize(version, account_sid, sid) def delete headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - @version.delete('DELETE', @uri, headers: headers) + + + + @version.delete('DELETE', @uri, headers: headers) end - ## - # Delete the MessageInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete_with_metadata - - headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - + ## + # Delete the MessageInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata - @version.delete('DELETE', @uri, headers: headers) - end + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code) + end ## # Fetch the MessageInstance @@ -417,11 +442,11 @@ def delete_with_metadata def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - - + + + + + payload = @version.fetch('GET', @uri, headers: headers) MessageInstance.new( @version, @@ -431,39 +456,39 @@ def fetch ) end - ## - # Fetch the MessageInstance - # @return [MessageInstance] Fetched MessageInstance - def fetch_with_metadata - - headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - + ## + # Fetch the MessageInstanceMetadata + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata - response = @version.fetch_with_metadata('GET', @uri, headers: headers) - message_instance = MessageInstance.new( - @version, - response.body, - account_sid: @solution[:account_sid], - sid: @solution[:sid], + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], ) - MessageInstanceMetadata.new( - @version, - message_instance, - response.headers, - response.status_code - ) - end + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end ## # Update the MessageInstance # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string - # @param [UpdateStatus] status + # @param [UpdateStatus] status # @return [MessageInstance] Updated MessageInstance def update( - body: :unset, + body: :unset, status: :unset ) @@ -473,11 +498,11 @@ def update( }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - - + + + + + payload = @version.update('POST', @uri, data: data, headers: headers) MessageInstance.new( @version, @@ -487,41 +512,41 @@ def update( ) end - ## - # Update the MessageInstance - # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string - # @param [UpdateStatus] status - # @return [MessageInstance] Updated MessageInstance - def update_with_metadata( - body: :unset, - status: :unset - ) + ## + # Update the MessageInstanceMetadata + # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string + # @param [UpdateStatus] status + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + body: :unset, + status: :unset + ) - data = Twilio::Values.of({ + data = Twilio::Values.of({ 'Body' => body, 'Status' => status, - }) - - headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) - - - - + }) - response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) - message_instance = MessageInstance.new( - @version, - response.body, - account_sid: @solution[:account_sid], - sid: @solution[:sid], + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], ) - MessageInstanceMetadata.new( - @version, - message_instance, - response.headers, - response.status_code - ) - end + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end ## # Access the feedback @@ -569,6 +594,45 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInstance] message_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def message + @message_instance + end + + def to_s + "" + end + end + + class MessageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_instance = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_instance + @instance + end + end + class MessagePage < Page ## # Initialize the MessagePage @@ -599,34 +663,52 @@ def to_s end class MessagePageMetadata < PageMetadata - attr_reader :message_page - - def initialize(version, response, solution, limit) - super(version, response) - @message_page = [] - @limit = limit - number_of_records = @payload.body["page_size"] - key = get_key(@payload.body) - while( limit != :unset && number_of_records <= limit ) - next_page = self.next_page - @message_page << MessageListResponse.new(version, next_page, key) - break unless next_page - number_of_records += next_page.body["page_size"] - end - # Path Solution - @solution = solution - end + attr_reader :message_page - def each - @message_page.each do |record| - yield record + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution end - end - def to_s - '' - end + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance @@ -639,9 +721,9 @@ class MessageInstance < InstanceResource # @return [MessageInstance] MessageInstance def initialize(version, payload , account_sid: nil, sid: nil) super(version) - + # Marshaled Properties - @properties = { + @properties = { 'body' => payload['body'], 'num_segments' => payload['num_segments'], 'direction' => payload['direction'], @@ -679,127 +761,127 @@ def context end @instance_context end - + ## # @return [String] The text content of the message def body @properties['body'] end - + ## # @return [String] The number of segments that make up the complete message. SMS message bodies that exceed the [character limit](https://www.twilio.com/docs/glossary/what-sms-character-limit) are segmented and charged as multiple messages. Note: For messages sent via a Messaging Service, `num_segments` is initially `0`, since a sender hasn't yet been assigned. def num_segments @properties['num_segments'] end - + ## - # @return [Direction] + # @return [Direction] def direction @properties['direction'] end - + ## # @return [String] The sender's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). For incoming messages, this is the number or channel address of the sender. For outgoing messages, this value is a Twilio phone number, alphanumeric sender ID, short code, or channel address from which the message is sent. def from @properties['from'] end - + ## # @return [String] The recipient's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format) or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g. `whatsapp:+15552229999`) def to @properties['to'] end - + ## # @return [Time] The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was last updated def date_updated @properties['date_updated'] end - + ## # @return [String] The amount billed for the message in the currency specified by `price_unit`. The `price` is populated after the message has been sent/received, and may not be immediately availalble. View the [Pricing page](https://www.twilio.com/en-us/pricing) for more details. def price @properties['price'] end - + ## # @return [String] The description of the `error_code` if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the `error_code` and `error_message` fields programmatically. def error_message @properties['error_message'] end - + ## # @return [String] The URI of the Message resource, relative to `https://api.twilio.com`. def uri @properties['uri'] end - + ## # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource def account_sid @properties['account_sid'] end - + ## # @return [String] The number of media files associated with the Message resource. def num_media @properties['num_media'] end - + ## - # @return [Status] + # @return [Status] def status @properties['status'] end - + ## # @return [String] The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. A unique default value is assigned if a Messaging Service is not used. def messaging_service_sid @properties['messaging_service_sid'] end - + ## # @return [String] The unique, Twilio-provided string that identifies the Message resource. def sid @properties['sid'] end - + ## # @return [Time] The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message was sent. For an outgoing message, this is when Twilio sent the message. For an incoming message, this is when Twilio sent the HTTP request to your incoming message webhook URL. def date_sent @properties['date_sent'] end - + ## # @return [Time] The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was created def date_created @properties['date_created'] end - + ## # @return [String] The [error code](https://www.twilio.com/docs/api/errors) returned if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the `error_code` and `error_message` fields programmatically. def error_code @properties['error_code'] end - + ## # @return [String] The currency in which `price` is measured, in [ISO 4127](https://www.iso.org/iso/home/standards/currency_codes.htm) format (e.g. `usd`, `eur`, `jpy`). def price_unit @properties['price_unit'] end - + ## # @return [String] The API version used to process the Message def api_version @properties['api_version'] end - + ## # @return [Hash] A list of related resources identified by their URIs relative to `https://api.twilio.com` def subresource_uris @properties['subresource_uris'] end - + ## # Delete the MessageInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -808,14 +890,6 @@ def delete context.delete end - ## - # Delete the MessageInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete_with_metadata - - context.delete - end - ## # Fetch the MessageInstance # @return [MessageInstance] Fetched MessageInstance @@ -824,46 +898,22 @@ def fetch context.fetch end - ## - # Fetch the MessageInstance - # @return [MessageInstance] Fetched MessageInstance - def fetch_with_metadata - - context.fetch - end - ## # Update the MessageInstance # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string - # @param [UpdateStatus] status + # @param [UpdateStatus] status # @return [MessageInstance] Updated MessageInstance def update( - body: :unset, + body: :unset, status: :unset ) context.update( - body: body, - status: status, + body: body, + status: status, ) end - ## - # Update the MessageInstance - # @param [String] body The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string - # @param [UpdateStatus] status - # @return [MessageInstance] Updated MessageInstance - def update_with_metadata( - body: :unset, - status: :unset - ) - - context.update( - body: body, - status: status, - ) - end - ## # Access the feedback # @return [feedback] feedback @@ -893,61 +943,6 @@ def inspect end end - class MessageInstanceMetadata < InstanceResourceMetadata - ## - # Initializes a new MessageInstanceMetadata. - # @param [Version] version Version that contains the resource - # @param [MessageInstance] message_instance The instance associated with the metadata. - # @param [Hash] headers Header object with response headers. - # @param [Integer] status_code The HTTP status code of the response. - # @return [MessageInstanceMetadata] The initialized instance with metadata. - def initialize(version, message_instance, headers, status_code) - super(version, headers, status_code) - @message_instance = message_instance - end - - def instance - @message_instance - end - - def headers - @headers - end - - def status_code - @status_code - end - - def to_s - "" - end - end - - class MessageListResponse - # @param [Array] instance - # @param [Hash{String => Object}] headers - # @param [Integer] status_code - def initialize(version, payload, key) - @instance = payload.body[key].map do |message_data| - MessageInstance.new(version, message_data) - end - @headers = payload.headers - @status_code = payload.status_code - end - - def instance - @instance - end - - def headers - @headers - end - - def status_code - @status_code - end - end - end end end diff --git a/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb b/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb index cf9689596..9d1cae6fb 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb @@ -60,6 +60,39 @@ def create( ) end + ## + # Create the FeedbackInstanceMetadata + # @param [Outcome] outcome + # @return [FeedbackInstance] Created FeedbackInstance + def create_with_metadata( + outcome: :unset + ) + + data = Twilio::Values.of({ + 'Outcome' => outcome, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + feedback_instance = FeedbackInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + message_sid: @solution[:message_sid], + ) + FeedbackInstanceMetadata.new( + @version, + feedback_instance, + response.headers, + response.status_code + ) + end + @@ -97,6 +130,54 @@ def to_s '' end end + + class FeedbackPageMetadata < PageMetadata + attr_reader :feedback_page + + def initialize(version, response, solution, limit) + super(version, response) + @feedback_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @feedback_page << FeedbackListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @feedback_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FeedbackListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @feedback = payload.body[key].map do |data| + FeedbackInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def feedback + @feedback + end + end + class FeedbackInstance < InstanceResource ## # Initialize the FeedbackInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/message/media.rb b/lib/twilio-ruby/rest/api/v2010/account/message/media.rb index 2c61dd88d..571716b03 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/message/media.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/message/media.rb @@ -84,6 +84,34 @@ def stream(date_created: :unset, date_created_before: :unset, date_created_after @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MediaPageMetadata records from the API as a list. + # @param [Time] date_created Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + # @param [Time] date_created_before Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + # @param [Time] date_created_after Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + # @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_with_metadata(date_created: :unset, date_created_before: :unset, date_created_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateCreated<' => Twilio.serialize_iso8601_datetime(date_created_before), + 'DateCreated>' => Twilio.serialize_iso8601_datetime(date_created_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MediaPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MediaInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -174,7 +202,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MediaInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + media_instance = MediaInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MediaInstanceMetadata.new(@version, media_instance, response.headers, response.status_code) end ## @@ -198,6 +245,33 @@ def fetch ) end + ## + # Fetch the MediaInstanceMetadata + # @return [MediaInstance] Fetched MediaInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + media_instance = MediaInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + message_sid: @solution[:message_sid], + sid: @solution[:sid], + ) + MediaInstanceMetadata.new( + @version, + media_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -214,6 +288,45 @@ def inspect end end + class MediaInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MediaInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MediaInstance] media_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MediaInstanceMetadata] The initialized instance with metadata. + def initialize(version, media_instance, headers, status_code) + super(version, headers, status_code) + @media_instance = media_instance + end + + def media + @media_instance + end + + def to_s + "" + end + end + + class MediaListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @media_instance = payload.body[key].map do |data| + MediaInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def media_instance + @instance + end + end + class MediaPage < Page ## # Initialize the MediaPage @@ -242,6 +355,54 @@ def to_s '' end end + + class MediaPageMetadata < PageMetadata + attr_reader :media_page + + def initialize(version, response, solution, limit) + super(version, response) + @media_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @media_page << MediaListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @media_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MediaListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @media = payload.body[key].map do |data| + MediaInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def media + @media + end + end + class MediaInstance < InstanceResource ## # Initialize the MediaInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/new_key.rb b/lib/twilio-ruby/rest/api/v2010/account/new_key.rb index 7344f26bf..f5cd8ecde 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/new_key.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/new_key.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the NewKeyInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [NewKeyInstance] Created NewKeyInstance + def create_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + newKey_instance = NewKeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + NewKeyInstanceMetadata.new( + @version, + newKey_instance, + response.headers, + response.status_code + ) + end + @@ -95,6 +127,54 @@ def to_s '' end end + + class NewKeyPageMetadata < PageMetadata + attr_reader :new_key_page + + def initialize(version, response, solution, limit) + super(version, response) + @new_key_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @new_key_page << NewKeyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @new_key_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NewKeyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_key = payload.body[key].map do |data| + NewKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_key + @new_key + end + end + class NewKeyInstance < InstanceResource ## # Initialize the NewKeyInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/new_signing_key.rb b/lib/twilio-ruby/rest/api/v2010/account/new_signing_key.rb index a652e55a5..b856da000 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/new_signing_key.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/new_signing_key.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the NewSigningKeyInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [NewSigningKeyInstance] Created NewSigningKeyInstance + def create_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + newSigningKey_instance = NewSigningKeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + NewSigningKeyInstanceMetadata.new( + @version, + newSigningKey_instance, + response.headers, + response.status_code + ) + end + @@ -95,6 +127,54 @@ def to_s '' end end + + class NewSigningKeyPageMetadata < PageMetadata + attr_reader :new_signing_key_page + + def initialize(version, response, solution, limit) + super(version, response) + @new_signing_key_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @new_signing_key_page << NewSigningKeyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @new_signing_key_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NewSigningKeyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_signing_key = payload.body[key].map do |data| + NewSigningKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_signing_key + @new_signing_key + end + end + class NewSigningKeyInstance < InstanceResource ## # Initialize the NewSigningKeyInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/notification.rb b/lib/twilio-ruby/rest/api/v2010/account/notification.rb index a1143d59c..9aa8bc871 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/notification.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/notification.rb @@ -87,6 +87,36 @@ def stream(log: :unset, message_date: :unset, message_date_before: :unset, messa @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists NotificationPageMetadata records from the API as a list. + # @param [String] log Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read. + # @param [Date] message_date Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date. + # @param [Date] message_date_before Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date. + # @param [Date] message_date_after Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date. + # @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_with_metadata(log: :unset, message_date: :unset, message_date_before: :unset, message_date_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Log' => log, + 'MessageDate' => Twilio.serialize_iso8601_date(message_date), + 'MessageDate<' => Twilio.serialize_iso8601_date(message_date_before), + 'MessageDate>' => Twilio.serialize_iso8601_date(message_date_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + NotificationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields NotificationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -189,6 +219,32 @@ def fetch ) end + ## + # Fetch the NotificationInstanceMetadata + # @return [NotificationInstance] Fetched NotificationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + notification_instance = NotificationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + NotificationInstanceMetadata.new( + @version, + notification_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -205,6 +261,45 @@ def inspect end end + class NotificationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NotificationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NotificationInstance] notification_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NotificationInstanceMetadata] The initialized instance with metadata. + def initialize(version, notification_instance, headers, status_code) + super(version, headers, status_code) + @notification_instance = notification_instance + end + + def notification + @notification_instance + end + + def to_s + "" + end + end + + class NotificationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification_instance = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification_instance + @instance + end + end + class NotificationPage < Page ## # Initialize the NotificationPage @@ -233,6 +328,54 @@ def to_s '' end end + + class NotificationPageMetadata < PageMetadata + attr_reader :notification_page + + def initialize(version, response, solution, limit) + super(version, response) + @notification_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @notification_page << NotificationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @notification_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NotificationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification + @notification + end + end + class NotificationInstance < InstanceResource ## # Initialize the NotificationInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb b/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb index 0a03300ef..f903d5040 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb @@ -79,6 +79,32 @@ def stream(phone_number: :unset, friendly_name: :unset, limit: nil, page_size: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists OutgoingCallerIdPageMetadata records from the API as a list. + # @param [String] phone_number The phone number of the OutgoingCallerId resources to read. + # @param [String] friendly_name The string that identifies the OutgoingCallerId resources to read. + # @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_with_metadata(phone_number: :unset, friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + OutgoingCallerIdPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields OutgoingCallerIdInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -166,7 +192,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the OutgoingCallerIdInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + outgoingCallerId_instance = OutgoingCallerIdInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + OutgoingCallerIdInstanceMetadata.new(@version, outgoingCallerId_instance, response.headers, response.status_code) end ## @@ -189,6 +234,32 @@ def fetch ) end + ## + # Fetch the OutgoingCallerIdInstanceMetadata + # @return [OutgoingCallerIdInstance] Fetched OutgoingCallerIdInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + outgoingCallerId_instance = OutgoingCallerIdInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + OutgoingCallerIdInstanceMetadata.new( + @version, + outgoingCallerId_instance, + response.headers, + response.status_code + ) + end + ## # Update the OutgoingCallerIdInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -216,6 +287,39 @@ def update( ) end + ## + # Update the OutgoingCallerIdInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [OutgoingCallerIdInstance] Updated OutgoingCallerIdInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + outgoingCallerId_instance = OutgoingCallerIdInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + OutgoingCallerIdInstanceMetadata.new( + @version, + outgoingCallerId_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -232,6 +336,45 @@ def inspect end end + class OutgoingCallerIdInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OutgoingCallerIdInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OutgoingCallerIdInstance] outgoing_caller_id_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OutgoingCallerIdInstanceMetadata] The initialized instance with metadata. + def initialize(version, outgoing_caller_id_instance, headers, status_code) + super(version, headers, status_code) + @outgoing_caller_id_instance = outgoing_caller_id_instance + end + + def outgoing_caller_id + @outgoing_caller_id_instance + end + + def to_s + "" + end + end + + class OutgoingCallerIdListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @outgoing_caller_id_instance = payload.body[key].map do |data| + OutgoingCallerIdInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def outgoing_caller_id_instance + @instance + end + end + class OutgoingCallerIdPage < Page ## # Initialize the OutgoingCallerIdPage @@ -260,6 +403,54 @@ def to_s '' end end + + class OutgoingCallerIdPageMetadata < PageMetadata + attr_reader :outgoing_caller_id_page + + def initialize(version, response, solution, limit) + super(version, response) + @outgoing_caller_id_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @outgoing_caller_id_page << OutgoingCallerIdListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @outgoing_caller_id_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OutgoingCallerIdListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @outgoing_caller_id = payload.body[key].map do |data| + OutgoingCallerIdInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def outgoing_caller_id + @outgoing_caller_id + end + end + class OutgoingCallerIdInstance < InstanceResource ## # Initialize the OutgoingCallerIdInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/queue.rb b/lib/twilio-ruby/rest/api/v2010/account/queue.rb index 4683116a7..285715497 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/queue.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/queue.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the QueueInstanceMetadata + # @param [String] friendly_name A descriptive string that you created to describe this resource. It can be up to 64 characters long. + # @param [String] max_size The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000. + # @return [QueueInstance] Created QueueInstance + def create_with_metadata( + friendly_name: nil, + max_size: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'MaxSize' => max_size, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + queue_instance = QueueInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + QueueInstanceMetadata.new( + @version, + queue_instance, + response.headers, + response.status_code + ) + end + ## # Lists QueueInstance records from the API as a list. @@ -100,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists QueuePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + QueuePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields QueueInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the QueueInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + queue_instance = QueueInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + QueueInstanceMetadata.new(@version, queue_instance, response.headers, response.status_code) end ## @@ -207,6 +283,32 @@ def fetch ) end + ## + # Fetch the QueueInstanceMetadata + # @return [QueueInstance] Fetched QueueInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + queue_instance = QueueInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + QueueInstanceMetadata.new( + @version, + queue_instance, + response.headers, + response.status_code + ) + end + ## # Update the QueueInstance # @param [String] friendly_name A descriptive string that you created to describe this resource. It can be up to 64 characters long. @@ -237,6 +339,42 @@ def update( ) end + ## + # Update the QueueInstanceMetadata + # @param [String] friendly_name A descriptive string that you created to describe this resource. It can be up to 64 characters long. + # @param [String] max_size The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000. + # @return [QueueInstance] Updated QueueInstance + def update_with_metadata( + friendly_name: :unset, + max_size: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'MaxSize' => max_size, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + queue_instance = QueueInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + QueueInstanceMetadata.new( + @version, + queue_instance, + response.headers, + response.status_code + ) + end + ## # Access the members # @return [MemberList] @@ -272,6 +410,45 @@ def inspect end end + class QueueInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new QueueInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}QueueInstance] queue_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [QueueInstanceMetadata] The initialized instance with metadata. + def initialize(version, queue_instance, headers, status_code) + super(version, headers, status_code) + @queue_instance = queue_instance + end + + def queue + @queue_instance + end + + def to_s + "" + end + end + + class QueueListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @queue_instance = payload.body[key].map do |data| + QueueInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def queue_instance + @instance + end + end + class QueuePage < Page ## # Initialize the QueuePage @@ -300,6 +477,54 @@ def to_s '' end end + + class QueuePageMetadata < PageMetadata + attr_reader :queue_page + + def initialize(version, response, solution, limit) + super(version, response) + @queue_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @queue_page << QueueListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @queue_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class QueueListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @queue = payload.body[key].map do |data| + QueueInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def queue + @queue + end + end + class QueueInstance < InstanceResource ## # Initialize the QueueInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb b/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb index 33b3cc9cb..90bfa1587 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MemberPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MemberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MemberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +190,33 @@ def fetch ) end + ## + # Fetch the MemberInstanceMetadata + # @return [MemberInstance] Fetched MemberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + queue_sid: @solution[:queue_sid], + call_sid: @solution[:call_sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Update the MemberInstance # @param [String] url The absolute URL of the Queue resource. @@ -199,6 +248,43 @@ def update( ) end + ## + # Update the MemberInstanceMetadata + # @param [String] url The absolute URL of the Queue resource. + # @param [String] method How to pass the update request data. Can be `GET` or `POST` and the default is `POST`. `POST` sends the data as encoded form data and `GET` sends the data as query parameters. + # @return [MemberInstance] Updated MemberInstance + def update_with_metadata( + url: nil, + method: :unset + ) + + data = Twilio::Values.of({ + 'Url' => url, + 'Method' => method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + queue_sid: @solution[:queue_sid], + call_sid: @solution[:call_sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -215,6 +301,45 @@ def inspect end end + class MemberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MemberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MemberInstance] member_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MemberInstanceMetadata] The initialized instance with metadata. + def initialize(version, member_instance, headers, status_code) + super(version, headers, status_code) + @member_instance = member_instance + end + + def member + @member_instance + end + + def to_s + "" + end + end + + class MemberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member_instance = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member_instance + @instance + end + end + class MemberPage < Page ## # Initialize the MemberPage @@ -243,6 +368,54 @@ def to_s '' end end + + class MemberPageMetadata < PageMetadata + attr_reader :member_page + + def initialize(version, response, solution, limit) + super(version, response) + @member_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @member_page << MemberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @member_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MemberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member + @member + end + end + class MemberInstance < InstanceResource ## # Initialize the MemberInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/recording.rb b/lib/twilio-ruby/rest/api/v2010/account/recording.rb index be9ebf5e1..707552b0b 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/recording.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/recording.rb @@ -95,6 +95,40 @@ def stream(date_created: :unset, date_created_before: :unset, date_created_after @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RecordingPageMetadata records from the API as a list. + # @param [Time] date_created Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date. + # @param [Time] date_created_before Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date. + # @param [Time] date_created_after Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date. + # @param [String] call_sid The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources 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 + # 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_with_metadata(date_created: :unset, date_created_before: :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) + params = Twilio::Values.of({ + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateCreated<' => Twilio.serialize_iso8601_datetime(date_created_before), + 'DateCreated>' => Twilio.serialize_iso8601_datetime(date_created_after), + 'CallSid' => call_sid, + 'ConferenceSid' => conference_sid, + 'IncludeSoftDeleted' => include_soft_deleted, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RecordingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RecordingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -192,7 +226,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RecordingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new(@version, recording_instance, response.headers, response.status_code) end ## @@ -221,6 +274,38 @@ def fetch( ) end + ## + # Fetch the RecordingInstanceMetadata + # @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_with_metadata( + include_soft_deleted: :unset + ) + + params = Twilio::Values.of({ + 'IncludeSoftDeleted' => include_soft_deleted, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Access the add_on_results # @return [AddOnResultList] @@ -275,6 +360,45 @@ def inspect end end + class RecordingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RecordingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RecordingInstance] recording_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RecordingInstanceMetadata] The initialized instance with metadata. + def initialize(version, recording_instance, headers, status_code) + super(version, headers, status_code) + @recording_instance = recording_instance + end + + def recording + @recording_instance + end + + def to_s + "" + end + end + + class RecordingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_instance = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_instance + @instance + end + end + class RecordingPage < Page ## # Initialize the RecordingPage @@ -303,6 +427,54 @@ def to_s '' end end + + class RecordingPageMetadata < PageMetadata + attr_reader :recording_page + + def initialize(version, response, solution, limit) + super(version, response) + @recording_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @recording_page << RecordingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @recording_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording + @recording + end + end + class RecordingInstance < InstanceResource ## # Initialize the RecordingInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb b/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb index a28a9f579..d38dbc773 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AddOnResultPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AddOnResultPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AddOnResultInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -157,7 +179,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AddOnResultInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + addOnResult_instance = AddOnResultInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AddOnResultInstanceMetadata.new(@version, addOnResult_instance, response.headers, response.status_code) end ## @@ -181,6 +222,33 @@ def fetch ) end + ## + # Fetch the AddOnResultInstanceMetadata + # @return [AddOnResultInstance] Fetched AddOnResultInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + addOnResult_instance = AddOnResultInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + reference_sid: @solution[:reference_sid], + sid: @solution[:sid], + ) + AddOnResultInstanceMetadata.new( + @version, + addOnResult_instance, + response.headers, + response.status_code + ) + end + ## # Access the payloads # @return [PayloadList] @@ -216,6 +284,45 @@ def inspect end end + class AddOnResultInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AddOnResultInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AddOnResultInstance] add_on_result_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AddOnResultInstanceMetadata] The initialized instance with metadata. + def initialize(version, add_on_result_instance, headers, status_code) + super(version, headers, status_code) + @add_on_result_instance = add_on_result_instance + end + + def add_on_result + @add_on_result_instance + end + + def to_s + "" + end + end + + class AddOnResultListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @add_on_result_instance = payload.body[key].map do |data| + AddOnResultInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def add_on_result_instance + @instance + end + end + class AddOnResultPage < Page ## # Initialize the AddOnResultPage @@ -244,6 +351,54 @@ def to_s '' end end + + class AddOnResultPageMetadata < PageMetadata + attr_reader :add_on_result_page + + def initialize(version, response, solution, limit) + super(version, response) + @add_on_result_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @add_on_result_page << AddOnResultListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @add_on_result_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AddOnResultListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @add_on_result = payload.body[key].map do |data| + AddOnResultInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def add_on_result + @add_on_result + end + end + class AddOnResultInstance < InstanceResource ## # Initialize the AddOnResultInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload.rb b/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload.rb index 3df65038e..c46beb00f 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload.rb @@ -73,6 +73,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PayloadPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PayloadPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PayloadInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -159,7 +181,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PayloadInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + payload_instance = PayloadInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PayloadInstanceMetadata.new(@version, payload_instance, response.headers, response.status_code) end ## @@ -184,6 +225,34 @@ def fetch ) end + ## + # Fetch the PayloadInstanceMetadata + # @return [PayloadInstance] Fetched PayloadInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + payload_instance = PayloadInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + reference_sid: @solution[:reference_sid], + add_on_result_sid: @solution[:add_on_result_sid], + sid: @solution[:sid], + ) + PayloadInstanceMetadata.new( + @version, + payload_instance, + response.headers, + response.status_code + ) + end + ## # Access the data # @return [DataList] @@ -213,6 +282,45 @@ def inspect end end + class PayloadInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PayloadInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PayloadInstance] payload_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PayloadInstanceMetadata] The initialized instance with metadata. + def initialize(version, payload_instance, headers, status_code) + super(version, headers, status_code) + @payload_instance = payload_instance + end + + def payload + @payload_instance + end + + def to_s + "" + end + end + + class PayloadListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @payload_instance = payload.body[key].map do |data| + PayloadInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def payload_instance + @instance + end + end + class PayloadPage < Page ## # Initialize the PayloadPage @@ -241,6 +349,54 @@ def to_s '' end end + + class PayloadPageMetadata < PageMetadata + attr_reader :payload_page + + def initialize(version, response, solution, limit) + super(version, response) + @payload_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @payload_page << PayloadListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @payload_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PayloadListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @payload = payload.body[key].map do |data| + PayloadInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def payload + @payload + end + end + class PayloadInstance < InstanceResource ## # Initialize the PayloadInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload/data.rb b/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload/data.rb index 7f17cb499..e460621c0 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload/data.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload/data.rb @@ -85,6 +85,34 @@ def fetch ) end + ## + # Fetch the DataInstanceMetadata + # @return [DataInstance] Fetched DataInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + data_instance = DataInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + reference_sid: @solution[:reference_sid], + add_on_result_sid: @solution[:add_on_result_sid], + payload_sid: @solution[:payload_sid], + ) + DataInstanceMetadata.new( + @version, + data_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -101,6 +129,45 @@ def inspect end end + class DataInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DataInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DataInstance] data_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DataInstanceMetadata] The initialized instance with metadata. + def initialize(version, data_instance, headers, status_code) + super(version, headers, status_code) + @data_instance = data_instance + end + + def data + @data_instance + end + + def to_s + "" + end + end + + class DataListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @data_instance = payload.body[key].map do |data| + DataInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def data_instance + @instance + end + end + class DataPage < Page ## # Initialize the DataPage @@ -129,6 +196,54 @@ def to_s '' end end + + class DataPageMetadata < PageMetadata + attr_reader :data_page + + def initialize(version, response, solution, limit) + super(version, response) + @data_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @data_page << DataListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @data_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DataListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @data = payload.body[key].map do |data| + DataInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def data + @data + end + end + class DataInstance < InstanceResource ## # Initialize the DataInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb b/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb index 67c6d0259..d9557a124 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TranscriptionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TranscriptionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TranscriptionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TranscriptionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + transcription_instance = TranscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TranscriptionInstanceMetadata.new(@version, transcription_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the TranscriptionInstanceMetadata + # @return [TranscriptionInstance] Fetched TranscriptionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + transcription_instance = TranscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + recording_sid: @solution[:recording_sid], + sid: @solution[:sid], + ) + TranscriptionInstanceMetadata.new( + @version, + transcription_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -196,6 +264,45 @@ def inspect end end + class TranscriptionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TranscriptionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TranscriptionInstance] transcription_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TranscriptionInstanceMetadata] The initialized instance with metadata. + def initialize(version, transcription_instance, headers, status_code) + super(version, headers, status_code) + @transcription_instance = transcription_instance + end + + def transcription + @transcription_instance + end + + def to_s + "" + end + end + + class TranscriptionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcription_instance = payload.body[key].map do |data| + TranscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcription_instance + @instance + end + end + class TranscriptionPage < Page ## # Initialize the TranscriptionPage @@ -224,6 +331,54 @@ def to_s '' end end + + class TranscriptionPageMetadata < PageMetadata + attr_reader :transcription_page + + def initialize(version, response, solution, limit) + super(version, response) + @transcription_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @transcription_page << TranscriptionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @transcription_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TranscriptionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcription = payload.body[key].map do |data| + TranscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcription + @transcription + end + end + class TranscriptionInstance < InstanceResource ## # Initialize the TranscriptionInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/short_code.rb b/lib/twilio-ruby/rest/api/v2010/account/short_code.rb index 75cc557aa..b11c21453 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/short_code.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/short_code.rb @@ -79,6 +79,32 @@ def stream(friendly_name: :unset, short_code: :unset, limit: nil, page_size: nil @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ShortCodePageMetadata records from the API as a list. + # @param [String] friendly_name The string that identifies the ShortCode resources to read. + # @param [String] short_code Only show the ShortCode resources that match this pattern. You can specify partial numbers and use '*' as a wildcard for any digit. + # @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_with_metadata(friendly_name: :unset, short_code: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'ShortCode' => short_code, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ShortCodePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ShortCodeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -177,6 +203,32 @@ def fetch ) end + ## + # Fetch the ShortCodeInstanceMetadata + # @return [ShortCodeInstance] Fetched ShortCodeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + shortCode_instance = ShortCodeInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ShortCodeInstanceMetadata.new( + @version, + shortCode_instance, + response.headers, + response.status_code + ) + end + ## # Update the ShortCodeInstance # @param [String] friendly_name A descriptive string that you created to describe this resource. It can be up to 64 characters long. By default, the `FriendlyName` is the short code. @@ -219,6 +271,54 @@ def update( ) end + ## + # Update the ShortCodeInstanceMetadata + # @param [String] friendly_name A descriptive string that you created to describe this resource. It can be up to 64 characters long. By default, the `FriendlyName` is the short code. + # @param [String] api_version The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. + # @param [String] sms_url The URL we should call when receiving an incoming SMS message to this short code. + # @param [String] sms_method The HTTP method we should use when calling the `sms_url`. Can be: `GET` or `POST`. + # @param [String] sms_fallback_url The URL that we should call if an error occurs while retrieving or executing the TwiML from `sms_url`. + # @param [String] sms_fallback_method The HTTP method that we should use to call the `sms_fallback_url`. Can be: `GET` or `POST`. + # @return [ShortCodeInstance] Updated ShortCodeInstance + def update_with_metadata( + friendly_name: :unset, + api_version: :unset, + sms_url: :unset, + sms_method: :unset, + sms_fallback_url: :unset, + sms_fallback_method: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'ApiVersion' => api_version, + 'SmsUrl' => sms_url, + 'SmsMethod' => sms_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsFallbackMethod' => sms_fallback_method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + shortCode_instance = ShortCodeInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ShortCodeInstanceMetadata.new( + @version, + shortCode_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -235,6 +335,45 @@ def inspect end end + class ShortCodeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ShortCodeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ShortCodeInstance] short_code_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ShortCodeInstanceMetadata] The initialized instance with metadata. + def initialize(version, short_code_instance, headers, status_code) + super(version, headers, status_code) + @short_code_instance = short_code_instance + end + + def short_code + @short_code_instance + end + + def to_s + "" + end + end + + class ShortCodeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @short_code_instance = payload.body[key].map do |data| + ShortCodeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def short_code_instance + @instance + end + end + class ShortCodePage < Page ## # Initialize the ShortCodePage @@ -263,6 +402,54 @@ def to_s '' end end + + class ShortCodePageMetadata < PageMetadata + attr_reader :short_code_page + + def initialize(version, response, solution, limit) + super(version, response) + @short_code_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @short_code_page << ShortCodeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @short_code_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ShortCodeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @short_code = payload.body[key].map do |data| + ShortCodeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def short_code + @short_code + end + end + class ShortCodeInstance < InstanceResource ## # Initialize the ShortCodeInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/signing_key.rb b/lib/twilio-ruby/rest/api/v2010/account/signing_key.rb index 580c69f1f..525851754 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/signing_key.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/signing_key.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SigningKeyPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SigningKeyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SigningKeyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -154,7 +176,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SigningKeyInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + signingKey_instance = SigningKeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SigningKeyInstanceMetadata.new(@version, signingKey_instance, response.headers, response.status_code) end ## @@ -177,6 +218,32 @@ def fetch ) end + ## + # Fetch the SigningKeyInstanceMetadata + # @return [SigningKeyInstance] Fetched SigningKeyInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + signingKey_instance = SigningKeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SigningKeyInstanceMetadata.new( + @version, + signingKey_instance, + response.headers, + response.status_code + ) + end + ## # Update the SigningKeyInstance # @param [String] friendly_name @@ -204,6 +271,39 @@ def update( ) end + ## + # Update the SigningKeyInstanceMetadata + # @param [String] friendly_name + # @return [SigningKeyInstance] Updated SigningKeyInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + signingKey_instance = SigningKeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SigningKeyInstanceMetadata.new( + @version, + signingKey_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -220,6 +320,45 @@ def inspect end end + class SigningKeyInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SigningKeyInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SigningKeyInstance] signing_key_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SigningKeyInstanceMetadata] The initialized instance with metadata. + def initialize(version, signing_key_instance, headers, status_code) + super(version, headers, status_code) + @signing_key_instance = signing_key_instance + end + + def signing_key + @signing_key_instance + end + + def to_s + "" + end + end + + class SigningKeyListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @signing_key_instance = payload.body[key].map do |data| + SigningKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def signing_key_instance + @instance + end + end + class SigningKeyPage < Page ## # Initialize the SigningKeyPage @@ -248,6 +387,54 @@ def to_s '' end end + + class SigningKeyPageMetadata < PageMetadata + attr_reader :signing_key_page + + def initialize(version, response, solution, limit) + super(version, response) + @signing_key_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @signing_key_page << SigningKeyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @signing_key_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SigningKeyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @signing_key = payload.body[key].map do |data| + SigningKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def signing_key + @signing_key + end + end + class SigningKeyInstance < InstanceResource ## # Initialize the SigningKeyInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip.rb b/lib/twilio-ruby/rest/api/v2010/account/sip.rb index 2919e21f4..1520f0464 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip.rb @@ -111,6 +111,54 @@ def to_s '' end end + + class SipPageMetadata < PageMetadata + attr_reader :sip_page + + def initialize(version, response, solution, limit) + super(version, response) + @sip_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sip_page << SipListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sip_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SipListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sip = payload.body[key].map do |data| + SipInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sip + @sip + end + end + class SipInstance < InstanceResource ## # Initialize the SipInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb index 2212f5d86..a5f24007b 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb @@ -59,6 +59,38 @@ def create( ) end + ## + # Create the CredentialListInstanceMetadata + # @param [String] friendly_name A human readable descriptive text that describes the CredentialList, up to 64 characters long. + # @return [CredentialListInstance] Created CredentialListInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credentialList_instance = CredentialListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + CredentialListInstanceMetadata.new( + @version, + credentialList_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialListInstance records from the API as a list. @@ -98,6 +130,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialListPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialListPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialListInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,7 +236,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialListInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credentialList_instance = CredentialListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialListInstanceMetadata.new(@version, credentialList_instance, response.headers, response.status_code) end ## @@ -205,6 +278,32 @@ def fetch ) end + ## + # Fetch the CredentialListInstanceMetadata + # @return [CredentialListInstance] Fetched CredentialListInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credentialList_instance = CredentialListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialListInstanceMetadata.new( + @version, + credentialList_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialListInstance # @param [String] friendly_name A human readable descriptive text for a CredentialList, up to 64 characters long. @@ -232,6 +331,39 @@ def update( ) end + ## + # Update the CredentialListInstanceMetadata + # @param [String] friendly_name A human readable descriptive text for a CredentialList, up to 64 characters long. + # @return [CredentialListInstance] Updated CredentialListInstance + def update_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credentialList_instance = CredentialListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialListInstanceMetadata.new( + @version, + credentialList_instance, + response.headers, + response.status_code + ) + end + ## # Access the credentials # @return [CredentialList] @@ -267,6 +399,45 @@ def inspect end end + class CredentialListInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialListInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialListInstance] credential_list_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialListInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_list_instance, headers, status_code) + super(version, headers, status_code) + @credential_list_instance = credential_list_instance + end + + def credential_list + @credential_list_instance + end + + def to_s + "" + end + end + + class CredentialListListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_list_instance = payload.body[key].map do |data| + CredentialListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_list_instance + @instance + end + end + class CredentialListPage < Page ## # Initialize the CredentialListPage @@ -295,6 +466,54 @@ def to_s '' end end + + class CredentialListPageMetadata < PageMetadata + attr_reader :credential_list_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_list_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_list_page << CredentialListListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_list_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_list = payload.body[key].map do |data| + CredentialListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_list + @credential_list + end + end + class CredentialListInstance < InstanceResource ## # Initialize the CredentialListInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb index 61e85fabf..a0883e84d 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb @@ -64,6 +64,42 @@ def create( ) end + ## + # Create the CredentialInstanceMetadata + # @param [String] username The username that will be passed when authenticating SIP requests. The username should be sent in response to Twilio's challenge of the initial INVITE. It can be up to 32 characters long. + # @param [String] password The password that the username will use when authenticating SIP requests. The password must be a minimum of 12 characters, contain at least 1 digit, and have mixed case. (eg `IWasAtSignal2018`) + # @return [CredentialInstance] Created CredentialInstance + def create_with_metadata( + username: nil, + password: nil + ) + + data = Twilio::Values.of({ + 'Username' => username, + 'Password' => password, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + credential_list_sid: @solution[:credential_list_sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialInstance records from the API as a list. @@ -103,6 +139,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -187,7 +245,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code) end ## @@ -211,6 +288,33 @@ def fetch ) end + ## + # Fetch the CredentialInstanceMetadata + # @return [CredentialInstance] Fetched CredentialInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + credential_list_sid: @solution[:credential_list_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialInstance # @param [String] password The password that the username will use when authenticating SIP requests. The password must be a minimum of 12 characters, contain at least 1 digit, and have mixed case. (eg `IWasAtSignal2018`) @@ -239,6 +343,40 @@ def update( ) end + ## + # Update the CredentialInstanceMetadata + # @param [String] password The password that the username will use when authenticating SIP requests. The password must be a minimum of 12 characters, contain at least 1 digit, and have mixed case. (eg `IWasAtSignal2018`) + # @return [CredentialInstance] Updated CredentialInstance + def update_with_metadata( + password: :unset + ) + + data = Twilio::Values.of({ + 'Password' => password, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + credential_list_sid: @solution[:credential_list_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -255,6 +393,45 @@ def inspect end end + class CredentialInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialInstance] credential_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_instance, headers, status_code) + super(version, headers, status_code) + @credential_instance = credential_instance + end + + def credential + @credential_instance + end + + def to_s + "" + end + end + + class CredentialListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_instance = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_instance + @instance + end + end + class CredentialPage < Page ## # Initialize the CredentialPage @@ -283,6 +460,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb index 72732d04c..fa5b3684e 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb @@ -95,6 +95,74 @@ def create( ) end + ## + # Create the DomainInstanceMetadata + # @param [String] domain_name The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and \\\"-\\\" and must end with `sip.twilio.com`. + # @param [String] friendly_name A descriptive string that you created to describe the resource. It can be up to 64 characters long. + # @param [String] voice_url The URL we should when the domain receives a call. + # @param [String] voice_method The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs while retrieving or executing the TwiML from `voice_url`. + # @param [String] voice_fallback_method The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. + # @param [String] voice_status_callback_url The URL that we should call to pass status parameters (such as call ended) to your application. + # @param [String] voice_status_callback_method The HTTP method we should use to call `voice_status_callback_url`. Can be: `GET` or `POST`. + # @param [Boolean] sip_registration Whether to allow SIP Endpoints to register with the domain to receive calls. Can be `true` or `false`. `true` allows SIP Endpoints to register with the domain to receive calls, `false` does not. + # @param [Boolean] emergency_calling_enabled Whether emergency calling is enabled for the domain. If enabled, allows emergency calls on the domain from phone numbers with validated addresses. + # @param [Boolean] secure Whether secure SIP is enabled for the domain. If enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls to this sip domain. + # @param [String] byoc_trunk_sid The SID of the BYOC Trunk(Bring Your Own Carrier) resource that the Sip Domain will be associated with. + # @param [String] emergency_caller_sid Whether an emergency caller sid is configured for the domain. If present, this phone number will be used as the callback for the emergency call. + # @return [DomainInstance] Created DomainInstance + def create_with_metadata( + domain_name: nil, + friendly_name: :unset, + voice_url: :unset, + voice_method: :unset, + voice_fallback_url: :unset, + voice_fallback_method: :unset, + voice_status_callback_url: :unset, + voice_status_callback_method: :unset, + sip_registration: :unset, + emergency_calling_enabled: :unset, + secure: :unset, + byoc_trunk_sid: :unset, + emergency_caller_sid: :unset + ) + + data = Twilio::Values.of({ + 'DomainName' => domain_name, + 'FriendlyName' => friendly_name, + 'VoiceUrl' => voice_url, + 'VoiceMethod' => voice_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceStatusCallbackUrl' => voice_status_callback_url, + 'VoiceStatusCallbackMethod' => voice_status_callback_method, + 'SipRegistration' => sip_registration, + 'EmergencyCallingEnabled' => emergency_calling_enabled, + 'Secure' => secure, + 'ByocTrunkSid' => byoc_trunk_sid, + 'EmergencyCallerSid' => emergency_caller_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + domain_instance = DomainInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + DomainInstanceMetadata.new( + @version, + domain_instance, + response.headers, + response.status_code + ) + end + ## # Lists DomainInstance records from the API as a list. @@ -134,6 +202,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DomainPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DomainPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DomainInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -220,7 +310,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the DomainInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + domain_instance = DomainInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + DomainInstanceMetadata.new(@version, domain_instance, response.headers, response.status_code) end ## @@ -243,6 +352,32 @@ def fetch ) end + ## + # Fetch the DomainInstanceMetadata + # @return [DomainInstance] Fetched DomainInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + domain_instance = DomainInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + DomainInstanceMetadata.new( + @version, + domain_instance, + response.headers, + response.status_code + ) + end + ## # Update the DomainInstance # @param [String] friendly_name A descriptive string that you created to describe the resource. It can be up to 64 characters long. @@ -306,6 +441,75 @@ def update( ) end + ## + # Update the DomainInstanceMetadata + # @param [String] friendly_name A descriptive string that you created to describe the resource. It can be up to 64 characters long. + # @param [String] voice_fallback_method The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs while retrieving or executing the TwiML requested by `voice_url`. + # @param [String] voice_method The HTTP method we should use to call `voice_url` + # @param [String] voice_status_callback_method The HTTP method we should use to call `voice_status_callback_url`. Can be: `GET` or `POST`. + # @param [String] voice_status_callback_url The URL that we should call to pass status parameters (such as call ended) to your application. + # @param [String] voice_url The URL we should call when the domain receives a call. + # @param [Boolean] sip_registration Whether to allow SIP Endpoints to register with the domain to receive calls. Can be `true` or `false`. `true` allows SIP Endpoints to register with the domain to receive calls, `false` does not. + # @param [String] domain_name The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and \\\"-\\\" and must end with `sip.twilio.com`. + # @param [Boolean] emergency_calling_enabled Whether emergency calling is enabled for the domain. If enabled, allows emergency calls on the domain from phone numbers with validated addresses. + # @param [Boolean] secure Whether secure SIP is enabled for the domain. If enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls to this sip domain. + # @param [String] byoc_trunk_sid The SID of the BYOC Trunk(Bring Your Own Carrier) resource that the Sip Domain will be associated with. + # @param [String] emergency_caller_sid Whether an emergency caller sid is configured for the domain. If present, this phone number will be used as the callback for the emergency call. + # @return [DomainInstance] Updated DomainInstance + def update_with_metadata( + friendly_name: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_status_callback_method: :unset, + voice_status_callback_url: :unset, + voice_url: :unset, + sip_registration: :unset, + domain_name: :unset, + emergency_calling_enabled: :unset, + secure: :unset, + byoc_trunk_sid: :unset, + emergency_caller_sid: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceStatusCallbackMethod' => voice_status_callback_method, + 'VoiceStatusCallbackUrl' => voice_status_callback_url, + 'VoiceUrl' => voice_url, + 'SipRegistration' => sip_registration, + 'DomainName' => domain_name, + 'EmergencyCallingEnabled' => emergency_calling_enabled, + 'Secure' => secure, + 'ByocTrunkSid' => byoc_trunk_sid, + 'EmergencyCallerSid' => emergency_caller_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + domain_instance = DomainInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + DomainInstanceMetadata.new( + @version, + domain_instance, + response.headers, + response.status_code + ) + end + ## # Access the auth # @return [AuthTypesList] @@ -371,6 +575,45 @@ def inspect end end + class DomainInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DomainInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DomainInstance] domain_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DomainInstanceMetadata] The initialized instance with metadata. + def initialize(version, domain_instance, headers, status_code) + super(version, headers, status_code) + @domain_instance = domain_instance + end + + def domain + @domain_instance + end + + def to_s + "" + end + end + + class DomainListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_instance = payload.body[key].map do |data| + DomainInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_instance + @instance + end + end + class DomainPage < Page ## # Initialize the DomainPage @@ -399,6 +642,54 @@ def to_s '' end end + + class DomainPageMetadata < PageMetadata + attr_reader :domain_page + + def initialize(version, response, solution, limit) + super(version, response) + @domain_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @domain_page << DomainListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @domain_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DomainListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain = payload.body[key].map do |data| + DomainInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain + @domain + end + end + class DomainInstance < InstanceResource ## # Initialize the DomainInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types.rb index 1510431a9..34a564d47 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types.rb @@ -87,6 +87,54 @@ def to_s '' end end + + class AuthTypesPageMetadata < PageMetadata + attr_reader :auth_types_page + + def initialize(version, response, solution, limit) + super(version, response) + @auth_types_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @auth_types_page << AuthTypesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @auth_types_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthTypesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_types = payload.body[key].map do |data| + AuthTypesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_types + @auth_types + end + end + class AuthTypesInstance < InstanceResource ## # Initialize the AuthTypesInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls.rb index 14a8ce7b0..442baa89c 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls.rb @@ -100,6 +100,54 @@ def to_s '' end end + + class AuthTypeCallsPageMetadata < PageMetadata + attr_reader :auth_type_calls_page + + def initialize(version, response, solution, limit) + super(version, response) + @auth_type_calls_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @auth_type_calls_page << AuthTypeCallsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @auth_type_calls_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthTypeCallsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_type_calls = payload.body[key].map do |data| + AuthTypeCallsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_type_calls + @auth_type_calls + end + end + class AuthTypeCallsInstance < InstanceResource ## # Initialize the AuthTypeCallsInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.rb index 2308a142c..194e2eab2 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.rb @@ -63,6 +63,39 @@ def create( ) end + ## + # Create the AuthCallsCredentialListMappingInstanceMetadata + # @param [String] credential_list_sid The SID of the CredentialList resource to map to the SIP domain. + # @return [AuthCallsCredentialListMappingInstance] Created AuthCallsCredentialListMappingInstance + def create_with_metadata( + credential_list_sid: nil + ) + + data = Twilio::Values.of({ + 'CredentialListSid' => credential_list_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + authCallsCredentialListMapping_instance = AuthCallsCredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + ) + AuthCallsCredentialListMappingInstanceMetadata.new( + @version, + authCallsCredentialListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Lists AuthCallsCredentialListMappingInstance records from the API as a list. @@ -102,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AuthCallsCredentialListMappingPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AuthCallsCredentialListMappingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AuthCallsCredentialListMappingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AuthCallsCredentialListMappingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + authCallsCredentialListMapping_instance = AuthCallsCredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AuthCallsCredentialListMappingInstanceMetadata.new(@version, authCallsCredentialListMapping_instance, response.headers, response.status_code) end ## @@ -210,6 +284,33 @@ def fetch ) end + ## + # Fetch the AuthCallsCredentialListMappingInstanceMetadata + # @return [AuthCallsCredentialListMappingInstance] Fetched AuthCallsCredentialListMappingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + authCallsCredentialListMapping_instance = AuthCallsCredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + sid: @solution[:sid], + ) + AuthCallsCredentialListMappingInstanceMetadata.new( + @version, + authCallsCredentialListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -226,6 +327,45 @@ def inspect end end + class AuthCallsCredentialListMappingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AuthCallsCredentialListMappingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AuthCallsCredentialListMappingInstance] auth_calls_credential_list_mapping_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AuthCallsCredentialListMappingInstanceMetadata] The initialized instance with metadata. + def initialize(version, auth_calls_credential_list_mapping_instance, headers, status_code) + super(version, headers, status_code) + @auth_calls_credential_list_mapping_instance = auth_calls_credential_list_mapping_instance + end + + def auth_calls_credential_list_mapping + @auth_calls_credential_list_mapping_instance + end + + def to_s + "" + end + end + + class AuthCallsCredentialListMappingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_calls_credential_list_mapping_instance = payload.body[key].map do |data| + AuthCallsCredentialListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_calls_credential_list_mapping_instance + @instance + end + end + class AuthCallsCredentialListMappingPage < Page ## # Initialize the AuthCallsCredentialListMappingPage @@ -254,6 +394,54 @@ def to_s '' end end + + class AuthCallsCredentialListMappingPageMetadata < PageMetadata + attr_reader :auth_calls_credential_list_mapping_page + + def initialize(version, response, solution, limit) + super(version, response) + @auth_calls_credential_list_mapping_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @auth_calls_credential_list_mapping_page << AuthCallsCredentialListMappingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @auth_calls_credential_list_mapping_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthCallsCredentialListMappingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_calls_credential_list_mapping = payload.body[key].map do |data| + AuthCallsCredentialListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_calls_credential_list_mapping + @auth_calls_credential_list_mapping + end + end + class AuthCallsCredentialListMappingInstance < InstanceResource ## # Initialize the AuthCallsCredentialListMappingInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.rb index 28a6a499a..d4aff0dd5 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.rb @@ -63,6 +63,39 @@ def create( ) end + ## + # Create the AuthCallsIpAccessControlListMappingInstanceMetadata + # @param [String] ip_access_control_list_sid The SID of the IpAccessControlList resource to map to the SIP domain. + # @return [AuthCallsIpAccessControlListMappingInstance] Created AuthCallsIpAccessControlListMappingInstance + def create_with_metadata( + ip_access_control_list_sid: nil + ) + + data = Twilio::Values.of({ + 'IpAccessControlListSid' => ip_access_control_list_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + authCallsIpAccessControlListMapping_instance = AuthCallsIpAccessControlListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + ) + AuthCallsIpAccessControlListMappingInstanceMetadata.new( + @version, + authCallsIpAccessControlListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Lists AuthCallsIpAccessControlListMappingInstance records from the API as a list. @@ -102,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AuthCallsIpAccessControlListMappingPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AuthCallsIpAccessControlListMappingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AuthCallsIpAccessControlListMappingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AuthCallsIpAccessControlListMappingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + authCallsIpAccessControlListMapping_instance = AuthCallsIpAccessControlListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AuthCallsIpAccessControlListMappingInstanceMetadata.new(@version, authCallsIpAccessControlListMapping_instance, response.headers, response.status_code) end ## @@ -210,6 +284,33 @@ def fetch ) end + ## + # Fetch the AuthCallsIpAccessControlListMappingInstanceMetadata + # @return [AuthCallsIpAccessControlListMappingInstance] Fetched AuthCallsIpAccessControlListMappingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + authCallsIpAccessControlListMapping_instance = AuthCallsIpAccessControlListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + sid: @solution[:sid], + ) + AuthCallsIpAccessControlListMappingInstanceMetadata.new( + @version, + authCallsIpAccessControlListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -226,6 +327,45 @@ def inspect end end + class AuthCallsIpAccessControlListMappingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AuthCallsIpAccessControlListMappingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AuthCallsIpAccessControlListMappingInstance] auth_calls_ip_access_control_list_mapping_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AuthCallsIpAccessControlListMappingInstanceMetadata] The initialized instance with metadata. + def initialize(version, auth_calls_ip_access_control_list_mapping_instance, headers, status_code) + super(version, headers, status_code) + @auth_calls_ip_access_control_list_mapping_instance = auth_calls_ip_access_control_list_mapping_instance + end + + def auth_calls_ip_access_control_list_mapping + @auth_calls_ip_access_control_list_mapping_instance + end + + def to_s + "" + end + end + + class AuthCallsIpAccessControlListMappingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_calls_ip_access_control_list_mapping_instance = payload.body[key].map do |data| + AuthCallsIpAccessControlListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_calls_ip_access_control_list_mapping_instance + @instance + end + end + class AuthCallsIpAccessControlListMappingPage < Page ## # Initialize the AuthCallsIpAccessControlListMappingPage @@ -254,6 +394,54 @@ def to_s '' end end + + class AuthCallsIpAccessControlListMappingPageMetadata < PageMetadata + attr_reader :auth_calls_ip_access_control_list_mapping_page + + def initialize(version, response, solution, limit) + super(version, response) + @auth_calls_ip_access_control_list_mapping_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @auth_calls_ip_access_control_list_mapping_page << AuthCallsIpAccessControlListMappingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @auth_calls_ip_access_control_list_mapping_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthCallsIpAccessControlListMappingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_calls_ip_access_control_list_mapping = payload.body[key].map do |data| + AuthCallsIpAccessControlListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_calls_ip_access_control_list_mapping + @auth_calls_ip_access_control_list_mapping + end + end + class AuthCallsIpAccessControlListMappingInstance < InstanceResource ## # Initialize the AuthCallsIpAccessControlListMappingInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations.rb index 16ac41f5e..1c8f9566b 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations.rb @@ -86,6 +86,54 @@ def to_s '' end end + + class AuthTypeRegistrationsPageMetadata < PageMetadata + attr_reader :auth_type_registrations_page + + def initialize(version, response, solution, limit) + super(version, response) + @auth_type_registrations_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @auth_type_registrations_page << AuthTypeRegistrationsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @auth_type_registrations_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthTypeRegistrationsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_type_registrations = payload.body[key].map do |data| + AuthTypeRegistrationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_type_registrations + @auth_type_registrations + end + end + class AuthTypeRegistrationsInstance < InstanceResource ## # Initialize the AuthTypeRegistrationsInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.rb index dc74e662f..2ec0f483d 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.rb @@ -63,6 +63,39 @@ def create( ) end + ## + # Create the AuthRegistrationsCredentialListMappingInstanceMetadata + # @param [String] credential_list_sid The SID of the CredentialList resource to map to the SIP domain. + # @return [AuthRegistrationsCredentialListMappingInstance] Created AuthRegistrationsCredentialListMappingInstance + def create_with_metadata( + credential_list_sid: nil + ) + + data = Twilio::Values.of({ + 'CredentialListSid' => credential_list_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + authRegistrationsCredentialListMapping_instance = AuthRegistrationsCredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + ) + AuthRegistrationsCredentialListMappingInstanceMetadata.new( + @version, + authRegistrationsCredentialListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Lists AuthRegistrationsCredentialListMappingInstance records from the API as a list. @@ -102,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AuthRegistrationsCredentialListMappingPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AuthRegistrationsCredentialListMappingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AuthRegistrationsCredentialListMappingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AuthRegistrationsCredentialListMappingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + authRegistrationsCredentialListMapping_instance = AuthRegistrationsCredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AuthRegistrationsCredentialListMappingInstanceMetadata.new(@version, authRegistrationsCredentialListMapping_instance, response.headers, response.status_code) end ## @@ -210,6 +284,33 @@ def fetch ) end + ## + # Fetch the AuthRegistrationsCredentialListMappingInstanceMetadata + # @return [AuthRegistrationsCredentialListMappingInstance] Fetched AuthRegistrationsCredentialListMappingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + authRegistrationsCredentialListMapping_instance = AuthRegistrationsCredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + sid: @solution[:sid], + ) + AuthRegistrationsCredentialListMappingInstanceMetadata.new( + @version, + authRegistrationsCredentialListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -226,6 +327,45 @@ def inspect end end + class AuthRegistrationsCredentialListMappingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AuthRegistrationsCredentialListMappingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AuthRegistrationsCredentialListMappingInstance] auth_registrations_credential_list_mapping_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AuthRegistrationsCredentialListMappingInstanceMetadata] The initialized instance with metadata. + def initialize(version, auth_registrations_credential_list_mapping_instance, headers, status_code) + super(version, headers, status_code) + @auth_registrations_credential_list_mapping_instance = auth_registrations_credential_list_mapping_instance + end + + def auth_registrations_credential_list_mapping + @auth_registrations_credential_list_mapping_instance + end + + def to_s + "" + end + end + + class AuthRegistrationsCredentialListMappingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_registrations_credential_list_mapping_instance = payload.body[key].map do |data| + AuthRegistrationsCredentialListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_registrations_credential_list_mapping_instance + @instance + end + end + class AuthRegistrationsCredentialListMappingPage < Page ## # Initialize the AuthRegistrationsCredentialListMappingPage @@ -254,6 +394,54 @@ def to_s '' end end + + class AuthRegistrationsCredentialListMappingPageMetadata < PageMetadata + attr_reader :auth_registrations_credential_list_mapping_page + + def initialize(version, response, solution, limit) + super(version, response) + @auth_registrations_credential_list_mapping_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @auth_registrations_credential_list_mapping_page << AuthRegistrationsCredentialListMappingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @auth_registrations_credential_list_mapping_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthRegistrationsCredentialListMappingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @auth_registrations_credential_list_mapping = payload.body[key].map do |data| + AuthRegistrationsCredentialListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def auth_registrations_credential_list_mapping + @auth_registrations_credential_list_mapping + end + end + class AuthRegistrationsCredentialListMappingInstance < InstanceResource ## # Initialize the AuthRegistrationsCredentialListMappingInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb index ea286cc78..a8a112aa8 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb @@ -61,6 +61,39 @@ def create( ) end + ## + # Create the CredentialListMappingInstanceMetadata + # @param [String] credential_list_sid A 34 character string that uniquely identifies the CredentialList resource to map to the SIP domain. + # @return [CredentialListMappingInstance] Created CredentialListMappingInstance + def create_with_metadata( + credential_list_sid: nil + ) + + data = Twilio::Values.of({ + 'CredentialListSid' => credential_list_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credentialListMapping_instance = CredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + ) + CredentialListMappingInstanceMetadata.new( + @version, + credentialListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialListMappingInstance records from the API as a list. @@ -100,6 +133,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialListMappingPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialListMappingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialListMappingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +239,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialListMappingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credentialListMapping_instance = CredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialListMappingInstanceMetadata.new(@version, credentialListMapping_instance, response.headers, response.status_code) end ## @@ -208,6 +282,33 @@ def fetch ) end + ## + # Fetch the CredentialListMappingInstanceMetadata + # @return [CredentialListMappingInstance] Fetched CredentialListMappingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credentialListMapping_instance = CredentialListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + sid: @solution[:sid], + ) + CredentialListMappingInstanceMetadata.new( + @version, + credentialListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -224,6 +325,45 @@ def inspect end end + class CredentialListMappingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialListMappingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialListMappingInstance] credential_list_mapping_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialListMappingInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_list_mapping_instance, headers, status_code) + super(version, headers, status_code) + @credential_list_mapping_instance = credential_list_mapping_instance + end + + def credential_list_mapping + @credential_list_mapping_instance + end + + def to_s + "" + end + end + + class CredentialListMappingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_list_mapping_instance = payload.body[key].map do |data| + CredentialListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_list_mapping_instance + @instance + end + end + class CredentialListMappingPage < Page ## # Initialize the CredentialListMappingPage @@ -252,6 +392,54 @@ def to_s '' end end + + class CredentialListMappingPageMetadata < PageMetadata + attr_reader :credential_list_mapping_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_list_mapping_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_list_mapping_page << CredentialListMappingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_list_mapping_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListMappingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_list_mapping = payload.body[key].map do |data| + CredentialListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_list_mapping + @credential_list_mapping + end + end + class CredentialListMappingInstance < InstanceResource ## # Initialize the CredentialListMappingInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb index 7646e97cf..4f7dcf2b4 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb @@ -61,6 +61,39 @@ def create( ) end + ## + # Create the IpAccessControlListMappingInstanceMetadata + # @param [String] ip_access_control_list_sid The unique id of the IP access control list to map to the SIP domain. + # @return [IpAccessControlListMappingInstance] Created IpAccessControlListMappingInstance + def create_with_metadata( + ip_access_control_list_sid: nil + ) + + data = Twilio::Values.of({ + 'IpAccessControlListSid' => ip_access_control_list_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ipAccessControlListMapping_instance = IpAccessControlListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + ) + IpAccessControlListMappingInstanceMetadata.new( + @version, + ipAccessControlListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Lists IpAccessControlListMappingInstance records from the API as a list. @@ -100,6 +133,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists IpAccessControlListMappingPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + IpAccessControlListMappingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields IpAccessControlListMappingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +239,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the IpAccessControlListMappingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + ipAccessControlListMapping_instance = IpAccessControlListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IpAccessControlListMappingInstanceMetadata.new(@version, ipAccessControlListMapping_instance, response.headers, response.status_code) end ## @@ -208,6 +282,33 @@ def fetch ) end + ## + # Fetch the IpAccessControlListMappingInstanceMetadata + # @return [IpAccessControlListMappingInstance] Fetched IpAccessControlListMappingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ipAccessControlListMapping_instance = IpAccessControlListMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + domain_sid: @solution[:domain_sid], + sid: @solution[:sid], + ) + IpAccessControlListMappingInstanceMetadata.new( + @version, + ipAccessControlListMapping_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -224,6 +325,45 @@ def inspect end end + class IpAccessControlListMappingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new IpAccessControlListMappingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}IpAccessControlListMappingInstance] ip_access_control_list_mapping_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [IpAccessControlListMappingInstanceMetadata] The initialized instance with metadata. + def initialize(version, ip_access_control_list_mapping_instance, headers, status_code) + super(version, headers, status_code) + @ip_access_control_list_mapping_instance = ip_access_control_list_mapping_instance + end + + def ip_access_control_list_mapping + @ip_access_control_list_mapping_instance + end + + def to_s + "" + end + end + + class IpAccessControlListMappingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_access_control_list_mapping_instance = payload.body[key].map do |data| + IpAccessControlListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_access_control_list_mapping_instance + @instance + end + end + class IpAccessControlListMappingPage < Page ## # Initialize the IpAccessControlListMappingPage @@ -252,6 +392,54 @@ def to_s '' end end + + class IpAccessControlListMappingPageMetadata < PageMetadata + attr_reader :ip_access_control_list_mapping_page + + def initialize(version, response, solution, limit) + super(version, response) + @ip_access_control_list_mapping_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @ip_access_control_list_mapping_page << IpAccessControlListMappingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @ip_access_control_list_mapping_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class IpAccessControlListMappingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_access_control_list_mapping = payload.body[key].map do |data| + IpAccessControlListMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_access_control_list_mapping + @ip_access_control_list_mapping + end + end + class IpAccessControlListMappingInstance < InstanceResource ## # Initialize the IpAccessControlListMappingInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb index 127614a23..4b2f3708e 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb @@ -59,6 +59,38 @@ def create( ) end + ## + # Create the IpAccessControlListInstanceMetadata + # @param [String] friendly_name A human readable descriptive text that describes the IpAccessControlList, up to 255 characters long. + # @return [IpAccessControlListInstance] Created IpAccessControlListInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ipAccessControlList_instance = IpAccessControlListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + IpAccessControlListInstanceMetadata.new( + @version, + ipAccessControlList_instance, + response.headers, + response.status_code + ) + end + ## # Lists IpAccessControlListInstance records from the API as a list. @@ -98,6 +130,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists IpAccessControlListPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + IpAccessControlListPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields IpAccessControlListInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,7 +236,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the IpAccessControlListInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + ipAccessControlList_instance = IpAccessControlListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IpAccessControlListInstanceMetadata.new(@version, ipAccessControlList_instance, response.headers, response.status_code) end ## @@ -205,6 +278,32 @@ def fetch ) end + ## + # Fetch the IpAccessControlListInstanceMetadata + # @return [IpAccessControlListInstance] Fetched IpAccessControlListInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ipAccessControlList_instance = IpAccessControlListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IpAccessControlListInstanceMetadata.new( + @version, + ipAccessControlList_instance, + response.headers, + response.status_code + ) + end + ## # Update the IpAccessControlListInstance # @param [String] friendly_name A human readable descriptive text, up to 255 characters long. @@ -232,6 +331,39 @@ def update( ) end + ## + # Update the IpAccessControlListInstanceMetadata + # @param [String] friendly_name A human readable descriptive text, up to 255 characters long. + # @return [IpAccessControlListInstance] Updated IpAccessControlListInstance + def update_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + ipAccessControlList_instance = IpAccessControlListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IpAccessControlListInstanceMetadata.new( + @version, + ipAccessControlList_instance, + response.headers, + response.status_code + ) + end + ## # Access the ip_addresses # @return [IpAddressList] @@ -267,6 +399,45 @@ def inspect end end + class IpAccessControlListInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new IpAccessControlListInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}IpAccessControlListInstance] ip_access_control_list_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [IpAccessControlListInstanceMetadata] The initialized instance with metadata. + def initialize(version, ip_access_control_list_instance, headers, status_code) + super(version, headers, status_code) + @ip_access_control_list_instance = ip_access_control_list_instance + end + + def ip_access_control_list + @ip_access_control_list_instance + end + + def to_s + "" + end + end + + class IpAccessControlListListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_access_control_list_instance = payload.body[key].map do |data| + IpAccessControlListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_access_control_list_instance + @instance + end + end + class IpAccessControlListPage < Page ## # Initialize the IpAccessControlListPage @@ -295,6 +466,54 @@ def to_s '' end end + + class IpAccessControlListPageMetadata < PageMetadata + attr_reader :ip_access_control_list_page + + def initialize(version, response, solution, limit) + super(version, response) + @ip_access_control_list_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @ip_access_control_list_page << IpAccessControlListListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @ip_access_control_list_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class IpAccessControlListListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_access_control_list = payload.body[key].map do |data| + IpAccessControlListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_access_control_list + @ip_access_control_list + end + end + class IpAccessControlListInstance < InstanceResource ## # Initialize the IpAccessControlListInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb b/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb index 869cb1225..a3c691e13 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb @@ -67,6 +67,45 @@ def create( ) end + ## + # Create the IpAddressInstanceMetadata + # @param [String] friendly_name A human readable descriptive text for this resource, up to 255 characters long. + # @param [String] ip_address An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. + # @param [String] cidr_prefix_length An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. + # @return [IpAddressInstance] Created IpAddressInstance + def create_with_metadata( + friendly_name: nil, + ip_address: nil, + cidr_prefix_length: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'IpAddress' => ip_address, + 'CidrPrefixLength' => cidr_prefix_length, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ipAddress_instance = IpAddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ip_access_control_list_sid: @solution[:ip_access_control_list_sid], + ) + IpAddressInstanceMetadata.new( + @version, + ipAddress_instance, + response.headers, + response.status_code + ) + end + ## # Lists IpAddressInstance records from the API as a list. @@ -106,6 +145,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists IpAddressPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + IpAddressPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields IpAddressInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -190,7 +251,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the IpAddressInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + ipAddress_instance = IpAddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IpAddressInstanceMetadata.new(@version, ipAddress_instance, response.headers, response.status_code) end ## @@ -214,6 +294,33 @@ def fetch ) end + ## + # Fetch the IpAddressInstanceMetadata + # @return [IpAddressInstance] Fetched IpAddressInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ipAddress_instance = IpAddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ip_access_control_list_sid: @solution[:ip_access_control_list_sid], + sid: @solution[:sid], + ) + IpAddressInstanceMetadata.new( + @version, + ipAddress_instance, + response.headers, + response.status_code + ) + end + ## # Update the IpAddressInstance # @param [String] ip_address An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. @@ -248,6 +355,46 @@ def update( ) end + ## + # Update the IpAddressInstanceMetadata + # @param [String] ip_address An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. + # @param [String] friendly_name A human readable descriptive text for this resource, up to 255 characters long. + # @param [String] cidr_prefix_length An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. + # @return [IpAddressInstance] Updated IpAddressInstance + def update_with_metadata( + ip_address: :unset, + friendly_name: :unset, + cidr_prefix_length: :unset + ) + + data = Twilio::Values.of({ + 'IpAddress' => ip_address, + 'FriendlyName' => friendly_name, + 'CidrPrefixLength' => cidr_prefix_length, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + ipAddress_instance = IpAddressInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ip_access_control_list_sid: @solution[:ip_access_control_list_sid], + sid: @solution[:sid], + ) + IpAddressInstanceMetadata.new( + @version, + ipAddress_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -264,6 +411,45 @@ def inspect end end + class IpAddressInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new IpAddressInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}IpAddressInstance] ip_address_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [IpAddressInstanceMetadata] The initialized instance with metadata. + def initialize(version, ip_address_instance, headers, status_code) + super(version, headers, status_code) + @ip_address_instance = ip_address_instance + end + + def ip_address + @ip_address_instance + end + + def to_s + "" + end + end + + class IpAddressListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_address_instance = payload.body[key].map do |data| + IpAddressInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_address_instance + @instance + end + end + class IpAddressPage < Page ## # Initialize the IpAddressPage @@ -292,6 +478,54 @@ def to_s '' end end + + class IpAddressPageMetadata < PageMetadata + attr_reader :ip_address_page + + def initialize(version, response, solution, limit) + super(version, response) + @ip_address_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @ip_address_page << IpAddressListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @ip_address_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class IpAddressListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_address = payload.body[key].map do |data| + IpAddressInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_address + @ip_address + end + end + class IpAddressInstance < InstanceResource ## # Initialize the IpAddressInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/token.rb b/lib/twilio-ruby/rest/api/v2010/account/token.rb index 464249e14..639bb13da 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/token.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/token.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the TokenInstanceMetadata + # @param [String] ttl The duration in seconds for which the generated credentials are valid. The default value is 86400 (24 hours). + # @return [TokenInstance] Created TokenInstance + def create_with_metadata( + ttl: :unset + ) + + data = Twilio::Values.of({ + 'Ttl' => ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + token_instance = TokenInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + TokenInstanceMetadata.new( + @version, + token_instance, + response.headers, + response.status_code + ) + end + @@ -95,6 +127,54 @@ def to_s '' end end + + class TokenPageMetadata < PageMetadata + attr_reader :token_page + + def initialize(version, response, solution, limit) + super(version, response) + @token_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @token_page << TokenListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @token_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TokenListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @token = payload.body[key].map do |data| + TokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def token + @token + end + end + class TokenInstance < InstanceResource ## # Initialize the TokenInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/transcription.rb b/lib/twilio-ruby/rest/api/v2010/account/transcription.rb index 30c2bba4b..4a71e4319 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/transcription.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/transcription.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TranscriptionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TranscriptionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TranscriptionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -154,7 +176,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TranscriptionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + transcription_instance = TranscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TranscriptionInstanceMetadata.new(@version, transcription_instance, response.headers, response.status_code) end ## @@ -177,6 +218,32 @@ def fetch ) end + ## + # Fetch the TranscriptionInstanceMetadata + # @return [TranscriptionInstance] Fetched TranscriptionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + transcription_instance = TranscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TranscriptionInstanceMetadata.new( + @version, + transcription_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -193,6 +260,45 @@ def inspect end end + class TranscriptionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TranscriptionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TranscriptionInstance] transcription_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TranscriptionInstanceMetadata] The initialized instance with metadata. + def initialize(version, transcription_instance, headers, status_code) + super(version, headers, status_code) + @transcription_instance = transcription_instance + end + + def transcription + @transcription_instance + end + + def to_s + "" + end + end + + class TranscriptionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcription_instance = payload.body[key].map do |data| + TranscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcription_instance + @instance + end + end + class TranscriptionPage < Page ## # Initialize the TranscriptionPage @@ -221,6 +327,54 @@ def to_s '' end end + + class TranscriptionPageMetadata < PageMetadata + attr_reader :transcription_page + + def initialize(version, response, solution, limit) + super(version, response) + @transcription_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @transcription_page << TranscriptionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @transcription_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TranscriptionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcription = payload.body[key].map do |data| + TranscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcription + @transcription + end + end + class TranscriptionInstance < InstanceResource ## # Initialize the TranscriptionInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage.rb b/lib/twilio-ruby/rest/api/v2010/account/usage.rb index 9ae0c4127..ff74ee042 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage.rb @@ -91,6 +91,54 @@ def to_s '' end end + + class UsagePageMetadata < PageMetadata + attr_reader :usage_page + + def initialize(version, response, solution, limit) + super(version, response) + @usage_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @usage_page << UsageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @usage_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @usage = payload.body[key].map do |data| + UsageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def usage + @usage + end + end + class UsageInstance < InstanceResource ## # Initialize the UsageInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb index 507da6bad..bd67ec1a2 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb @@ -96,6 +96,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RecordPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RecordPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RecordInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -245,6 +275,54 @@ def to_s '' end end + + class RecordPageMetadata < PageMetadata + attr_reader :record_page + + def initialize(version, response, solution, limit) + super(version, response) + @record_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @record_page << RecordListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @record_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @record = payload.body[key].map do |data| + RecordInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def record + @record + end + end + class RecordInstance < InstanceResource ## # Initialize the RecordInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb index f978162c0..8429624fc 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AllTimePageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AllTimePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AllTimeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class AllTimePageMetadata < PageMetadata + attr_reader :all_time_page + + def initialize(version, response, solution, limit) + super(version, response) + @all_time_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @all_time_page << AllTimeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @all_time_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AllTimeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @all_time = payload.body[key].map do |data| + AllTimeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def all_time + @all_time + end + end + class AllTimeInstance < InstanceResource ## # Initialize the AllTimeInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb index c79cfda5d..fc438b9a8 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DailyPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DailyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DailyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class DailyPageMetadata < PageMetadata + attr_reader :daily_page + + def initialize(version, response, solution, limit) + super(version, response) + @daily_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @daily_page << DailyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @daily_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DailyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @daily = payload.body[key].map do |data| + DailyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def daily + @daily + end + end + class DailyInstance < InstanceResource ## # Initialize the DailyInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb index 3e9a1e0ed..dce724a04 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists LastMonthPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + LastMonthPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields LastMonthInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class LastMonthPageMetadata < PageMetadata + attr_reader :last_month_page + + def initialize(version, response, solution, limit) + super(version, response) + @last_month_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @last_month_page << LastMonthListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @last_month_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LastMonthListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @last_month = payload.body[key].map do |data| + LastMonthInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def last_month + @last_month + end + end + class LastMonthInstance < InstanceResource ## # Initialize the LastMonthInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb index 45db2a200..fcf340814 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MonthlyPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MonthlyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MonthlyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class MonthlyPageMetadata < PageMetadata + attr_reader :monthly_page + + def initialize(version, response, solution, limit) + super(version, response) + @monthly_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @monthly_page << MonthlyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @monthly_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MonthlyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @monthly = payload.body[key].map do |data| + MonthlyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def monthly + @monthly + end + end + class MonthlyInstance < InstanceResource ## # Initialize the MonthlyInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb index 381a2fcd9..4358561be 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ThisMonthPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ThisMonthPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ThisMonthInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class ThisMonthPageMetadata < PageMetadata + attr_reader :this_month_page + + def initialize(version, response, solution, limit) + super(version, response) + @this_month_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @this_month_page << ThisMonthListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @this_month_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ThisMonthListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @this_month = payload.body[key].map do |data| + ThisMonthInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def this_month + @this_month + end + end + class ThisMonthInstance < InstanceResource ## # Initialize the ThisMonthInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb index 98dc58d9f..ead7128c7 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TodayPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TodayPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TodayInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class TodayPageMetadata < PageMetadata + attr_reader :today_page + + def initialize(version, response, solution, limit) + super(version, response) + @today_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @today_page << TodayListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @today_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TodayListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @today = payload.body[key].map do |data| + TodayInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def today + @today + end + end + class TodayInstance < InstanceResource ## # Initialize the TodayInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb index ee70e3f3a..dd31d7b2a 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists YearlyPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + YearlyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields YearlyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class YearlyPageMetadata < PageMetadata + attr_reader :yearly_page + + def initialize(version, response, solution, limit) + super(version, response) + @yearly_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @yearly_page << YearlyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @yearly_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class YearlyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @yearly = payload.body[key].map do |data| + YearlyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def yearly + @yearly + end + end + class YearlyInstance < InstanceResource ## # Initialize the YearlyInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb index 4d34e8418..3dd2a411a 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb @@ -89,6 +89,36 @@ def stream(category: :unset, start_date: :unset, end_date: :unset, include_subac @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists YesterdayPageMetadata records from the API as a list. + # @param [String] category The [usage category](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) of the UsageRecord resources to read. Only UsageRecord resources in the specified category are retrieved. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `-30days`, which will set the start date to be 30 days before the current date. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify offsets from the current date, such as: `+30days`, which will set the end date to 30 days from the current date. + # @param [Boolean] include_subaccounts Whether to include usage from the master account and all its subaccounts. Can be: `true` (the default) to include usage from the master account and all subaccounts or `false` to retrieve usage from only the specified account. + # @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_with_metadata(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Category' => category, + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'IncludeSubaccounts' => include_subaccounts, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + YesterdayPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields YesterdayInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,6 +212,54 @@ def to_s '' end end + + class YesterdayPageMetadata < PageMetadata + attr_reader :yesterday_page + + def initialize(version, response, solution, limit) + super(version, response) + @yesterday_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @yesterday_page << YesterdayListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @yesterday_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class YesterdayListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @yesterday = payload.body[key].map do |data| + YesterdayInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def yesterday + @yesterday + end + end + class YesterdayInstance < InstanceResource ## # Initialize the YesterdayInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb b/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb index c6e95bb78..2a337aba7 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb @@ -77,6 +77,56 @@ def create( ) end + ## + # Create the TriggerInstanceMetadata + # @param [String] callback_url The URL we should call using `callback_method` when the trigger fires. + # @param [String] trigger_value The usage value at which the trigger should fire. For convenience, you can use an offset value such as `+30` to specify a trigger_value that is 30 units more than the current usage value. Be sure to urlencode a `+` as `%2B`. + # @param [String] usage_category The usage category that the trigger should watch. Use one of the supported [usage categories](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) for this value. + # @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] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [Recurring] recurring + # @param [TriggerField] trigger_by + # @return [TriggerInstance] Created TriggerInstance + def create_with_metadata( + callback_url: nil, + trigger_value: nil, + usage_category: nil, + callback_method: :unset, + friendly_name: :unset, + recurring: :unset, + trigger_by: :unset + ) + + data = Twilio::Values.of({ + 'CallbackUrl' => callback_url, + 'TriggerValue' => trigger_value, + 'UsageCategory' => usage_category, + 'CallbackMethod' => callback_method, + 'FriendlyName' => friendly_name, + 'Recurring' => recurring, + 'TriggerBy' => trigger_by, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + trigger_instance = TriggerInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + TriggerInstanceMetadata.new( + @version, + trigger_instance, + response.headers, + response.status_code + ) + end + ## # Lists TriggerInstance records from the API as a list. @@ -128,6 +178,34 @@ def stream(recurring: :unset, trigger_by: :unset, usage_category: :unset, limit: @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TriggerPageMetadata records from the API as a list. + # @param [Recurring] recurring The frequency of recurring UsageTriggers to read. Can be: `daily`, `monthly`, or `yearly` to read recurring UsageTriggers. An empty value or a value of `alltime` reads non-recurring UsageTriggers. + # @param [TriggerField] trigger_by The trigger field of the UsageTriggers to read. Can be: `count`, `usage`, or `price` as described in the [UsageRecords documentation](https://www.twilio.com/docs/usage/api/usage-record#usage-count-price). + # @param [String] usage_category The usage category of the UsageTriggers to read. Must be a supported [usage categories](https://www.twilio.com/docs/usage/api/usage-record#usage-categories). + # @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_with_metadata(recurring: :unset, trigger_by: :unset, usage_category: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Recurring' => recurring, + 'TriggerBy' => trigger_by, + 'UsageCategory' => usage_category, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TriggerPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TriggerInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -217,7 +295,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TriggerInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + trigger_instance = TriggerInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TriggerInstanceMetadata.new(@version, trigger_instance, response.headers, response.status_code) end ## @@ -240,6 +337,32 @@ def fetch ) end + ## + # Fetch the TriggerInstanceMetadata + # @return [TriggerInstance] Fetched TriggerInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + trigger_instance = TriggerInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TriggerInstanceMetadata.new( + @version, + trigger_instance, + response.headers, + response.status_code + ) + end + ## # Update the TriggerInstance # @param [String] callback_method The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is `POST`. @@ -273,6 +396,45 @@ def update( ) end + ## + # Update the TriggerInstanceMetadata + # @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 `callback_method` when the trigger fires. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [TriggerInstance] Updated TriggerInstance + def update_with_metadata( + callback_method: :unset, + callback_url: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'CallbackMethod' => callback_method, + 'CallbackUrl' => callback_url, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + trigger_instance = TriggerInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TriggerInstanceMetadata.new( + @version, + trigger_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -289,6 +451,45 @@ def inspect end end + class TriggerInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TriggerInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TriggerInstance] trigger_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TriggerInstanceMetadata] The initialized instance with metadata. + def initialize(version, trigger_instance, headers, status_code) + super(version, headers, status_code) + @trigger_instance = trigger_instance + end + + def trigger + @trigger_instance + end + + def to_s + "" + end + end + + class TriggerListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trigger_instance = payload.body[key].map do |data| + TriggerInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trigger_instance + @instance + end + end + class TriggerPage < Page ## # Initialize the TriggerPage @@ -317,6 +518,54 @@ def to_s '' end end + + class TriggerPageMetadata < PageMetadata + attr_reader :trigger_page + + def initialize(version, response, solution, limit) + super(version, response) + @trigger_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @trigger_page << TriggerListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @trigger_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TriggerListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trigger = payload.body[key].map do |data| + TriggerInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trigger + @trigger + end + end + class TriggerInstance < InstanceResource ## # Initialize the TriggerInstance diff --git a/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb b/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb index f2784f1cc..9e0bcff24 100644 --- a/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb +++ b/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb @@ -73,6 +73,53 @@ def create( ) end + ## + # Create the ValidationRequestInstanceMetadata + # @param [String] phone_number The phone number to verify in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. + # @param [String] friendly_name A descriptive string that you create to describe the new caller ID resource. It can be up to 64 characters long. The default value is a formatted version of the phone number. + # @param [String] call_delay The number of seconds to delay before initiating the verification call. Can be an integer between `0` and `60`, inclusive. The default is `0`. + # @param [String] extension The digits to dial after connecting the verification call. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information about the verification process to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`, and the default is `POST`. + # @return [ValidationRequestInstance] Created ValidationRequestInstance + def create_with_metadata( + phone_number: nil, + friendly_name: :unset, + call_delay: :unset, + extension: :unset, + status_callback: :unset, + status_callback_method: :unset + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + 'FriendlyName' => friendly_name, + 'CallDelay' => call_delay, + 'Extension' => extension, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + validationRequest_instance = ValidationRequestInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + ) + ValidationRequestInstanceMetadata.new( + @version, + validationRequest_instance, + response.headers, + response.status_code + ) + end + @@ -110,6 +157,54 @@ def to_s '' end end + + class ValidationRequestPageMetadata < PageMetadata + attr_reader :validation_request_page + + def initialize(version, response, solution, limit) + super(version, response) + @validation_request_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @validation_request_page << ValidationRequestListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @validation_request_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ValidationRequestListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @validation_request = payload.body[key].map do |data| + ValidationRequestInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def validation_request + @validation_request + end + end + class ValidationRequestInstance < InstanceResource ## # Initialize the ValidationRequestInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/assistant.rb b/lib/twilio-ruby/rest/assistants/v1/assistant.rb index 944523dcc..8027720c4 100644 --- a/lib/twilio-ruby/rest/assistants/v1/assistant.rb +++ b/lib/twilio-ruby/rest/assistants/v1/assistant.rb @@ -222,6 +222,32 @@ def create(assistants_v1_service_create_assistant_request: nil ) end + ## + # Create the AssistantInstanceMetadata + # @param [AssistantsV1ServiceCreateAssistantRequest] assistants_v1_service_create_assistant_request + # @return [AssistantInstance] Created AssistantInstance + def create_with_metadata(assistants_v1_service_create_assistant_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: assistants_v1_service_create_assistant_request.to_json) + assistant_instance = AssistantInstance.new( + @version, + response.body, + ) + AssistantInstanceMetadata.new( + @version, + assistant_instance, + response.headers, + response.status_code + ) + end + ## # Lists AssistantInstance records from the API as a list. @@ -261,6 +287,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssistantPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssistantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssistantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -347,7 +395,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AssistantInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + assistant_instance = AssistantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AssistantInstanceMetadata.new(@version, assistant_instance, response.headers, response.status_code) end ## @@ -369,6 +436,31 @@ def fetch ) end + ## + # Fetch the AssistantInstanceMetadata + # @return [AssistantInstance] Fetched AssistantInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + assistant_instance = AssistantInstance.new( + @version, + response.body, + id: @solution[:id], + ) + AssistantInstanceMetadata.new( + @version, + assistant_instance, + response.headers, + response.status_code + ) + end + ## # Update the AssistantInstance # @param [AssistantsV1ServiceUpdateAssistantRequest] assistants_v1_service_update_assistant_request @@ -390,6 +482,33 @@ def update(assistants_v1_service_update_assistant_request: :unset ) end + ## + # Update the AssistantInstanceMetadata + # @param [AssistantsV1ServiceUpdateAssistantRequest] assistants_v1_service_update_assistant_request + # @return [AssistantInstance] Updated AssistantInstance + def update_with_metadata(assistants_v1_service_update_assistant_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: assistants_v1_service_update_assistant_request.to_json) + assistant_instance = AssistantInstance.new( + @version, + response.body, + id: @solution[:id], + ) + AssistantInstanceMetadata.new( + @version, + assistant_instance, + response.headers, + response.status_code + ) + end + ## # Access the feedbacks # @return [FeedbackList] @@ -466,6 +585,45 @@ def inspect end end + class AssistantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssistantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssistantInstance] assistant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssistantInstanceMetadata] The initialized instance with metadata. + def initialize(version, assistant_instance, headers, status_code) + super(version, headers, status_code) + @assistant_instance = assistant_instance + end + + def assistant + @assistant_instance + end + + def to_s + "" + end + end + + class AssistantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assistant_instance = payload.body[key].map do |data| + AssistantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assistant_instance + @instance + end + end + class AssistantPage < Page ## # Initialize the AssistantPage @@ -494,6 +652,54 @@ def to_s '' end end + + class AssistantPageMetadata < PageMetadata + attr_reader :assistant_page + + def initialize(version, response, solution, limit) + super(version, response) + @assistant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @assistant_page << AssistantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @assistant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssistantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assistant = payload.body[key].map do |data| + AssistantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assistant + @assistant + end + end + class AssistantInstance < InstanceResource ## # Initialize the AssistantInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_knowledge.rb b/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_knowledge.rb index bdd62fdb6..5ccdba8c8 100644 --- a/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_knowledge.rb +++ b/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_knowledge.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssistantsKnowledgePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssistantsKnowledgePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssistantsKnowledgeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def create ) end + ## + # Create the AssistantsKnowledgeInstanceMetadata + # @return [AssistantsKnowledgeInstance] Created AssistantsKnowledgeInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + assistantsKnowledge_instance = AssistantsKnowledgeInstance.new( + @version, + response.body, + assistant_id: @solution[:assistant_id], + id: @solution[:id], + ) + AssistantsKnowledgeInstanceMetadata.new( + @version, + assistantsKnowledge_instance, + response.headers, + response.status_code + ) + end + ## # Delete the AssistantsKnowledgeInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -174,7 +222,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AssistantsKnowledgeInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + assistantsKnowledge_instance = AssistantsKnowledgeInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AssistantsKnowledgeInstanceMetadata.new(@version, assistantsKnowledge_instance, response.headers, response.status_code) end @@ -193,6 +260,45 @@ def inspect end end + class AssistantsKnowledgeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssistantsKnowledgeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssistantsKnowledgeInstance] assistants_knowledge_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssistantsKnowledgeInstanceMetadata] The initialized instance with metadata. + def initialize(version, assistants_knowledge_instance, headers, status_code) + super(version, headers, status_code) + @assistants_knowledge_instance = assistants_knowledge_instance + end + + def assistants_knowledge + @assistants_knowledge_instance + end + + def to_s + "" + end + end + + class AssistantsKnowledgeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assistants_knowledge_instance = payload.body[key].map do |data| + AssistantsKnowledgeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assistants_knowledge_instance + @instance + end + end + class AssistantsKnowledgePage < Page ## # Initialize the AssistantsKnowledgePage @@ -221,6 +327,54 @@ def to_s '' end end + + class AssistantsKnowledgePageMetadata < PageMetadata + attr_reader :assistants_knowledge_page + + def initialize(version, response, solution, limit) + super(version, response) + @assistants_knowledge_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @assistants_knowledge_page << AssistantsKnowledgeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @assistants_knowledge_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssistantsKnowledgeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assistants_knowledge = payload.body[key].map do |data| + AssistantsKnowledgeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assistants_knowledge + @assistants_knowledge + end + end + class AssistantsKnowledgeInstance < InstanceResource ## # Initialize the AssistantsKnowledgeInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_tool.rb b/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_tool.rb index a14ce9767..4df2b87fe 100644 --- a/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_tool.rb +++ b/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_tool.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssistantsToolPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssistantsToolPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssistantsToolInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def create ) end + ## + # Create the AssistantsToolInstanceMetadata + # @return [AssistantsToolInstance] Created AssistantsToolInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + assistantsTool_instance = AssistantsToolInstance.new( + @version, + response.body, + assistant_id: @solution[:assistant_id], + id: @solution[:id], + ) + AssistantsToolInstanceMetadata.new( + @version, + assistantsTool_instance, + response.headers, + response.status_code + ) + end + ## # Delete the AssistantsToolInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -174,7 +222,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AssistantsToolInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + assistantsTool_instance = AssistantsToolInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AssistantsToolInstanceMetadata.new(@version, assistantsTool_instance, response.headers, response.status_code) end @@ -193,6 +260,45 @@ def inspect end end + class AssistantsToolInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssistantsToolInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssistantsToolInstance] assistants_tool_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssistantsToolInstanceMetadata] The initialized instance with metadata. + def initialize(version, assistants_tool_instance, headers, status_code) + super(version, headers, status_code) + @assistants_tool_instance = assistants_tool_instance + end + + def assistants_tool + @assistants_tool_instance + end + + def to_s + "" + end + end + + class AssistantsToolListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assistants_tool_instance = payload.body[key].map do |data| + AssistantsToolInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assistants_tool_instance + @instance + end + end + class AssistantsToolPage < Page ## # Initialize the AssistantsToolPage @@ -221,6 +327,54 @@ def to_s '' end end + + class AssistantsToolPageMetadata < PageMetadata + attr_reader :assistants_tool_page + + def initialize(version, response, solution, limit) + super(version, response) + @assistants_tool_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @assistants_tool_page << AssistantsToolListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @assistants_tool_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssistantsToolListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assistants_tool = payload.body[key].map do |data| + AssistantsToolInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assistants_tool + @assistants_tool + end + end + class AssistantsToolInstance < InstanceResource ## # Initialize the AssistantsToolInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/assistant/feedback.rb b/lib/twilio-ruby/rest/assistants/v1/assistant/feedback.rb index a82336a68..74d3162c6 100644 --- a/lib/twilio-ruby/rest/assistants/v1/assistant/feedback.rb +++ b/lib/twilio-ruby/rest/assistants/v1/assistant/feedback.rb @@ -76,6 +76,33 @@ def create(assistants_v1_service_create_feedback_request: nil ) end + ## + # Create the FeedbackInstanceMetadata + # @param [AssistantsV1ServiceCreateFeedbackRequest] assistants_v1_service_create_feedback_request + # @return [FeedbackInstance] Created FeedbackInstance + def create_with_metadata(assistants_v1_service_create_feedback_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: assistants_v1_service_create_feedback_request.to_json) + feedback_instance = FeedbackInstance.new( + @version, + response.body, + id: @solution[:id], + ) + FeedbackInstanceMetadata.new( + @version, + feedback_instance, + response.headers, + response.status_code + ) + end + ## # Lists FeedbackInstance records from the API as a list. @@ -115,6 +142,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FeedbackPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FeedbackPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FeedbackInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -200,6 +249,54 @@ def to_s '' end end + + class FeedbackPageMetadata < PageMetadata + attr_reader :feedback_page + + def initialize(version, response, solution, limit) + super(version, response) + @feedback_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @feedback_page << FeedbackListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @feedback_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FeedbackListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @feedback = payload.body[key].map do |data| + FeedbackInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def feedback + @feedback + end + end + class FeedbackInstance < InstanceResource ## # Initialize the FeedbackInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/assistant/message.rb b/lib/twilio-ruby/rest/assistants/v1/assistant/message.rb index 246d17b02..66c860801 100644 --- a/lib/twilio-ruby/rest/assistants/v1/assistant/message.rb +++ b/lib/twilio-ruby/rest/assistants/v1/assistant/message.rb @@ -79,6 +79,33 @@ def create(assistants_v1_service_assistant_send_message_request: nil ) end + ## + # Create the MessageInstanceMetadata + # @param [AssistantsV1ServiceAssistantSendMessageRequest] assistants_v1_service_assistant_send_message_request + # @return [MessageInstance] Created MessageInstance + def create_with_metadata(assistants_v1_service_assistant_send_message_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: assistants_v1_service_assistant_send_message_request.to_json) + message_instance = MessageInstance.new( + @version, + response.body, + id: @solution[:id], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + @@ -116,6 +143,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/knowledge.rb b/lib/twilio-ruby/rest/assistants/v1/knowledge.rb index 7164d9e50..1eaddab04 100644 --- a/lib/twilio-ruby/rest/assistants/v1/knowledge.rb +++ b/lib/twilio-ruby/rest/assistants/v1/knowledge.rb @@ -220,6 +220,32 @@ def create(assistants_v1_service_create_knowledge_request: nil ) end + ## + # Create the KnowledgeInstanceMetadata + # @param [AssistantsV1ServiceCreateKnowledgeRequest] assistants_v1_service_create_knowledge_request + # @return [KnowledgeInstance] Created KnowledgeInstance + def create_with_metadata(assistants_v1_service_create_knowledge_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: assistants_v1_service_create_knowledge_request.to_json) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + ) + KnowledgeInstanceMetadata.new( + @version, + knowledge_instance, + response.headers, + response.status_code + ) + end + ## # Lists KnowledgeInstance records from the API as a list. @@ -263,6 +289,30 @@ def stream(assistant_id: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists KnowledgePageMetadata records from the API as a list. + # @param [String] assistant_id + # @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_with_metadata(assistant_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AssistantId' => assistant_id, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + KnowledgePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields KnowledgeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -349,7 +399,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the KnowledgeInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + KnowledgeInstanceMetadata.new(@version, knowledge_instance, response.headers, response.status_code) end ## @@ -371,6 +440,31 @@ def fetch ) end + ## + # Fetch the KnowledgeInstanceMetadata + # @return [KnowledgeInstance] Fetched KnowledgeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + id: @solution[:id], + ) + KnowledgeInstanceMetadata.new( + @version, + knowledge_instance, + response.headers, + response.status_code + ) + end + ## # Update the KnowledgeInstance # @param [AssistantsV1ServiceUpdateKnowledgeRequest] assistants_v1_service_update_knowledge_request @@ -392,6 +486,33 @@ def update(assistants_v1_service_update_knowledge_request: :unset ) end + ## + # Update the KnowledgeInstanceMetadata + # @param [AssistantsV1ServiceUpdateKnowledgeRequest] assistants_v1_service_update_knowledge_request + # @return [KnowledgeInstance] Updated KnowledgeInstance + def update_with_metadata(assistants_v1_service_update_knowledge_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: assistants_v1_service_update_knowledge_request.to_json) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + id: @solution[:id], + ) + KnowledgeInstanceMetadata.new( + @version, + knowledge_instance, + response.headers, + response.status_code + ) + end + ## # Access the chunks # @return [ChunkList] @@ -429,6 +550,45 @@ def inspect end end + class KnowledgeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new KnowledgeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}KnowledgeInstance] knowledge_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [KnowledgeInstanceMetadata] The initialized instance with metadata. + def initialize(version, knowledge_instance, headers, status_code) + super(version, headers, status_code) + @knowledge_instance = knowledge_instance + end + + def knowledge + @knowledge_instance + end + + def to_s + "" + end + end + + class KnowledgeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge_instance = payload.body[key].map do |data| + KnowledgeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge_instance + @instance + end + end + class KnowledgePage < Page ## # Initialize the KnowledgePage @@ -457,6 +617,54 @@ def to_s '' end end + + class KnowledgePageMetadata < PageMetadata + attr_reader :knowledge_page + + def initialize(version, response, solution, limit) + super(version, response) + @knowledge_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @knowledge_page << KnowledgeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @knowledge_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class KnowledgeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge = payload.body[key].map do |data| + KnowledgeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge + @knowledge + end + end + class KnowledgeInstance < InstanceResource ## # Initialize the KnowledgeInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/knowledge/chunk.rb b/lib/twilio-ruby/rest/assistants/v1/knowledge/chunk.rb index 41928b85e..5b4b46551 100644 --- a/lib/twilio-ruby/rest/assistants/v1/knowledge/chunk.rb +++ b/lib/twilio-ruby/rest/assistants/v1/knowledge/chunk.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChunkPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChunkPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChunkInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,6 +178,54 @@ def to_s '' end end + + class ChunkPageMetadata < PageMetadata + attr_reader :chunk_page + + def initialize(version, response, solution, limit) + super(version, response) + @chunk_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @chunk_page << ChunkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @chunk_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChunkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @chunk = payload.body[key].map do |data| + ChunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def chunk + @chunk + end + end + class ChunkInstance < InstanceResource ## # Initialize the ChunkInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/knowledge/knowledge_status.rb b/lib/twilio-ruby/rest/assistants/v1/knowledge/knowledge_status.rb index 29fbef3b2..b6169cbd9 100644 --- a/lib/twilio-ruby/rest/assistants/v1/knowledge/knowledge_status.rb +++ b/lib/twilio-ruby/rest/assistants/v1/knowledge/knowledge_status.rb @@ -76,6 +76,31 @@ def fetch ) end + ## + # Fetch the KnowledgeStatusInstanceMetadata + # @return [KnowledgeStatusInstance] Fetched KnowledgeStatusInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + knowledgeStatus_instance = KnowledgeStatusInstance.new( + @version, + response.body, + id: @solution[:id], + ) + KnowledgeStatusInstanceMetadata.new( + @version, + knowledgeStatus_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -92,6 +117,45 @@ def inspect end end + class KnowledgeStatusInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new KnowledgeStatusInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}KnowledgeStatusInstance] knowledge_status_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [KnowledgeStatusInstanceMetadata] The initialized instance with metadata. + def initialize(version, knowledge_status_instance, headers, status_code) + super(version, headers, status_code) + @knowledge_status_instance = knowledge_status_instance + end + + def knowledge_status + @knowledge_status_instance + end + + def to_s + "" + end + end + + class KnowledgeStatusListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge_status_instance = payload.body[key].map do |data| + KnowledgeStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge_status_instance + @instance + end + end + class KnowledgeStatusPage < Page ## # Initialize the KnowledgeStatusPage @@ -120,6 +184,54 @@ def to_s '' end end + + class KnowledgeStatusPageMetadata < PageMetadata + attr_reader :knowledge_status_page + + def initialize(version, response, solution, limit) + super(version, response) + @knowledge_status_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @knowledge_status_page << KnowledgeStatusListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @knowledge_status_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class KnowledgeStatusListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge_status = payload.body[key].map do |data| + KnowledgeStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge_status + @knowledge_status + end + end + class KnowledgeStatusInstance < InstanceResource ## # Initialize the KnowledgeStatusInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/policy.rb b/lib/twilio-ruby/rest/assistants/v1/policy.rb index bc34511da..dc7fa645e 100644 --- a/lib/twilio-ruby/rest/assistants/v1/policy.rb +++ b/lib/twilio-ruby/rest/assistants/v1/policy.rb @@ -77,6 +77,32 @@ def stream(tool_id: :unset, knowledge_id: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PolicyPageMetadata records from the API as a list. + # @param [String] tool_id The tool ID. + # @param [String] knowledge_id The knowledge ID. + # @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_with_metadata(tool_id: :unset, knowledge_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ToolId' => tool_id, + 'KnowledgeId' => knowledge_id, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PolicyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PolicyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -166,6 +192,54 @@ def to_s '' end end + + class PolicyPageMetadata < PageMetadata + attr_reader :policy_page + + def initialize(version, response, solution, limit) + super(version, response) + @policy_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @policy_page << PolicyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @policy_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PolicyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @policy = payload.body[key].map do |data| + PolicyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def policy + @policy + end + end + class PolicyInstance < InstanceResource ## # Initialize the PolicyInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/session.rb b/lib/twilio-ruby/rest/assistants/v1/session.rb index 26a3c10f3..d786ef8e0 100644 --- a/lib/twilio-ruby/rest/assistants/v1/session.rb +++ b/lib/twilio-ruby/rest/assistants/v1/session.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SessionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SessionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SessionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -162,6 +184,31 @@ def fetch ) end + ## + # Fetch the SessionInstanceMetadata + # @return [SessionInstance] Fetched SessionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + session_instance = SessionInstance.new( + @version, + response.body, + id: @solution[:id], + ) + SessionInstanceMetadata.new( + @version, + session_instance, + response.headers, + response.status_code + ) + end + ## # Access the messages # @return [MessageList] @@ -189,6 +236,45 @@ def inspect end end + class SessionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SessionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SessionInstance] session_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SessionInstanceMetadata] The initialized instance with metadata. + def initialize(version, session_instance, headers, status_code) + super(version, headers, status_code) + @session_instance = session_instance + end + + def session + @session_instance + end + + def to_s + "" + end + end + + class SessionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @session_instance = payload.body[key].map do |data| + SessionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def session_instance + @instance + end + end + class SessionPage < Page ## # Initialize the SessionPage @@ -217,6 +303,54 @@ def to_s '' end end + + class SessionPageMetadata < PageMetadata + attr_reader :session_page + + def initialize(version, response, solution, limit) + super(version, response) + @session_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @session_page << SessionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @session_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SessionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @session = payload.body[key].map do |data| + SessionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def session + @session + end + end + class SessionInstance < InstanceResource ## # Initialize the SessionInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/session/message.rb b/lib/twilio-ruby/rest/assistants/v1/session/message.rb index 8d2ae4a61..f977aafd7 100644 --- a/lib/twilio-ruby/rest/assistants/v1/session/message.rb +++ b/lib/twilio-ruby/rest/assistants/v1/session/message.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,6 +178,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/assistants/v1/tool.rb b/lib/twilio-ruby/rest/assistants/v1/tool.rb index 08abb53c5..59b7170d2 100644 --- a/lib/twilio-ruby/rest/assistants/v1/tool.rb +++ b/lib/twilio-ruby/rest/assistants/v1/tool.rb @@ -226,6 +226,32 @@ def create(assistants_v1_service_create_tool_request: nil ) end + ## + # Create the ToolInstanceMetadata + # @param [AssistantsV1ServiceCreateToolRequest] assistants_v1_service_create_tool_request + # @return [ToolInstance] Created ToolInstance + def create_with_metadata(assistants_v1_service_create_tool_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: assistants_v1_service_create_tool_request.to_json) + tool_instance = ToolInstance.new( + @version, + response.body, + ) + ToolInstanceMetadata.new( + @version, + tool_instance, + response.headers, + response.status_code + ) + end + ## # Lists ToolInstance records from the API as a list. @@ -269,6 +295,30 @@ def stream(assistant_id: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ToolPageMetadata records from the API as a list. + # @param [String] assistant_id + # @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_with_metadata(assistant_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AssistantId' => assistant_id, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ToolPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ToolInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -353,7 +403,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ToolInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + tool_instance = ToolInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ToolInstanceMetadata.new(@version, tool_instance, response.headers, response.status_code) end ## @@ -375,6 +444,31 @@ def fetch ) end + ## + # Fetch the ToolInstanceMetadata + # @return [ToolInstance] Fetched ToolInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + tool_instance = ToolInstance.new( + @version, + response.body, + id: @solution[:id], + ) + ToolInstanceMetadata.new( + @version, + tool_instance, + response.headers, + response.status_code + ) + end + ## # Update the ToolInstance # @param [AssistantsV1ServiceUpdateToolRequest] assistants_v1_service_update_tool_request @@ -396,6 +490,33 @@ def update(assistants_v1_service_update_tool_request: :unset ) end + ## + # Update the ToolInstanceMetadata + # @param [AssistantsV1ServiceUpdateToolRequest] assistants_v1_service_update_tool_request + # @return [ToolInstance] Updated ToolInstance + def update_with_metadata(assistants_v1_service_update_tool_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: assistants_v1_service_update_tool_request.to_json) + tool_instance = ToolInstance.new( + @version, + response.body, + id: @solution[:id], + ) + ToolInstanceMetadata.new( + @version, + tool_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -412,6 +533,45 @@ def inspect end end + class ToolInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ToolInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ToolInstance] tool_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ToolInstanceMetadata] The initialized instance with metadata. + def initialize(version, tool_instance, headers, status_code) + super(version, headers, status_code) + @tool_instance = tool_instance + end + + def tool + @tool_instance + end + + def to_s + "" + end + end + + class ToolListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @tool_instance = payload.body[key].map do |data| + ToolInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def tool_instance + @instance + end + end + class ToolPage < Page ## # Initialize the ToolPage @@ -440,6 +600,54 @@ def to_s '' end end + + class ToolPageMetadata < PageMetadata + attr_reader :tool_page + + def initialize(version, response, solution, limit) + super(version, response) + @tool_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @tool_page << ToolListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @tool_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ToolListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @tool = payload.body[key].map do |data| + ToolInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def tool + @tool + end + end + class ToolInstance < InstanceResource ## # Initialize the ToolInstance diff --git a/lib/twilio-ruby/rest/bulkexports/v1/export.rb b/lib/twilio-ruby/rest/bulkexports/v1/export.rb index eb29cf793..37263fb61 100644 --- a/lib/twilio-ruby/rest/bulkexports/v1/export.rb +++ b/lib/twilio-ruby/rest/bulkexports/v1/export.rb @@ -90,6 +90,31 @@ def fetch ) end + ## + # Fetch the ExportInstanceMetadata + # @return [ExportInstance] Fetched ExportInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + export_instance = ExportInstance.new( + @version, + response.body, + resource_type: @solution[:resource_type], + ) + ExportInstanceMetadata.new( + @version, + export_instance, + response.headers, + response.status_code + ) + end + ## # Access the export_custom_jobs # @return [ExportCustomJobList] @@ -136,6 +161,45 @@ def inspect end end + class ExportInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExportInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExportInstance] export_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExportInstanceMetadata] The initialized instance with metadata. + def initialize(version, export_instance, headers, status_code) + super(version, headers, status_code) + @export_instance = export_instance + end + + def export + @export_instance + end + + def to_s + "" + end + end + + class ExportListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @export_instance = payload.body[key].map do |data| + ExportInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def export_instance + @instance + end + end + class ExportPage < Page ## # Initialize the ExportPage @@ -164,6 +228,54 @@ def to_s '' end end + + class ExportPageMetadata < PageMetadata + attr_reader :export_page + + def initialize(version, response, solution, limit) + super(version, response) + @export_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @export_page << ExportListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @export_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExportListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @export = payload.body[key].map do |data| + ExportInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def export + @export + end + end + class ExportInstance < InstanceResource ## # Initialize the ExportInstance diff --git a/lib/twilio-ruby/rest/bulkexports/v1/export/day.rb b/lib/twilio-ruby/rest/bulkexports/v1/export/day.rb index 6691c9544..3a8933eef 100644 --- a/lib/twilio-ruby/rest/bulkexports/v1/export/day.rb +++ b/lib/twilio-ruby/rest/bulkexports/v1/export/day.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DayPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DayPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DayInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the DayInstanceMetadata + # @return [DayInstance] Fetched DayInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + day_instance = DayInstance.new( + @version, + response.body, + resource_type: @solution[:resource_type], + day: @solution[:day], + ) + DayInstanceMetadata.new( + @version, + day_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class DayInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DayInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DayInstance] day_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DayInstanceMetadata] The initialized instance with metadata. + def initialize(version, day_instance, headers, status_code) + super(version, headers, status_code) + @day_instance = day_instance + end + + def day + @day_instance + end + + def to_s + "" + end + end + + class DayListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @day_instance = payload.body[key].map do |data| + DayInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def day_instance + @instance + end + end + class DayPage < Page ## # Initialize the DayPage @@ -209,6 +296,54 @@ def to_s '' end end + + class DayPageMetadata < PageMetadata + attr_reader :day_page + + def initialize(version, response, solution, limit) + super(version, response) + @day_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @day_page << DayListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @day_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DayListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @day = payload.body[key].map do |data| + DayInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def day + @day + end + end + class DayInstance < InstanceResource ## # Initialize the DayInstance diff --git a/lib/twilio-ruby/rest/bulkexports/v1/export/export_custom_job.rb b/lib/twilio-ruby/rest/bulkexports/v1/export/export_custom_job.rb index f8ef951d5..7ccfc8b92 100644 --- a/lib/twilio-ruby/rest/bulkexports/v1/export/export_custom_job.rb +++ b/lib/twilio-ruby/rest/bulkexports/v1/export/export_custom_job.rb @@ -73,6 +73,53 @@ def create( ) end + ## + # Create the ExportCustomJobInstanceMetadata + # @param [String] start_day The start day for the custom export specified as a string in the format of yyyy-mm-dd + # @param [String] end_day The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day. + # @param [String] friendly_name The friendly name specified when creating the job + # @param [String] webhook_url The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. If you set neither webhook nor email, you will have to check your job's status manually. + # @param [String] webhook_method This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied. + # @param [String] email The optional email to send the completion notification to. You can set both webhook, and email, or one or the other. If you set neither, the job will run but you will have to query to determine your job's status. + # @return [ExportCustomJobInstance] Created ExportCustomJobInstance + def create_with_metadata( + start_day: nil, + end_day: nil, + friendly_name: nil, + webhook_url: :unset, + webhook_method: :unset, + email: :unset + ) + + data = Twilio::Values.of({ + 'StartDay' => start_day, + 'EndDay' => end_day, + 'FriendlyName' => friendly_name, + 'WebhookUrl' => webhook_url, + 'WebhookMethod' => webhook_method, + 'Email' => email, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + exportCustomJob_instance = ExportCustomJobInstance.new( + @version, + response.body, + resource_type: @solution[:resource_type], + ) + ExportCustomJobInstanceMetadata.new( + @version, + exportCustomJob_instance, + response.headers, + response.status_code + ) + end + ## # Lists ExportCustomJobInstance records from the API as a list. @@ -112,6 +159,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ExportCustomJobPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ExportCustomJobPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ExportCustomJobInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -197,6 +266,54 @@ def to_s '' end end + + class ExportCustomJobPageMetadata < PageMetadata + attr_reader :export_custom_job_page + + def initialize(version, response, solution, limit) + super(version, response) + @export_custom_job_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @export_custom_job_page << ExportCustomJobListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @export_custom_job_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExportCustomJobListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @export_custom_job = payload.body[key].map do |data| + ExportCustomJobInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def export_custom_job + @export_custom_job + end + end + class ExportCustomJobInstance < InstanceResource ## # Initialize the ExportCustomJobInstance diff --git a/lib/twilio-ruby/rest/bulkexports/v1/export/job.rb b/lib/twilio-ruby/rest/bulkexports/v1/export/job.rb index 390fcd5f1..7944ca305 100644 --- a/lib/twilio-ruby/rest/bulkexports/v1/export/job.rb +++ b/lib/twilio-ruby/rest/bulkexports/v1/export/job.rb @@ -66,7 +66,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the JobInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + job_instance = JobInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + JobInstanceMetadata.new(@version, job_instance, response.headers, response.status_code) end ## @@ -88,6 +107,31 @@ def fetch ) end + ## + # Fetch the JobInstanceMetadata + # @return [JobInstance] Fetched JobInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + job_instance = JobInstance.new( + @version, + response.body, + job_sid: @solution[:job_sid], + ) + JobInstanceMetadata.new( + @version, + job_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -104,6 +148,45 @@ def inspect end end + class JobInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new JobInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}JobInstance] job_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [JobInstanceMetadata] The initialized instance with metadata. + def initialize(version, job_instance, headers, status_code) + super(version, headers, status_code) + @job_instance = job_instance + end + + def job + @job_instance + end + + def to_s + "" + end + end + + class JobListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @job_instance = payload.body[key].map do |data| + JobInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def job_instance + @instance + end + end + class JobPage < Page ## # Initialize the JobPage @@ -132,6 +215,54 @@ def to_s '' end end + + class JobPageMetadata < PageMetadata + attr_reader :job_page + + def initialize(version, response, solution, limit) + super(version, response) + @job_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @job_page << JobListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @job_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class JobListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @job = payload.body[key].map do |data| + JobInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def job + @job + end + end + class JobInstance < InstanceResource ## # Initialize the JobInstance diff --git a/lib/twilio-ruby/rest/bulkexports/v1/export_configuration.rb b/lib/twilio-ruby/rest/bulkexports/v1/export_configuration.rb index b9e36c2c0..3f58417d6 100644 --- a/lib/twilio-ruby/rest/bulkexports/v1/export_configuration.rb +++ b/lib/twilio-ruby/rest/bulkexports/v1/export_configuration.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the ExportConfigurationInstanceMetadata + # @return [ExportConfigurationInstance] Fetched ExportConfigurationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + exportConfiguration_instance = ExportConfigurationInstance.new( + @version, + response.body, + resource_type: @solution[:resource_type], + ) + ExportConfigurationInstanceMetadata.new( + @version, + exportConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Update the ExportConfigurationInstance # @param [Boolean] enabled If true, Twilio will automatically generate every day's file when the day is over. @@ -106,6 +131,44 @@ def update( ) end + ## + # Update the ExportConfigurationInstanceMetadata + # @param [Boolean] enabled If true, Twilio will automatically generate every day's file when the day is over. + # @param [String] webhook_url Stores the URL destination for the method specified in webhook_method. + # @param [String] webhook_method Sets whether Twilio should call a webhook URL when the automatic generation is complete, using GET or POST. The actual destination is set in the webhook_url + # @return [ExportConfigurationInstance] Updated ExportConfigurationInstance + def update_with_metadata( + enabled: :unset, + webhook_url: :unset, + webhook_method: :unset + ) + + data = Twilio::Values.of({ + 'Enabled' => enabled, + 'WebhookUrl' => webhook_url, + 'WebhookMethod' => webhook_method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + exportConfiguration_instance = ExportConfigurationInstance.new( + @version, + response.body, + resource_type: @solution[:resource_type], + ) + ExportConfigurationInstanceMetadata.new( + @version, + exportConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -122,6 +185,45 @@ def inspect end end + class ExportConfigurationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExportConfigurationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExportConfigurationInstance] export_configuration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExportConfigurationInstanceMetadata] The initialized instance with metadata. + def initialize(version, export_configuration_instance, headers, status_code) + super(version, headers, status_code) + @export_configuration_instance = export_configuration_instance + end + + def export_configuration + @export_configuration_instance + end + + def to_s + "" + end + end + + class ExportConfigurationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @export_configuration_instance = payload.body[key].map do |data| + ExportConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def export_configuration_instance + @instance + end + end + class ExportConfigurationPage < Page ## # Initialize the ExportConfigurationPage @@ -150,6 +252,54 @@ def to_s '' end end + + class ExportConfigurationPageMetadata < PageMetadata + attr_reader :export_configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @export_configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @export_configuration_page << ExportConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @export_configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExportConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @export_configuration = payload.body[key].map do |data| + ExportConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def export_configuration + @export_configuration + end + end + class ExportConfigurationInstance < InstanceResource ## # Initialize the ExportConfigurationInstance diff --git a/lib/twilio-ruby/rest/chat/v1/credential.rb b/lib/twilio-ruby/rest/chat/v1/credential.rb index 1a3bf255c..e1cfd2cbc 100644 --- a/lib/twilio-ruby/rest/chat/v1/credential.rb +++ b/lib/twilio-ruby/rest/chat/v1/credential.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CredentialInstanceMetadata + # @param [PushService] type + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A== -----END CERTIFICATE-----` + # @param [String] private_key [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR. -----END RSA PRIVATE KEY-----` + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + # @param [String] secret [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. + # @return [CredentialInstance] Created CredentialInstance + def create_with_metadata( + type: nil, + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialInstance records from the API as a list. @@ -112,6 +161,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code) end ## @@ -216,6 +306,31 @@ def fetch ) end + ## + # Fetch the CredentialInstanceMetadata + # @return [CredentialInstance] Fetched CredentialInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -257,6 +372,53 @@ def update( ) end + ## + # Update the CredentialInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A== -----END CERTIFICATE-----` + # @param [String] private_key [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR. -----END RSA PRIVATE KEY-----` + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + # @param [String] secret [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. + # @return [CredentialInstance] Updated CredentialInstance + def update_with_metadata( + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -273,6 +435,45 @@ def inspect end end + class CredentialInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialInstance] credential_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_instance, headers, status_code) + super(version, headers, status_code) + @credential_instance = credential_instance + end + + def credential + @credential_instance + end + + def to_s + "" + end + end + + class CredentialListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_instance = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_instance + @instance + end + end + class CredentialPage < Page ## # Initialize the CredentialPage @@ -301,6 +502,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service.rb b/lib/twilio-ruby/rest/chat/v1/service.rb index f359a48d7..15abd022e 100644 --- a/lib/twilio-ruby/rest/chat/v1/service.rb +++ b/lib/twilio-ruby/rest/chat/v1/service.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -94,6 +125,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -179,7 +232,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -201,6 +273,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -386,6 +483,197 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] default_service_role_sid The service role assigned to users when they are added to the service. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details. + # @param [String] default_channel_role_sid The channel role assigned to users when they are added to a channel. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details. + # @param [String] default_channel_creator_role_sid The channel role assigned to a channel creator when they join a new channel. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details. + # @param [Boolean] read_status_enabled Whether to enable the [Message Consumption Horizon](https://www.twilio.com/docs/chat/consumption-horizon) feature. The default is `true`. + # @param [Boolean] reachability_enabled Whether to enable the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) for this Service instance. The default is `false`. + # @param [String] typing_indicator_timeout How long in seconds after a `started typing` event until clients should assume that user is no longer typing, even if no `ended typing` message was received. The default is 5 seconds. + # @param [String] consumption_report_interval DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints. + # @param [Boolean] notifications_new_message_enabled Whether to send a notification when a new message is added to a channel. Can be: `true` or `false` and the default is `false`. + # @param [String] notifications_new_message_template The template to use to create the notification text displayed when a new message is added to a channel and `notifications.new_message.enabled` is `true`. + # @param [Boolean] notifications_added_to_channel_enabled Whether to send a notification when a member is added to a channel. Can be: `true` or `false` and the default is `false`. + # @param [String] notifications_added_to_channel_template The template to use to create the notification text displayed when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`. + # @param [Boolean] notifications_removed_from_channel_enabled Whether to send a notification to a user when they are removed from a channel. Can be: `true` or `false` and the default is `false`. + # @param [String] notifications_removed_from_channel_template The template to use to create the notification text displayed to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`. + # @param [Boolean] notifications_invited_to_channel_enabled Whether to send a notification when a user is invited to a channel. Can be: `true` or `false` and the default is `false`. + # @param [String] notifications_invited_to_channel_template The template to use to create the notification text displayed when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`. + # @param [String] pre_webhook_url The URL for pre-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/api/chat/webhooks) for more details. + # @param [String] post_webhook_url The URL for post-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/api/chat/webhooks) for more details. + # @param [String] webhook_method The HTTP method to use for calls to the `pre_webhook_url` and `post_webhook_url` webhooks. Can be: `POST` or `GET` and the default is `POST`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. + # @param [Array[String]] webhook_filters The list of WebHook events that are enabled for this Service instance. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. + # @param [String] webhooks_on_message_send_url The URL of the webhook to call in response to the `on_message_send` event using the `webhooks.on_message_send.method` HTTP method. + # @param [String] webhooks_on_message_send_method The HTTP method to use when calling the `webhooks.on_message_send.url`. + # @param [String] webhooks_on_message_update_url The URL of the webhook to call in response to the `on_message_update` event using the `webhooks.on_message_update.method` HTTP method. + # @param [String] webhooks_on_message_update_method The HTTP method to use when calling the `webhooks.on_message_update.url`. + # @param [String] webhooks_on_message_remove_url The URL of the webhook to call in response to the `on_message_remove` event using the `webhooks.on_message_remove.method` HTTP method. + # @param [String] webhooks_on_message_remove_method The HTTP method to use when calling the `webhooks.on_message_remove.url`. + # @param [String] webhooks_on_channel_add_url The URL of the webhook to call in response to the `on_channel_add` event using the `webhooks.on_channel_add.method` HTTP method. + # @param [String] webhooks_on_channel_add_method The HTTP method to use when calling the `webhooks.on_channel_add.url`. + # @param [String] webhooks_on_channel_destroy_url The URL of the webhook to call in response to the `on_channel_destroy` event using the `webhooks.on_channel_destroy.method` HTTP method. + # @param [String] webhooks_on_channel_destroy_method The HTTP method to use when calling the `webhooks.on_channel_destroy.url`. + # @param [String] webhooks_on_channel_update_url The URL of the webhook to call in response to the `on_channel_update` event using the `webhooks.on_channel_update.method` HTTP method. + # @param [String] webhooks_on_channel_update_method The HTTP method to use when calling the `webhooks.on_channel_update.url`. + # @param [String] webhooks_on_member_add_url The URL of the webhook to call in response to the `on_member_add` event using the `webhooks.on_member_add.method` HTTP method. + # @param [String] webhooks_on_member_add_method The HTTP method to use when calling the `webhooks.on_member_add.url`. + # @param [String] webhooks_on_member_remove_url The URL of the webhook to call in response to the `on_member_remove` event using the `webhooks.on_member_remove.method` HTTP method. + # @param [String] webhooks_on_member_remove_method The HTTP method to use when calling the `webhooks.on_member_remove.url`. + # @param [String] webhooks_on_message_sent_url The URL of the webhook to call in response to the `on_message_sent` event using the `webhooks.on_message_sent.method` HTTP method. + # @param [String] webhooks_on_message_sent_method The URL of the webhook to call in response to the `on_message_sent` event`. + # @param [String] webhooks_on_message_updated_url The URL of the webhook to call in response to the `on_message_updated` event using the `webhooks.on_message_updated.method` HTTP method. + # @param [String] webhooks_on_message_updated_method The HTTP method to use when calling the `webhooks.on_message_updated.url`. + # @param [String] webhooks_on_message_removed_url The URL of the webhook to call in response to the `on_message_removed` event using the `webhooks.on_message_removed.method` HTTP method. + # @param [String] webhooks_on_message_removed_method The HTTP method to use when calling the `webhooks.on_message_removed.url`. + # @param [String] webhooks_on_channel_added_url The URL of the webhook to call in response to the `on_channel_added` event using the `webhooks.on_channel_added.method` HTTP method. + # @param [String] webhooks_on_channel_added_method The URL of the webhook to call in response to the `on_channel_added` event`. + # @param [String] webhooks_on_channel_destroyed_url The URL of the webhook to call in response to the `on_channel_added` event using the `webhooks.on_channel_destroyed.method` HTTP method. + # @param [String] webhooks_on_channel_destroyed_method The HTTP method to use when calling the `webhooks.on_channel_destroyed.url`. + # @param [String] webhooks_on_channel_updated_url The URL of the webhook to call in response to the `on_channel_updated` event using the `webhooks.on_channel_updated.method` HTTP method. + # @param [String] webhooks_on_channel_updated_method The HTTP method to use when calling the `webhooks.on_channel_updated.url`. + # @param [String] webhooks_on_member_added_url The URL of the webhook to call in response to the `on_channel_updated` event using the `webhooks.on_channel_updated.method` HTTP method. + # @param [String] webhooks_on_member_added_method The HTTP method to use when calling the `webhooks.on_channel_updated.url`. + # @param [String] webhooks_on_member_removed_url The URL of the webhook to call in response to the `on_member_removed` event using the `webhooks.on_member_removed.method` HTTP method. + # @param [String] webhooks_on_member_removed_method The HTTP method to use when calling the `webhooks.on_member_removed.url`. + # @param [String] limits_channel_members The maximum number of Members that can be added to Channels within this Service. Can be up to 1,000. + # @param [String] limits_user_channels The maximum number of Channels Users can be a Member of within this Service. Can be up to 1,000. + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + friendly_name: :unset, + default_service_role_sid: :unset, + default_channel_role_sid: :unset, + default_channel_creator_role_sid: :unset, + read_status_enabled: :unset, + reachability_enabled: :unset, + typing_indicator_timeout: :unset, + consumption_report_interval: :unset, + notifications_new_message_enabled: :unset, + notifications_new_message_template: :unset, + notifications_added_to_channel_enabled: :unset, + notifications_added_to_channel_template: :unset, + notifications_removed_from_channel_enabled: :unset, + notifications_removed_from_channel_template: :unset, + notifications_invited_to_channel_enabled: :unset, + notifications_invited_to_channel_template: :unset, + pre_webhook_url: :unset, + post_webhook_url: :unset, + webhook_method: :unset, + webhook_filters: :unset, + webhooks_on_message_send_url: :unset, + webhooks_on_message_send_method: :unset, + webhooks_on_message_update_url: :unset, + webhooks_on_message_update_method: :unset, + webhooks_on_message_remove_url: :unset, + webhooks_on_message_remove_method: :unset, + webhooks_on_channel_add_url: :unset, + webhooks_on_channel_add_method: :unset, + webhooks_on_channel_destroy_url: :unset, + webhooks_on_channel_destroy_method: :unset, + webhooks_on_channel_update_url: :unset, + webhooks_on_channel_update_method: :unset, + webhooks_on_member_add_url: :unset, + webhooks_on_member_add_method: :unset, + webhooks_on_member_remove_url: :unset, + webhooks_on_member_remove_method: :unset, + webhooks_on_message_sent_url: :unset, + webhooks_on_message_sent_method: :unset, + webhooks_on_message_updated_url: :unset, + webhooks_on_message_updated_method: :unset, + webhooks_on_message_removed_url: :unset, + webhooks_on_message_removed_method: :unset, + webhooks_on_channel_added_url: :unset, + webhooks_on_channel_added_method: :unset, + webhooks_on_channel_destroyed_url: :unset, + webhooks_on_channel_destroyed_method: :unset, + webhooks_on_channel_updated_url: :unset, + webhooks_on_channel_updated_method: :unset, + webhooks_on_member_added_url: :unset, + webhooks_on_member_added_method: :unset, + webhooks_on_member_removed_url: :unset, + webhooks_on_member_removed_method: :unset, + limits_channel_members: :unset, + limits_user_channels: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DefaultServiceRoleSid' => default_service_role_sid, + 'DefaultChannelRoleSid' => default_channel_role_sid, + 'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid, + 'ReadStatusEnabled' => read_status_enabled, + 'ReachabilityEnabled' => reachability_enabled, + 'TypingIndicatorTimeout' => typing_indicator_timeout, + 'ConsumptionReportInterval' => consumption_report_interval, + 'Notifications.NewMessage.Enabled' => notifications_new_message_enabled, + 'Notifications.NewMessage.Template' => notifications_new_message_template, + 'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled, + 'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template, + 'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled, + 'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template, + 'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled, + 'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template, + 'PreWebhookUrl' => pre_webhook_url, + 'PostWebhookUrl' => post_webhook_url, + 'WebhookMethod' => webhook_method, + 'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e }, + 'Webhooks.OnMessageSend.Url' => webhooks_on_message_send_url, + 'Webhooks.OnMessageSend.Method' => webhooks_on_message_send_method, + 'Webhooks.OnMessageUpdate.Url' => webhooks_on_message_update_url, + 'Webhooks.OnMessageUpdate.Method' => webhooks_on_message_update_method, + 'Webhooks.OnMessageRemove.Url' => webhooks_on_message_remove_url, + 'Webhooks.OnMessageRemove.Method' => webhooks_on_message_remove_method, + 'Webhooks.OnChannelAdd.Url' => webhooks_on_channel_add_url, + 'Webhooks.OnChannelAdd.Method' => webhooks_on_channel_add_method, + 'Webhooks.OnChannelDestroy.Url' => webhooks_on_channel_destroy_url, + 'Webhooks.OnChannelDestroy.Method' => webhooks_on_channel_destroy_method, + 'Webhooks.OnChannelUpdate.Url' => webhooks_on_channel_update_url, + 'Webhooks.OnChannelUpdate.Method' => webhooks_on_channel_update_method, + 'Webhooks.OnMemberAdd.Url' => webhooks_on_member_add_url, + 'Webhooks.OnMemberAdd.Method' => webhooks_on_member_add_method, + 'Webhooks.OnMemberRemove.Url' => webhooks_on_member_remove_url, + 'Webhooks.OnMemberRemove.Method' => webhooks_on_member_remove_method, + 'Webhooks.OnMessageSent.Url' => webhooks_on_message_sent_url, + 'Webhooks.OnMessageSent.Method' => webhooks_on_message_sent_method, + 'Webhooks.OnMessageUpdated.Url' => webhooks_on_message_updated_url, + 'Webhooks.OnMessageUpdated.Method' => webhooks_on_message_updated_method, + 'Webhooks.OnMessageRemoved.Url' => webhooks_on_message_removed_url, + 'Webhooks.OnMessageRemoved.Method' => webhooks_on_message_removed_method, + 'Webhooks.OnChannelAdded.Url' => webhooks_on_channel_added_url, + 'Webhooks.OnChannelAdded.Method' => webhooks_on_channel_added_method, + 'Webhooks.OnChannelDestroyed.Url' => webhooks_on_channel_destroyed_url, + 'Webhooks.OnChannelDestroyed.Method' => webhooks_on_channel_destroyed_method, + 'Webhooks.OnChannelUpdated.Url' => webhooks_on_channel_updated_url, + 'Webhooks.OnChannelUpdated.Method' => webhooks_on_channel_updated_method, + 'Webhooks.OnMemberAdded.Url' => webhooks_on_member_added_url, + 'Webhooks.OnMemberAdded.Method' => webhooks_on_member_added_method, + 'Webhooks.OnMemberRemoved.Url' => webhooks_on_member_removed_url, + 'Webhooks.OnMemberRemoved.Method' => webhooks_on_member_removed_method, + 'Limits.ChannelMembers' => limits_channel_members, + 'Limits.UserChannels' => limits_user_channels, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the channels # @return [ChannelList] @@ -459,6 +747,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -487,6 +814,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service/channel.rb b/lib/twilio-ruby/rest/chat/v1/service/channel.rb index 22ef609f3..83a278cc2 100644 --- a/lib/twilio-ruby/rest/chat/v1/service/channel.rb +++ b/lib/twilio-ruby/rest/chat/v1/service/channel.rb @@ -67,6 +67,47 @@ def create( ) end + ## + # Create the ChannelInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. This value must be 64 characters or less in length and be unique within the Service. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [ChannelType] type + # @return [ChannelInstance] Created ChannelInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset, + type: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + 'Type' => type, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChannelInstance records from the API as a list. @@ -110,6 +151,31 @@ def stream(type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChannelPageMetadata records from the API as a list. + # @param [Array[ChannelType]] type The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. + # @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_with_metadata(type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Type' => Twilio.serialize_list(type) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -199,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ChannelInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new(@version, channel_instance, response.headers, response.status_code) end ## @@ -222,6 +307,32 @@ def fetch ) end + ## + # Fetch the ChannelInstanceMetadata + # @return [ChannelInstance] Fetched ChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Update the ChannelInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -255,6 +366,45 @@ def update( ) end + ## + # Update the ChannelInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. This value must be 64 characters or less in length and be unique within the Service. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @return [ChannelInstance] Updated ChannelInstance + def update_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Access the members # @return [MemberList] @@ -328,6 +478,45 @@ def inspect end end + class ChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelInstance] channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, channel_instance, headers, status_code) + super(version, headers, status_code) + @channel_instance = channel_instance + end + + def channel + @channel_instance + end + + def to_s + "" + end + end + + class ChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_instance = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_instance + @instance + end + end + class ChannelPage < Page ## # Initialize the ChannelPage @@ -356,6 +545,54 @@ def to_s '' end end + + class ChannelPageMetadata < PageMetadata + attr_reader :channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channel_page << ChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel + @channel + end + end + class ChannelInstance < InstanceResource ## # Initialize the ChannelInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb b/lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb index bb4549a4e..682b15060 100644 --- a/lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb +++ b/lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the InviteInstanceMetadata + # @param [String] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/api/chat/rest/v1/user) within the [Service](https://www.twilio.com/docs/api/chat/rest/v1/service). See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more info. + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to the new member. + # @return [InviteInstance] Created InviteInstance + def create_with_metadata( + identity: nil, + role_sid: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Lists InviteInstance records from the API as a list. @@ -106,6 +142,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InvitePageMetadata records from the API as a list. + # @param [Array[String]] identity The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InvitePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InviteInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +254,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InviteInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new(@version, invite_instance, response.headers, response.status_code) end ## @@ -217,6 +297,33 @@ def fetch ) end + ## + # Fetch the InviteInstanceMetadata + # @return [InviteInstance] Fetched InviteInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -233,6 +340,45 @@ def inspect end end + class InviteInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InviteInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InviteInstance] invite_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InviteInstanceMetadata] The initialized instance with metadata. + def initialize(version, invite_instance, headers, status_code) + super(version, headers, status_code) + @invite_instance = invite_instance + end + + def invite + @invite_instance + end + + def to_s + "" + end + end + + class InviteListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite_instance = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite_instance + @instance + end + end + class InvitePage < Page ## # Initialize the InvitePage @@ -261,6 +407,54 @@ def to_s '' end end + + class InvitePageMetadata < PageMetadata + attr_reader :invite_page + + def initialize(version, response, solution, limit) + super(version, response) + @invite_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @invite_page << InviteListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @invite_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InviteListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite + @invite + end + end + class InviteInstance < InstanceResource ## # Initialize the InviteInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb b/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb index d1dfe8e76..77547a528 100644 --- a/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +++ b/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the MemberInstanceMetadata + # @param [String] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/api/chat/rest/v1/user) within the [Service](https://www.twilio.com/docs/api/chat/rest/services). See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/api/services). + # @return [MemberInstance] Created MemberInstance + def create_with_metadata( + identity: nil, + role_sid: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Lists MemberInstance records from the API as a list. @@ -106,6 +142,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MemberPageMetadata records from the API as a list. + # @param [Array[String]] identity The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MemberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MemberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +254,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MemberInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new(@version, member_instance, response.headers, response.status_code) end ## @@ -217,6 +297,33 @@ def fetch ) end + ## + # Fetch the MemberInstanceMetadata + # @return [MemberInstance] Fetched MemberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Update the MemberInstance # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/api/services). @@ -248,6 +355,43 @@ def update( ) end + ## + # Update the MemberInstanceMetadata + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/api/services). + # @param [String] last_consumed_message_index The index of the last [Message](https://www.twilio.com/docs/api/chat/rest/messages) that the Member has read within the [Channel](https://www.twilio.com/docs/api/chat/rest/channels). + # @return [MemberInstance] Updated MemberInstance + def update_with_metadata( + role_sid: :unset, + last_consumed_message_index: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'LastConsumedMessageIndex' => last_consumed_message_index, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -264,6 +408,45 @@ def inspect end end + class MemberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MemberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MemberInstance] member_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MemberInstanceMetadata] The initialized instance with metadata. + def initialize(version, member_instance, headers, status_code) + super(version, headers, status_code) + @member_instance = member_instance + end + + def member + @member_instance + end + + def to_s + "" + end + end + + class MemberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member_instance = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member_instance + @instance + end + end + class MemberPage < Page ## # Initialize the MemberPage @@ -292,6 +475,54 @@ def to_s '' end end + + class MemberPageMetadata < PageMetadata + attr_reader :member_page + + def initialize(version, response, solution, limit) + super(version, response) + @member_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @member_page << MemberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @member_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MemberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member + @member + end + end + class MemberInstance < InstanceResource ## # Initialize the MemberInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service/channel/message.rb b/lib/twilio-ruby/rest/chat/v1/service/channel/message.rb index c0f374088..1f262c7bd 100644 --- a/lib/twilio-ruby/rest/chat/v1/service/channel/message.rb +++ b/lib/twilio-ruby/rest/chat/v1/service/channel/message.rb @@ -66,6 +66,45 @@ def create( ) end + ## + # Create the MessageInstanceMetadata + # @param [String] body The message to send to the channel. Can also be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. + # @param [String] from The [identity](https://www.twilio.com/docs/api/chat/guides/identity) of the new message's author. The default value is `system`. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + body: nil, + from: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'From' => from, + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInstance records from the API as a list. @@ -109,6 +148,30 @@ def stream(order: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @param [OrderType] order The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. + # @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_with_metadata(order: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -195,7 +258,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MessageInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code) end ## @@ -219,6 +301,33 @@ def fetch ) end + ## + # Fetch the MessageInstanceMetadata + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessageInstance # @param [String] body The message to send to the channel. Can also be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. @@ -250,6 +359,43 @@ def update( ) end + ## + # Update the MessageInstanceMetadata + # @param [String] body The message to send to the channel. Can also be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + body: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -266,6 +412,45 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInstance] message_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def message + @message_instance + end + + def to_s + "" + end + end + + class MessageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_instance = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_instance + @instance + end + end + class MessagePage < Page ## # Initialize the MessagePage @@ -294,6 +479,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service/role.rb b/lib/twilio-ruby/rest/chat/v1/service/role.rb index 1efd0b322..d1b5c85b5 100644 --- a/lib/twilio-ruby/rest/chat/v1/service/role.rb +++ b/lib/twilio-ruby/rest/chat/v1/service/role.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the RoleInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [RoleType] type + # @param [Array[String]] permission A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type` and are described in the documentation. + # @return [RoleInstance] Created RoleInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + permission: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoleInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RolePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RolePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoleInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +246,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoleInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new(@version, role_instance, response.headers, response.status_code) end ## @@ -209,6 +288,32 @@ def fetch ) end + ## + # Fetch the RoleInstanceMetadata + # @return [RoleInstance] Fetched RoleInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Update the RoleInstance # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type` and are described in the documentation. @@ -236,6 +341,39 @@ def update( ) end + ## + # Update the RoleInstanceMetadata + # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type` and are described in the documentation. + # @return [RoleInstance] Updated RoleInstance + def update_with_metadata( + permission: nil + ) + + data = Twilio::Values.of({ + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -252,6 +390,45 @@ def inspect end end + class RoleInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoleInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoleInstance] role_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoleInstanceMetadata] The initialized instance with metadata. + def initialize(version, role_instance, headers, status_code) + super(version, headers, status_code) + @role_instance = role_instance + end + + def role + @role_instance + end + + def to_s + "" + end + end + + class RoleListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_instance = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_instance + @instance + end + end + class RolePage < Page ## # Initialize the RolePage @@ -280,6 +457,54 @@ def to_s '' end end + + class RolePageMetadata < PageMetadata + attr_reader :role_page + + def initialize(version, response, solution, limit) + super(version, response) + @role_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @role_page << RoleListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @role_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoleListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role + @role + end + end + class RoleInstance < InstanceResource ## # Initialize the RoleInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service/user.rb b/lib/twilio-ruby/rest/chat/v1/service/user.rb index 69587aab3..845023103 100644 --- a/lib/twilio-ruby/rest/chat/v1/service/user.rb +++ b/lib/twilio-ruby/rest/chat/v1/service/user.rb @@ -67,6 +67,47 @@ def create( ) end + ## + # Create the UserInstanceMetadata + # @param [String] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/api/chat/rest/v1/user) within the [Service](https://www.twilio.com/docs/api/chat/rest/v1/service). This value is often a username or email address. See the Identity documentation for more details. + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to the new User. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [String] friendly_name A descriptive string that you create to describe the new resource. This value is often used for display purposes. + # @return [UserInstance] Created UserInstance + def create_with_metadata( + identity: nil, + role_sid: :unset, + attributes: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Lists UserInstance records from the API as a list. @@ -106,6 +147,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -190,7 +253,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code) end ## @@ -213,6 +295,32 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to this user. @@ -246,6 +354,45 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to this user. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is often used for display purposes. + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + role_sid: :unset, + attributes: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Access the user_channels # @return [UserChannelList] @@ -273,6 +420,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -301,6 +487,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb b/lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb index c7449a8d3..06bac4f1d 100644 --- a/lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb +++ b/lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -157,6 +179,54 @@ def to_s '' end end + + class UserChannelPageMetadata < PageMetadata + attr_reader :user_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_channel_page << UserChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_channel = payload.body[key].map do |data| + UserChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_channel + @user_channel + end + end + class UserChannelInstance < InstanceResource ## # Initialize the UserChannelInstance diff --git a/lib/twilio-ruby/rest/chat/v2/credential.rb b/lib/twilio-ruby/rest/chat/v2/credential.rb index e8553ce67..c29b91b6b 100644 --- a/lib/twilio-ruby/rest/chat/v2/credential.rb +++ b/lib/twilio-ruby/rest/chat/v2/credential.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CredentialInstanceMetadata + # @param [PushService] type + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----` + # @param [String] private_key [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----` + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + # @param [String] secret [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. + # @return [CredentialInstance] Created CredentialInstance + def create_with_metadata( + type: nil, + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialInstance records from the API as a list. @@ -112,6 +161,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code) end ## @@ -216,6 +306,31 @@ def fetch ) end + ## + # Fetch the CredentialInstanceMetadata + # @return [CredentialInstance] Fetched CredentialInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -257,6 +372,53 @@ def update( ) end + ## + # Update the CredentialInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----` + # @param [String] private_key [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----` + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + # @param [String] secret [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. + # @return [CredentialInstance] Updated CredentialInstance + def update_with_metadata( + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -273,6 +435,45 @@ def inspect end end + class CredentialInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialInstance] credential_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_instance, headers, status_code) + super(version, headers, status_code) + @credential_instance = credential_instance + end + + def credential + @credential_instance + end + + def to_s + "" + end + end + + class CredentialListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_instance = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_instance + @instance + end + end + class CredentialPage < Page ## # Initialize the CredentialPage @@ -301,6 +502,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service.rb b/lib/twilio-ruby/rest/chat/v2/service.rb index 0825df558..266ae7cd0 100644 --- a/lib/twilio-ruby/rest/chat/v2/service.rb +++ b/lib/twilio-ruby/rest/chat/v2/service.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new resource. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -94,6 +125,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +233,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -202,6 +274,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. @@ -318,6 +415,128 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. + # @param [String] default_service_role_sid The service role assigned to users when they are added to the service. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles. + # @param [String] default_channel_role_sid The channel role assigned to users when they are added to a channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles. + # @param [String] default_channel_creator_role_sid The channel role assigned to a channel creator when they join a new channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles. + # @param [Boolean] read_status_enabled Whether to enable the [Message Consumption Horizon](https://www.twilio.com/docs/chat/consumption-horizon) feature. The default is `true`. + # @param [Boolean] reachability_enabled Whether to enable the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) for this Service instance. The default is `false`. + # @param [String] typing_indicator_timeout How long in seconds after a `started typing` event until clients should assume that user is no longer typing, even if no `ended typing` message was received. The default is 5 seconds. + # @param [String] consumption_report_interval DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints. + # @param [Boolean] notifications_new_message_enabled Whether to send a notification when a new message is added to a channel. The default is `false`. + # @param [String] notifications_new_message_template The template to use to create the notification text displayed when a new message is added to a channel and `notifications.new_message.enabled` is `true`. + # @param [String] notifications_new_message_sound The name of the sound to play when a new message is added to a channel and `notifications.new_message.enabled` is `true`. + # @param [Boolean] notifications_new_message_badge_count_enabled Whether the new message badge is enabled. The default is `false`. + # @param [Boolean] notifications_added_to_channel_enabled Whether to send a notification when a member is added to a channel. The default is `false`. + # @param [String] notifications_added_to_channel_template The template to use to create the notification text displayed when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`. + # @param [String] notifications_added_to_channel_sound The name of the sound to play when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`. + # @param [Boolean] notifications_removed_from_channel_enabled Whether to send a notification to a user when they are removed from a channel. The default is `false`. + # @param [String] notifications_removed_from_channel_template The template to use to create the notification text displayed to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`. + # @param [String] notifications_removed_from_channel_sound The name of the sound to play to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`. + # @param [Boolean] notifications_invited_to_channel_enabled Whether to send a notification when a user is invited to a channel. The default is `false`. + # @param [String] notifications_invited_to_channel_template The template to use to create the notification text displayed when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`. + # @param [String] notifications_invited_to_channel_sound The name of the sound to play when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`. + # @param [String] pre_webhook_url The URL for pre-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. + # @param [String] post_webhook_url The URL for post-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. + # @param [String] webhook_method The HTTP method to use for calls to the `pre_webhook_url` and `post_webhook_url` webhooks. Can be: `POST` or `GET` and the default is `POST`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. + # @param [Array[String]] webhook_filters The list of webhook events that are enabled for this Service instance. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. + # @param [String] limits_channel_members The maximum number of Members that can be added to Channels within this Service. Can be up to 1,000. + # @param [String] limits_user_channels The maximum number of Channels Users can be a Member of within this Service. Can be up to 1,000. + # @param [String] media_compatibility_message The message to send when a media message has no text. Can be used as placeholder message. + # @param [String] pre_webhook_retry_count The number of times to retry a call to the `pre_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. Default retry count is 0 times, which means the call won't be retried. + # @param [String] post_webhook_retry_count The number of times to retry a call to the `post_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. The default is 0, which means the call won't be retried. + # @param [Boolean] notifications_log_enabled Whether to log notifications. The default is `false`. + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + friendly_name: :unset, + default_service_role_sid: :unset, + default_channel_role_sid: :unset, + default_channel_creator_role_sid: :unset, + read_status_enabled: :unset, + reachability_enabled: :unset, + typing_indicator_timeout: :unset, + consumption_report_interval: :unset, + notifications_new_message_enabled: :unset, + notifications_new_message_template: :unset, + notifications_new_message_sound: :unset, + notifications_new_message_badge_count_enabled: :unset, + notifications_added_to_channel_enabled: :unset, + notifications_added_to_channel_template: :unset, + notifications_added_to_channel_sound: :unset, + notifications_removed_from_channel_enabled: :unset, + notifications_removed_from_channel_template: :unset, + notifications_removed_from_channel_sound: :unset, + notifications_invited_to_channel_enabled: :unset, + notifications_invited_to_channel_template: :unset, + notifications_invited_to_channel_sound: :unset, + pre_webhook_url: :unset, + post_webhook_url: :unset, + webhook_method: :unset, + webhook_filters: :unset, + limits_channel_members: :unset, + limits_user_channels: :unset, + media_compatibility_message: :unset, + pre_webhook_retry_count: :unset, + post_webhook_retry_count: :unset, + notifications_log_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DefaultServiceRoleSid' => default_service_role_sid, + 'DefaultChannelRoleSid' => default_channel_role_sid, + 'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid, + 'ReadStatusEnabled' => read_status_enabled, + 'ReachabilityEnabled' => reachability_enabled, + 'TypingIndicatorTimeout' => typing_indicator_timeout, + 'ConsumptionReportInterval' => consumption_report_interval, + 'Notifications.NewMessage.Enabled' => notifications_new_message_enabled, + 'Notifications.NewMessage.Template' => notifications_new_message_template, + 'Notifications.NewMessage.Sound' => notifications_new_message_sound, + 'Notifications.NewMessage.BadgeCountEnabled' => notifications_new_message_badge_count_enabled, + 'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled, + 'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template, + 'Notifications.AddedToChannel.Sound' => notifications_added_to_channel_sound, + 'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled, + 'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template, + 'Notifications.RemovedFromChannel.Sound' => notifications_removed_from_channel_sound, + 'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled, + 'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template, + 'Notifications.InvitedToChannel.Sound' => notifications_invited_to_channel_sound, + 'PreWebhookUrl' => pre_webhook_url, + 'PostWebhookUrl' => post_webhook_url, + 'WebhookMethod' => webhook_method, + 'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e }, + 'Limits.ChannelMembers' => limits_channel_members, + 'Limits.UserChannels' => limits_user_channels, + 'Media.CompatibilityMessage' => media_compatibility_message, + 'PreWebhookRetryCount' => pre_webhook_retry_count, + 'PostWebhookRetryCount' => post_webhook_retry_count, + 'Notifications.LogEnabled' => notifications_log_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the bindings # @return [BindingList] @@ -410,6 +629,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -438,6 +696,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/binding.rb b/lib/twilio-ruby/rest/chat/v2/service/binding.rb index 5c5264d15..023d3e630 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/binding.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/binding.rb @@ -79,6 +79,34 @@ def stream(binding_type: :unset, identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BindingPageMetadata records from the API as a list. + # @param [Array[BindingType]] binding_type The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. + # @param [Array[String]] identity The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. + # @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_with_metadata(binding_type: :unset, identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'BindingType' => Twilio.serialize_list(binding_type) { |e| e }, + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BindingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BindingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,7 +196,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BindingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new(@version, binding_instance, response.headers, response.status_code) end ## @@ -191,6 +238,32 @@ def fetch ) end + ## + # Fetch the BindingInstanceMetadata + # @return [BindingInstance] Fetched BindingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new( + @version, + binding_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -207,6 +280,45 @@ def inspect end end + class BindingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BindingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BindingInstance] binding_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BindingInstanceMetadata] The initialized instance with metadata. + def initialize(version, binding_instance, headers, status_code) + super(version, headers, status_code) + @binding_instance = binding_instance + end + + def binding + @binding_instance + end + + def to_s + "" + end + end + + class BindingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding_instance = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding_instance + @instance + end + end + class BindingPage < Page ## # Initialize the BindingPage @@ -235,6 +347,54 @@ def to_s '' end end + + class BindingPageMetadata < PageMetadata + attr_reader :binding_page + + def initialize(version, response, solution, limit) + super(version, response) + @binding_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @binding_page << BindingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @binding_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BindingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding + @binding + end + end + class BindingInstance < InstanceResource ## # Initialize the BindingInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/channel.rb b/lib/twilio-ruby/rest/chat/v2/service/channel.rb index 50f4ba5bb..d48f58fa4 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/channel.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/channel.rb @@ -78,6 +78,58 @@ def create( ) end + ## + # Create the ChannelInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the Channel resource's `sid` in the URL. This value must be 64 characters or less in length and be unique within the Service. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [ChannelType] type + # @param [Time] date_created The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this should only be used in cases where a Channel is being recreated from a backup/separate source. + # @param [Time] date_updated The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. The default value is `null`. Note that this parameter should only be used in cases where a Channel is being recreated from a backup/separate source and where a Message was previously updated. + # @param [String] created_by The `identity` of the User that created the channel. Default is: `system`. + # @param [ChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ChannelInstance] Created ChannelInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset, + type: :unset, + date_created: :unset, + date_updated: :unset, + created_by: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + 'Type' => type, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'CreatedBy' => created_by, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChannelInstance records from the API as a list. @@ -121,6 +173,31 @@ def stream(type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChannelPageMetadata records from the API as a list. + # @param [Array[ChannelType]] type The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. + # @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_with_metadata(type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Type' => Twilio.serialize_list(type) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -214,7 +291,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ChannelInstanceMetadata + # @param [ChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new(@version, channel_instance, response.headers, response.status_code) end ## @@ -237,6 +336,32 @@ def fetch ) end + ## + # Fetch the ChannelInstanceMetadata + # @return [ChannelInstance] Fetched ChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Update the ChannelInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 256 characters long. @@ -281,6 +406,56 @@ def update( ) end + ## + # Update the ChannelInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 256 characters long. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. This value must be 256 characters or less in length and unique within the Service. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [Time] date_created The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this should only be used in cases where a Channel is being recreated from a backup/separate source. + # @param [Time] date_updated The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. + # @param [String] created_by The `identity` of the User that created the channel. Default is: `system`. + # @param [ChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ChannelInstance] Updated ChannelInstance + def update_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset, + date_created: :unset, + date_updated: :unset, + created_by: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'CreatedBy' => created_by, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Access the webhooks # @return [WebhookList] @@ -373,6 +548,45 @@ def inspect end end + class ChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelInstance] channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, channel_instance, headers, status_code) + super(version, headers, status_code) + @channel_instance = channel_instance + end + + def channel + @channel_instance + end + + def to_s + "" + end + end + + class ChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_instance = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_instance + @instance + end + end + class ChannelPage < Page ## # Initialize the ChannelPage @@ -401,6 +615,54 @@ def to_s '' end end + + class ChannelPageMetadata < PageMetadata + attr_reader :channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channel_page << ChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel + @channel + end + end + class ChannelInstance < InstanceResource ## # Initialize the ChannelInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb b/lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb index 6257a10bd..f6d35f3a1 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the InviteInstanceMetadata + # @param [String] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info. + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) assigned to the new member. + # @return [InviteInstance] Created InviteInstance + def create_with_metadata( + identity: nil, + role_sid: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Lists InviteInstance records from the API as a list. @@ -106,6 +142,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InvitePageMetadata records from the API as a list. + # @param [Array[String]] identity The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InvitePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InviteInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +254,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InviteInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new(@version, invite_instance, response.headers, response.status_code) end ## @@ -217,6 +297,33 @@ def fetch ) end + ## + # Fetch the InviteInstanceMetadata + # @return [InviteInstance] Fetched InviteInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -233,6 +340,45 @@ def inspect end end + class InviteInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InviteInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InviteInstance] invite_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InviteInstanceMetadata] The initialized instance with metadata. + def initialize(version, invite_instance, headers, status_code) + super(version, headers, status_code) + @invite_instance = invite_instance + end + + def invite + @invite_instance + end + + def to_s + "" + end + end + + class InviteListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite_instance = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite_instance + @instance + end + end + class InvitePage < Page ## # Initialize the InvitePage @@ -261,6 +407,54 @@ def to_s '' end end + + class InvitePageMetadata < PageMetadata + attr_reader :invite_page + + def initialize(version, response, solution, limit) + super(version, response) + @invite_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @invite_page << InviteListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @invite_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InviteListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite + @invite + end + end + class InviteInstance < InstanceResource ## # Initialize the InviteInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb b/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb index 635875916..dac11e487 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb @@ -80,6 +80,59 @@ def create( ) end + ## + # Create the MemberInstanceMetadata + # @param [String] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info. + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/rest/service-resource). + # @param [String] last_consumed_message_index The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) in the [Channel](https://www.twilio.com/docs/chat/channels) that the Member has read. This parameter should only be used when recreating a Member from a backup/separate source. + # @param [Time] last_consumption_timestamp The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) read event for the Member within the [Channel](https://www.twilio.com/docs/chat/channels). + # @param [Time] date_created The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this parameter should only be used when a Member is being recreated from a backup/separate source. + # @param [Time] date_updated The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. The default value is `null`. Note that this parameter should only be used when a Member is being recreated from a backup/separate source and where a Member was previously updated. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [MemberEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MemberInstance] Created MemberInstance + def create_with_metadata( + identity: nil, + role_sid: :unset, + last_consumed_message_index: :unset, + last_consumption_timestamp: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + 'LastConsumedMessageIndex' => last_consumed_message_index, + 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Lists MemberInstance records from the API as a list. @@ -123,6 +176,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MemberPageMetadata records from the API as a list. + # @param [Array[String]] identity The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the Member resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MemberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MemberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -213,7 +291,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MemberInstanceMetadata + # @param [MemberEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new(@version, member_instance, response.headers, response.status_code) end ## @@ -237,6 +337,33 @@ def fetch ) end + ## + # Fetch the MemberInstanceMetadata + # @return [MemberInstance] Fetched MemberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Update the MemberInstance # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/rest/service-resource). @@ -282,6 +409,57 @@ def update( ) end + ## + # Update the MemberInstanceMetadata + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/rest/service-resource). + # @param [String] last_consumed_message_index The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) that the Member has read within the [Channel](https://www.twilio.com/docs/chat/channels). + # @param [Time] last_consumption_timestamp The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) read event for the Member within the [Channel](https://www.twilio.com/docs/chat/channels). + # @param [Time] date_created The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this parameter should only be used when a Member is being recreated from a backup/separate source. + # @param [Time] date_updated The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [MemberEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MemberInstance] Updated MemberInstance + def update_with_metadata( + role_sid: :unset, + last_consumed_message_index: :unset, + last_consumption_timestamp: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'LastConsumedMessageIndex' => last_consumed_message_index, + 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -298,6 +476,45 @@ def inspect end end + class MemberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MemberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MemberInstance] member_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MemberInstanceMetadata] The initialized instance with metadata. + def initialize(version, member_instance, headers, status_code) + super(version, headers, status_code) + @member_instance = member_instance + end + + def member + @member_instance + end + + def to_s + "" + end + end + + class MemberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member_instance = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member_instance + @instance + end + end + class MemberPage < Page ## # Initialize the MemberPage @@ -326,6 +543,54 @@ def to_s '' end end + + class MemberPageMetadata < PageMetadata + attr_reader :member_page + + def initialize(version, response, solution, limit) + super(version, response) + @member_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @member_page << MemberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @member_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MemberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member + @member + end + end + class MemberInstance < InstanceResource ## # Initialize the MemberInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb b/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb index 019462b11..5dfe28646 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb @@ -80,6 +80,59 @@ def create( ) end + ## + # Create the MessageInstanceMetadata + # @param [String] from The [Identity](https://www.twilio.com/docs/chat/identity) of the new message's author. The default value is `system`. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [Time] date_created The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source. + # @param [Time] date_updated The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. + # @param [String] last_updated_by The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable. + # @param [String] body The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. + # @param [String] media_sid The SID of the [Media](https://www.twilio.com/docs/chat/rest/media) to attach to the new Message. + # @param [MessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + from: :unset, + attributes: :unset, + date_created: :unset, + date_updated: :unset, + last_updated_by: :unset, + body: :unset, + media_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'From' => from, + 'Attributes' => attributes, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'LastUpdatedBy' => last_updated_by, + 'Body' => body, + 'MediaSid' => media_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInstance records from the API as a list. @@ -123,6 +176,30 @@ def stream(order: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @param [OrderType] order The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. + # @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_with_metadata(order: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -212,7 +289,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MessageInstanceMetadata + # @param [MessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code) end ## @@ -236,6 +335,33 @@ def fetch ) end + ## + # Fetch the MessageInstanceMetadata + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessageInstance # @param [String] body The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. @@ -281,6 +407,57 @@ def update( ) end + ## + # Update the MessageInstanceMetadata + # @param [String] body The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [Time] date_created The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source. + # @param [Time] date_updated The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. + # @param [String] last_updated_by The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable. + # @param [String] from The [Identity](https://www.twilio.com/docs/chat/identity) of the message's author. + # @param [MessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + body: :unset, + attributes: :unset, + date_created: :unset, + date_updated: :unset, + last_updated_by: :unset, + from: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'Attributes' => attributes, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'LastUpdatedBy' => last_updated_by, + 'From' => from, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -297,6 +474,45 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInstance] message_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def message + @message_instance + end + + def to_s + "" + end + end + + class MessageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_instance = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_instance + @instance + end + end + class MessagePage < Page ## # Initialize the MessagePage @@ -325,6 +541,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb b/lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb index b72fae2e2..4545ed347 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb @@ -78,6 +78,57 @@ def create( ) end + ## + # Create the WebhookInstanceMetadata + # @param [Type] type + # @param [String] configuration_url The URL of the webhook to call using the `configuration.method`. + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger). + # @param [Array[String]] configuration_triggers A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`. + # @param [String] configuration_flow_sid The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` is `studio`. + # @param [String] configuration_retry_count The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0. + # @return [WebhookInstance] Created WebhookInstance + def create_with_metadata( + type: nil, + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset, + configuration_retry_count: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + 'Configuration.RetryCount' => configuration_retry_count, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Lists WebhookInstance records from the API as a list. @@ -117,6 +168,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WebhookPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WebhookPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WebhookInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -201,7 +274,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WebhookInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new(@version, webhook_instance, response.headers, response.status_code) end ## @@ -225,6 +317,33 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebhookInstance # @param [String] configuration_url The URL of the webhook to call using the `configuration.method`. @@ -268,6 +387,55 @@ def update( ) end + ## + # Update the WebhookInstanceMetadata + # @param [String] configuration_url The URL of the webhook to call using the `configuration.method`. + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger). + # @param [Array[String]] configuration_triggers A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`. + # @param [String] configuration_flow_sid The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` = `studio`. + # @param [String] configuration_retry_count The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0. + # @return [WebhookInstance] Updated WebhookInstance + def update_with_metadata( + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset, + configuration_retry_count: :unset + ) + + data = Twilio::Values.of({ + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + 'Configuration.RetryCount' => configuration_retry_count, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -284,6 +452,45 @@ def inspect end end + class WebhookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebhookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebhookInstance] webhook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebhookInstanceMetadata] The initialized instance with metadata. + def initialize(version, webhook_instance, headers, status_code) + super(version, headers, status_code) + @webhook_instance = webhook_instance + end + + def webhook + @webhook_instance + end + + def to_s + "" + end + end + + class WebhookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook_instance = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook_instance + @instance + end + end + class WebhookPage < Page ## # Initialize the WebhookPage @@ -312,6 +519,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/role.rb b/lib/twilio-ruby/rest/chat/v2/service/role.rb index a59ee0e6b..b86412d2c 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/role.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/role.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the RoleInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [RoleType] type + # @param [Array[String]] permission A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type`. + # @return [RoleInstance] Created RoleInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + permission: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoleInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RolePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RolePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoleInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +246,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoleInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new(@version, role_instance, response.headers, response.status_code) end ## @@ -209,6 +288,32 @@ def fetch ) end + ## + # Fetch the RoleInstanceMetadata + # @return [RoleInstance] Fetched RoleInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Update the RoleInstance # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`. @@ -236,6 +341,39 @@ def update( ) end + ## + # Update the RoleInstanceMetadata + # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`. + # @return [RoleInstance] Updated RoleInstance + def update_with_metadata( + permission: nil + ) + + data = Twilio::Values.of({ + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -252,6 +390,45 @@ def inspect end end + class RoleInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoleInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoleInstance] role_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoleInstanceMetadata] The initialized instance with metadata. + def initialize(version, role_instance, headers, status_code) + super(version, headers, status_code) + @role_instance = role_instance + end + + def role + @role_instance + end + + def to_s + "" + end + end + + class RoleListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_instance = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_instance + @instance + end + end + class RolePage < Page ## # Initialize the RolePage @@ -280,6 +457,54 @@ def to_s '' end end + + class RolePageMetadata < PageMetadata + attr_reader :role_page + + def initialize(version, response, solution, limit) + super(version, response) + @role_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @role_page << RoleListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @role_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoleListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role + @role + end + end + class RoleInstance < InstanceResource ## # Initialize the RoleInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/user.rb b/lib/twilio-ruby/rest/chat/v2/service/user.rb index a6086e396..ece1a7128 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/user.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/user.rb @@ -69,6 +69,49 @@ def create( ) end + ## + # Create the UserInstanceMetadata + # @param [String] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). This value is often a username or email address. See the Identity documentation for more info. + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the new User. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [String] friendly_name A descriptive string that you create to describe the new resource. This value is often used for display purposes. + # @param [UserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Created UserInstance + def create_with_metadata( + identity: nil, + role_sid: :unset, + attributes: :unset, + friendly_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Lists UserInstance records from the API as a list. @@ -108,6 +151,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +258,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code) end ## @@ -216,6 +300,32 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the User. @@ -251,6 +361,47 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] role_sid The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the User. + # @param [String] attributes A valid JSON string that contains application-specific data. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is often used for display purposes. + # @param [UserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + role_sid: :unset, + attributes: :unset, + friendly_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Access the user_channels # @return [UserChannelList] @@ -305,6 +456,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -333,6 +523,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/chat/v2/service/user/user_binding.rb b/lib/twilio-ruby/rest/chat/v2/service/user/user_binding.rb index c4ec0aaa6..7371a139f 100644 --- a/lib/twilio-ruby/rest/chat/v2/service/user/user_binding.rb +++ b/lib/twilio-ruby/rest/chat/v2/service/user/user_binding.rb @@ -76,6 +76,31 @@ def stream(binding_type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserBindingPageMetadata records from the API as a list. + # @param [Array[BindingType]] binding_type The push technology used by the User Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. + # @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_with_metadata(binding_type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'BindingType' => Twilio.serialize_list(binding_type) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserBindingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserBindingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,7 +188,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserBindingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + userBinding_instance = UserBindingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserBindingInstanceMetadata.new(@version, userBinding_instance, response.headers, response.status_code) end ## @@ -187,6 +231,33 @@ def fetch ) end + ## + # Fetch the UserBindingInstanceMetadata + # @return [UserBindingInstance] Fetched UserBindingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + userBinding_instance = UserBindingInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + user_sid: @solution[:user_sid], + sid: @solution[:sid], + ) + UserBindingInstanceMetadata.new( + @version, + userBinding_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -203,6 +274,45 @@ def inspect end end + class UserBindingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserBindingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserBindingInstance] user_binding_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserBindingInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_binding_instance, headers, status_code) + super(version, headers, status_code) + @user_binding_instance = user_binding_instance + end + + def user_binding + @user_binding_instance + end + + def to_s + "" + end + end + + class UserBindingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_binding_instance = payload.body[key].map do |data| + UserBindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_binding_instance + @instance + end + end + class UserBindingPage < Page ## # Initialize the UserBindingPage @@ -231,6 +341,54 @@ def to_s '' end end + + class UserBindingPageMetadata < PageMetadata + attr_reader :user_binding_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_binding_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_binding_page << UserBindingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_binding_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserBindingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_binding = payload.body[key].map do |data| + UserBindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_binding + @user_binding + end + end + class UserBindingInstance < InstanceResource ## # Initialize the UserBindingInstance 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 2793cee74..594bec15b 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 @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -159,7 +181,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserChannelInstanceMetadata + # @param [UserChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + userChannel_instance = UserChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserChannelInstanceMetadata.new(@version, userChannel_instance, response.headers, response.status_code) end ## @@ -183,6 +227,33 @@ def fetch ) end + ## + # Fetch the UserChannelInstanceMetadata + # @return [UserChannelInstance] Fetched UserChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + userChannel_instance = UserChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + user_sid: @solution[:user_sid], + channel_sid: @solution[:channel_sid], + ) + UserChannelInstanceMetadata.new( + @version, + userChannel_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserChannelInstance # @param [NotificationLevel] notification_level @@ -217,6 +288,46 @@ def update( ) end + ## + # Update the UserChannelInstanceMetadata + # @param [NotificationLevel] notification_level + # @param [String] last_consumed_message_index The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) in the [Channel](https://www.twilio.com/docs/chat/channels) that the Member has read. + # @param [Time] last_consumption_timestamp The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) read event for the Member within the [Channel](https://www.twilio.com/docs/chat/channels). + # @return [UserChannelInstance] Updated UserChannelInstance + def update_with_metadata( + notification_level: :unset, + last_consumed_message_index: :unset, + last_consumption_timestamp: :unset + ) + + data = Twilio::Values.of({ + 'NotificationLevel' => notification_level, + 'LastConsumedMessageIndex' => last_consumed_message_index, + 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + userChannel_instance = UserChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + user_sid: @solution[:user_sid], + channel_sid: @solution[:channel_sid], + ) + UserChannelInstanceMetadata.new( + @version, + userChannel_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -233,6 +344,45 @@ def inspect end end + class UserChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserChannelInstance] user_channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_channel_instance, headers, status_code) + super(version, headers, status_code) + @user_channel_instance = user_channel_instance + end + + def user_channel + @user_channel_instance + end + + def to_s + "" + end + end + + class UserChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_channel_instance = payload.body[key].map do |data| + UserChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_channel_instance + @instance + end + end + class UserChannelPage < Page ## # Initialize the UserChannelPage @@ -261,6 +411,54 @@ def to_s '' end end + + class UserChannelPageMetadata < PageMetadata + attr_reader :user_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_channel_page << UserChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_channel = payload.body[key].map do |data| + UserChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_channel + @user_channel + end + end + class UserChannelInstance < InstanceResource ## # Initialize the UserChannelInstance diff --git a/lib/twilio-ruby/rest/chat/v3/channel.rb b/lib/twilio-ruby/rest/chat/v3/channel.rb index 83fa0b72b..a2579411b 100644 --- a/lib/twilio-ruby/rest/chat/v3/channel.rb +++ b/lib/twilio-ruby/rest/chat/v3/channel.rb @@ -88,6 +88,44 @@ def update( ) end + ## + # Update the ChannelInstanceMetadata + # @param [ChannelType] type + # @param [String] messaging_service_sid The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to. + # @param [ChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ChannelInstance] Updated ChannelInstance + def update_with_metadata( + 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({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -104,6 +142,45 @@ def inspect end end + class ChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelInstance] channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, channel_instance, headers, status_code) + super(version, headers, status_code) + @channel_instance = channel_instance + end + + def channel + @channel_instance + end + + def to_s + "" + end + end + + class ChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_instance = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_instance + @instance + end + end + class ChannelPage < Page ## # Initialize the ChannelPage @@ -132,6 +209,54 @@ def to_s '' end end + + class ChannelPageMetadata < PageMetadata + attr_reader :channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channel_page << ChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel + @channel + end + end + class ChannelInstance < InstanceResource ## # Initialize the ChannelInstance diff --git a/lib/twilio-ruby/rest/content/v1/content.rb b/lib/twilio-ruby/rest/content/v1/content.rb index af077f62a..fc60f6cb7 100644 --- a/lib/twilio-ruby/rest/content/v1/content.rb +++ b/lib/twilio-ruby/rest/content/v1/content.rb @@ -1294,6 +1294,32 @@ def create(content_create_request: nil ) end + ## + # Create the ContentInstanceMetadata + # @param [ContentCreateRequest] content_create_request + # @return [ContentInstance] Created ContentInstance + def create_with_metadata(content_create_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: content_create_request.to_json) + content_instance = ContentInstance.new( + @version, + response.body, + ) + ContentInstanceMetadata.new( + @version, + content_instance, + response.headers, + response.status_code + ) + end + ## # Lists ContentInstance records from the API as a list. @@ -1333,6 +1359,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ContentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ContentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ContentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -1417,7 +1465,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ContentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + content_instance = ContentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ContentInstanceMetadata.new(@version, content_instance, response.headers, response.status_code) end ## @@ -1439,6 +1506,31 @@ def fetch ) end + ## + # Fetch the ContentInstanceMetadata + # @return [ContentInstance] Fetched ContentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + content_instance = ContentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ContentInstanceMetadata.new( + @version, + content_instance, + response.headers, + response.status_code + ) + end + ## # Update the ContentInstance # @param [ContentUpdateRequest] content_update_request @@ -1460,6 +1552,33 @@ def update(content_update_request: nil ) end + ## + # Update the ContentInstanceMetadata + # @param [ContentUpdateRequest] content_update_request + # @return [ContentInstance] Updated ContentInstance + def update_with_metadata(content_update_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: content_update_request.to_json) + content_instance = ContentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ContentInstanceMetadata.new( + @version, + content_instance, + response.headers, + response.status_code + ) + end + ## # Access the approval_create # @return [ApprovalCreateList] @@ -1497,6 +1616,45 @@ def inspect end end + class ContentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ContentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ContentInstance] content_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ContentInstanceMetadata] The initialized instance with metadata. + def initialize(version, content_instance, headers, status_code) + super(version, headers, status_code) + @content_instance = content_instance + end + + def content + @content_instance + end + + def to_s + "" + end + end + + class ContentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @content_instance = payload.body[key].map do |data| + ContentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def content_instance + @instance + end + end + class ContentPage < Page ## # Initialize the ContentPage @@ -1525,6 +1683,54 @@ def to_s '' end end + + class ContentPageMetadata < PageMetadata + attr_reader :content_page + + def initialize(version, response, solution, limit) + super(version, response) + @content_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @content_page << ContentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @content_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ContentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @content = payload.body[key].map do |data| + ContentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def content + @content + end + end + class ContentInstance < InstanceResource ## # Initialize the ContentInstance diff --git a/lib/twilio-ruby/rest/content/v1/content/approval_create.rb b/lib/twilio-ruby/rest/content/v1/content/approval_create.rb index 8adc2fa31..4fd7f19d1 100644 --- a/lib/twilio-ruby/rest/content/v1/content/approval_create.rb +++ b/lib/twilio-ruby/rest/content/v1/content/approval_create.rb @@ -70,6 +70,33 @@ def create(content_approval_request: nil ) end + ## + # Create the ApprovalCreateInstanceMetadata + # @param [ContentApprovalRequest] content_approval_request + # @return [ApprovalCreateInstance] Created ApprovalCreateInstance + def create_with_metadata(content_approval_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: content_approval_request.to_json) + approvalCreate_instance = ApprovalCreateInstance.new( + @version, + response.body, + content_sid: @solution[:content_sid], + ) + ApprovalCreateInstanceMetadata.new( + @version, + approvalCreate_instance, + response.headers, + response.status_code + ) + end + @@ -107,6 +134,54 @@ def to_s '' end end + + class ApprovalCreatePageMetadata < PageMetadata + attr_reader :approval_create_page + + def initialize(version, response, solution, limit) + super(version, response) + @approval_create_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @approval_create_page << ApprovalCreateListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @approval_create_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ApprovalCreateListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @approval_create = payload.body[key].map do |data| + ApprovalCreateInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def approval_create + @approval_create + end + end + class ApprovalCreateInstance < InstanceResource ## # Initialize the ApprovalCreateInstance diff --git a/lib/twilio-ruby/rest/content/v1/content/approval_fetch.rb b/lib/twilio-ruby/rest/content/v1/content/approval_fetch.rb index 19637a146..4127cf34a 100644 --- a/lib/twilio-ruby/rest/content/v1/content/approval_fetch.rb +++ b/lib/twilio-ruby/rest/content/v1/content/approval_fetch.rb @@ -76,6 +76,31 @@ def fetch ) end + ## + # Fetch the ApprovalFetchInstanceMetadata + # @return [ApprovalFetchInstance] Fetched ApprovalFetchInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + approvalFetch_instance = ApprovalFetchInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ApprovalFetchInstanceMetadata.new( + @version, + approvalFetch_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -92,6 +117,45 @@ def inspect end end + class ApprovalFetchInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ApprovalFetchInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ApprovalFetchInstance] approval_fetch_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ApprovalFetchInstanceMetadata] The initialized instance with metadata. + def initialize(version, approval_fetch_instance, headers, status_code) + super(version, headers, status_code) + @approval_fetch_instance = approval_fetch_instance + end + + def approval_fetch + @approval_fetch_instance + end + + def to_s + "" + end + end + + class ApprovalFetchListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @approval_fetch_instance = payload.body[key].map do |data| + ApprovalFetchInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def approval_fetch_instance + @instance + end + end + class ApprovalFetchPage < Page ## # Initialize the ApprovalFetchPage @@ -120,6 +184,54 @@ def to_s '' end end + + class ApprovalFetchPageMetadata < PageMetadata + attr_reader :approval_fetch_page + + def initialize(version, response, solution, limit) + super(version, response) + @approval_fetch_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @approval_fetch_page << ApprovalFetchListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @approval_fetch_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ApprovalFetchListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @approval_fetch = payload.body[key].map do |data| + ApprovalFetchInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def approval_fetch + @approval_fetch + end + end + class ApprovalFetchInstance < InstanceResource ## # Initialize the ApprovalFetchInstance diff --git a/lib/twilio-ruby/rest/content/v1/content_and_approvals.rb b/lib/twilio-ruby/rest/content/v1/content_and_approvals.rb index 913230435..6648a8ed8 100644 --- a/lib/twilio-ruby/rest/content/v1/content_and_approvals.rb +++ b/lib/twilio-ruby/rest/content/v1/content_and_approvals.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ContentAndApprovalsPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ContentAndApprovalsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ContentAndApprovalsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -154,6 +176,54 @@ def to_s '' end end + + class ContentAndApprovalsPageMetadata < PageMetadata + attr_reader :content_and_approvals_page + + def initialize(version, response, solution, limit) + super(version, response) + @content_and_approvals_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @content_and_approvals_page << ContentAndApprovalsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @content_and_approvals_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ContentAndApprovalsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @content_and_approvals = payload.body[key].map do |data| + ContentAndApprovalsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def content_and_approvals + @content_and_approvals + end + end + class ContentAndApprovalsInstance < InstanceResource ## # Initialize the ContentAndApprovalsInstance diff --git a/lib/twilio-ruby/rest/content/v1/legacy_content.rb b/lib/twilio-ruby/rest/content/v1/legacy_content.rb index 003448d02..25f70f0ac 100644 --- a/lib/twilio-ruby/rest/content/v1/legacy_content.rb +++ b/lib/twilio-ruby/rest/content/v1/legacy_content.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists LegacyContentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + LegacyContentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields LegacyContentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -154,6 +176,54 @@ def to_s '' end end + + class LegacyContentPageMetadata < PageMetadata + attr_reader :legacy_content_page + + def initialize(version, response, solution, limit) + super(version, response) + @legacy_content_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @legacy_content_page << LegacyContentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @legacy_content_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LegacyContentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @legacy_content = payload.body[key].map do |data| + LegacyContentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def legacy_content + @legacy_content + end + end + class LegacyContentInstance < InstanceResource ## # Initialize the LegacyContentInstance diff --git a/lib/twilio-ruby/rest/content/v2/content.rb b/lib/twilio-ruby/rest/content/v2/content.rb index e871f51a6..6d05aea39 100644 --- a/lib/twilio-ruby/rest/content/v2/content.rb +++ b/lib/twilio-ruby/rest/content/v2/content.rb @@ -105,6 +105,49 @@ def stream(sort_by_date: :unset, sort_by_content_name: :unset, date_created_afte @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ContentPageMetadata records from the API as a list. + # @param [String] sort_by_date Whether to sort by ascending or descending date updated + # @param [String] sort_by_content_name Whether to sort by ascending or descending content name + # @param [Time] date_created_after Filter by >=[date-time] + # @param [Time] date_created_before Filter by <=[date-time] + # @param [String] content_name Filter by Regex Pattern in content name + # @param [String] content Filter by Regex Pattern in template content + # @param [Array[String]] language Filter by array of valid language(s) + # @param [Array[String]] content_type Filter by array of contentType(s) + # @param [Array[String]] channel_eligibility Filter by array of ChannelEligibility(s), where ChannelEligibility=: + # @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_with_metadata(sort_by_date: :unset, sort_by_content_name: :unset, date_created_after: :unset, date_created_before: :unset, content_name: :unset, content: :unset, language: :unset, content_type: :unset, channel_eligibility: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'SortByDate' => sort_by_date, + 'SortByContentName' => sort_by_content_name, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + 'ContentName' => content_name, + 'Content' => content, + + 'Language' => Twilio.serialize_list(language) { |e| e }, + + 'ContentType' => Twilio.serialize_list(content_type) { |e| e }, + + 'ChannelEligibility' => Twilio.serialize_list(channel_eligibility) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ContentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ContentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -211,6 +254,54 @@ def to_s '' end end + + class ContentPageMetadata < PageMetadata + attr_reader :content_page + + def initialize(version, response, solution, limit) + super(version, response) + @content_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @content_page << ContentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @content_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ContentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @content = payload.body[key].map do |data| + ContentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def content + @content + end + end + class ContentInstance < InstanceResource ## # Initialize the ContentInstance diff --git a/lib/twilio-ruby/rest/content/v2/content_and_approvals.rb b/lib/twilio-ruby/rest/content/v2/content_and_approvals.rb index cb01cf049..1dcd6d8a1 100644 --- a/lib/twilio-ruby/rest/content/v2/content_and_approvals.rb +++ b/lib/twilio-ruby/rest/content/v2/content_and_approvals.rb @@ -105,6 +105,49 @@ def stream(sort_by_date: :unset, sort_by_content_name: :unset, date_created_afte @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ContentAndApprovalsPageMetadata records from the API as a list. + # @param [String] sort_by_date Whether to sort by ascending or descending date updated + # @param [String] sort_by_content_name Whether to sort by ascending or descending content name + # @param [Time] date_created_after Filter by >=[date-time] + # @param [Time] date_created_before Filter by <=[date-time] + # @param [String] content_name Filter by Regex Pattern in content name + # @param [String] content Filter by Regex Pattern in template content + # @param [Array[String]] language Filter by array of valid language(s) + # @param [Array[String]] content_type Filter by array of contentType(s) + # @param [Array[String]] channel_eligibility Filter by array of ChannelEligibility(s), where ChannelEligibility=: + # @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_with_metadata(sort_by_date: :unset, sort_by_content_name: :unset, date_created_after: :unset, date_created_before: :unset, content_name: :unset, content: :unset, language: :unset, content_type: :unset, channel_eligibility: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'SortByDate' => sort_by_date, + 'SortByContentName' => sort_by_content_name, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + 'ContentName' => content_name, + 'Content' => content, + + 'Language' => Twilio.serialize_list(language) { |e| e }, + + 'ContentType' => Twilio.serialize_list(content_type) { |e| e }, + + 'ChannelEligibility' => Twilio.serialize_list(channel_eligibility) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ContentAndApprovalsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ContentAndApprovalsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -211,6 +254,54 @@ def to_s '' end end + + class ContentAndApprovalsPageMetadata < PageMetadata + attr_reader :content_and_approvals_page + + def initialize(version, response, solution, limit) + super(version, response) + @content_and_approvals_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @content_and_approvals_page << ContentAndApprovalsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @content_and_approvals_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ContentAndApprovalsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @content_and_approvals = payload.body[key].map do |data| + ContentAndApprovalsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def content_and_approvals + @content_and_approvals + end + end + class ContentAndApprovalsInstance < InstanceResource ## # Initialize the ContentAndApprovalsInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb b/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb index 1293b2d4a..91a9707e5 100644 --- a/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb +++ b/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb @@ -88,6 +88,70 @@ def create( ) end + ## + # Create the AddressConfigurationInstanceMetadata + # @param [Type] type + # @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 [AutoCreationType] auto_creation_type + # @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 [Method] auto_creation_webhook_method + # @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 + # @param [String] address_country An ISO 3166-1 alpha-2n country code which the address belongs to. This is currently only applicable to short code addresses. + # @return [AddressConfigurationInstance] Created AddressConfigurationInstance + def create_with_metadata( + 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, + address_country: :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, + 'AddressCountry' => address_country, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + addressConfiguration_instance = AddressConfigurationInstance.new( + @version, + response.body, + ) + AddressConfigurationInstanceMetadata.new( + @version, + addressConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Lists AddressConfigurationInstance records from the API as a list. @@ -131,6 +195,30 @@ def stream(type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AddressConfigurationPageMetadata records from the API as a list. + # @param [String] type Filter the address configurations by its type. This value can be one of: `whatsapp`, `sms`. + # @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_with_metadata(type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Type' => type, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AddressConfigurationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AddressConfigurationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -215,7 +303,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AddressConfigurationInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + addressConfiguration_instance = AddressConfigurationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AddressConfigurationInstanceMetadata.new(@version, addressConfiguration_instance, response.headers, response.status_code) end ## @@ -237,6 +344,31 @@ def fetch ) end + ## + # Fetch the AddressConfigurationInstanceMetadata + # @return [AddressConfigurationInstance] Fetched AddressConfigurationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + addressConfiguration_instance = AddressConfigurationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AddressConfigurationInstanceMetadata.new( + @version, + addressConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Update the AddressConfigurationInstance # @param [String] friendly_name The human-readable name of this configuration, limited to 256 characters. Optional. @@ -287,6 +419,62 @@ def update( ) end + ## + # Update the AddressConfigurationInstanceMetadata + # @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 [AutoCreationType] auto_creation_type + # @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 [Method] auto_creation_webhook_method + # @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_with_metadata( + 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, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + addressConfiguration_instance = AddressConfigurationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AddressConfigurationInstanceMetadata.new( + @version, + addressConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -303,6 +491,45 @@ def inspect end end + class AddressConfigurationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AddressConfigurationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AddressConfigurationInstance] address_configuration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AddressConfigurationInstanceMetadata] The initialized instance with metadata. + def initialize(version, address_configuration_instance, headers, status_code) + super(version, headers, status_code) + @address_configuration_instance = address_configuration_instance + end + + def address_configuration + @address_configuration_instance + end + + def to_s + "" + end + end + + class AddressConfigurationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @address_configuration_instance = payload.body[key].map do |data| + AddressConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def address_configuration_instance + @instance + end + end + class AddressConfigurationPage < Page ## # Initialize the AddressConfigurationPage @@ -331,6 +558,54 @@ def to_s '' end end + + class AddressConfigurationPageMetadata < PageMetadata + attr_reader :address_configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @address_configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @address_configuration_page << AddressConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @address_configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AddressConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @address_configuration = payload.body[key].map do |data| + AddressConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def address_configuration + @address_configuration + end + end + class AddressConfigurationInstance < InstanceResource ## # Initialize the AddressConfigurationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/configuration.rb b/lib/twilio-ruby/rest/conversations/v1/configuration.rb index cb38f9f22..ed6c8427b 100644 --- a/lib/twilio-ruby/rest/conversations/v1/configuration.rb +++ b/lib/twilio-ruby/rest/conversations/v1/configuration.rb @@ -73,6 +73,30 @@ def fetch ) end + ## + # Fetch the ConfigurationInstanceMetadata + # @return [ConfigurationInstance] Fetched ConfigurationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + configuration_instance = ConfigurationInstance.new( + @version, + response.body, + ) + ConfigurationInstanceMetadata.new( + @version, + configuration_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConfigurationInstance # @param [String] default_chat_service_sid The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation. @@ -107,6 +131,46 @@ def update( ) end + ## + # Update the ConfigurationInstanceMetadata + # @param [String] default_chat_service_sid The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation. + # @param [String] default_messaging_service_sid The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation. + # @param [String] default_inactive_timer Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + # @param [String] default_closed_timer Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + # @return [ConfigurationInstance] Updated ConfigurationInstance + def update_with_metadata( + default_chat_service_sid: :unset, + default_messaging_service_sid: :unset, + default_inactive_timer: :unset, + default_closed_timer: :unset + ) + + data = Twilio::Values.of({ + 'DefaultChatServiceSid' => default_chat_service_sid, + 'DefaultMessagingServiceSid' => default_messaging_service_sid, + 'DefaultInactiveTimer' => default_inactive_timer, + 'DefaultClosedTimer' => default_closed_timer, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + configuration_instance = ConfigurationInstance.new( + @version, + response.body, + ) + ConfigurationInstanceMetadata.new( + @version, + configuration_instance, + response.headers, + response.status_code + ) + end + ## # Access the webhooks # @return [WebhookList] @@ -132,6 +196,45 @@ def inspect end end + class ConfigurationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConfigurationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConfigurationInstance] configuration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConfigurationInstanceMetadata] The initialized instance with metadata. + def initialize(version, configuration_instance, headers, status_code) + super(version, headers, status_code) + @configuration_instance = configuration_instance + end + + def configuration + @configuration_instance + end + + def to_s + "" + end + end + + class ConfigurationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configuration_instance = payload.body[key].map do |data| + ConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configuration_instance + @instance + end + end + class ConfigurationPage < Page ## # Initialize the ConfigurationPage @@ -160,6 +263,54 @@ def to_s '' end end + + class ConfigurationPageMetadata < PageMetadata + attr_reader :configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @configuration_page << ConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configuration = payload.body[key].map do |data| + ConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configuration + @configuration + end + end + class ConfigurationInstance < InstanceResource ## # Initialize the ConfigurationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb b/lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb index e091f34f7..e497137f9 100644 --- a/lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb +++ b/lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb @@ -74,6 +74,30 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebhookInstance # @param [String] method The HTTP method to be used when sending a webhook request. @@ -111,6 +135,49 @@ def update( ) end + ## + # Update the WebhookInstanceMetadata + # @param [String] method The HTTP method to be used when sending a webhook request. + # @param [Array[String]] filters The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onMessageAdd`, `onMessageUpdate`, `onMessageRemove`, `onConversationUpdated`, `onConversationRemoved`, `onConversationAdd`, `onConversationAdded`, `onConversationRemove`, `onConversationUpdate`, `onConversationStateUpdated`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onParticipantAdd`, `onParticipantRemove`, `onParticipantUpdate`, `onDeliveryUpdated`, `onUserAdded`, `onUserUpdate`, `onUserUpdated` + # @param [String] pre_webhook_url The absolute url the pre-event webhook request should be sent to. + # @param [String] post_webhook_url The absolute url the post-event webhook request should be sent to. + # @param [Target] target + # @return [WebhookInstance] Updated WebhookInstance + def update_with_metadata( + method: :unset, + filters: :unset, + pre_webhook_url: :unset, + post_webhook_url: :unset, + target: :unset + ) + + data = Twilio::Values.of({ + 'Method' => method, + 'Filters' => Twilio.serialize_list(filters) { |e| e }, + 'PreWebhookUrl' => pre_webhook_url, + 'PostWebhookUrl' => post_webhook_url, + 'Target' => target, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -127,6 +194,45 @@ def inspect end end + class WebhookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebhookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebhookInstance] webhook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebhookInstanceMetadata] The initialized instance with metadata. + def initialize(version, webhook_instance, headers, status_code) + super(version, headers, status_code) + @webhook_instance = webhook_instance + end + + def webhook + @webhook_instance + end + + def to_s + "" + end + end + + class WebhookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook_instance = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook_instance + @instance + end + end + class WebhookPage < Page ## # Initialize the WebhookPage @@ -155,6 +261,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/conversation.rb b/lib/twilio-ruby/rest/conversations/v1/conversation.rb index e8511ce32..1fc15db11 100644 --- a/lib/twilio-ruby/rest/conversations/v1/conversation.rb +++ b/lib/twilio-ruby/rest/conversations/v1/conversation.rb @@ -87,6 +87,69 @@ def create( ) end + ## + # Create the ConversationInstanceMetadata + # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [String] messaging_service_sid The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [State] state + # @param [String] timers_inactive ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + # @param [String] timers_closed ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + # @param [String] bindings_email_address The default email address that will be used when sending outbound emails in this conversation. + # @param [String] bindings_email_name The default name that will be used when sending outbound emails in this conversation. + # @param [ConversationEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ConversationInstance] Created ConversationInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + date_created: :unset, + date_updated: :unset, + messaging_service_sid: :unset, + attributes: :unset, + state: :unset, + timers_inactive: :unset, + timers_closed: :unset, + bindings_email_address: :unset, + bindings_email_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'MessagingServiceSid' => messaging_service_sid, + 'Attributes' => attributes, + 'State' => state, + 'Timers.Inactive' => timers_inactive, + 'Timers.Closed' => timers_closed, + 'Bindings.Email.Address' => bindings_email_address, + 'Bindings.Email.Name' => bindings_email_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + ) + ConversationInstanceMetadata.new( + @version, + conversation_instance, + response.headers, + response.status_code + ) + end + ## # Lists ConversationInstance records from the API as a list. @@ -138,6 +201,34 @@ def stream(start_date: :unset, end_date: :unset, state: :unset, limit: nil, page @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConversationPageMetadata records from the API as a list. + # @param [String] start_date Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + # @param [String] end_date Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + # @param [State] state State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` + # @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_with_metadata(start_date: :unset, end_date: :unset, state: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'StartDate' => start_date, + 'EndDate' => end_date, + 'State' => state, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConversationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConversationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -232,7 +323,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ConversationInstanceMetadata + # @param [ConversationEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConversationInstanceMetadata.new(@version, conversation_instance, response.headers, response.status_code) end ## @@ -254,6 +367,31 @@ def fetch ) end + ## + # Fetch the ConversationInstanceMetadata + # @return [ConversationInstance] Fetched ConversationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ConversationInstanceMetadata.new( + @version, + conversation_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConversationInstance # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. @@ -312,6 +450,70 @@ def update( ) end + ## + # Update the ConversationInstanceMetadata + # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] messaging_service_sid The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + # @param [State] state + # @param [String] timers_inactive ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + # @param [String] timers_closed ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + # @param [String] bindings_email_address The default email address that will be used when sending outbound emails in this conversation. + # @param [String] bindings_email_name The default name that will be used when sending outbound emails in this conversation. + # @param [ConversationEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ConversationInstance] Updated ConversationInstance + def update_with_metadata( + friendly_name: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + messaging_service_sid: :unset, + state: :unset, + timers_inactive: :unset, + timers_closed: :unset, + unique_name: :unset, + bindings_email_address: :unset, + bindings_email_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'MessagingServiceSid' => messaging_service_sid, + 'State' => state, + 'Timers.Inactive' => timers_inactive, + 'Timers.Closed' => timers_closed, + 'UniqueName' => unique_name, + 'Bindings.Email.Address' => bindings_email_address, + 'Bindings.Email.Name' => bindings_email_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ConversationInstanceMetadata.new( + @version, + conversation_instance, + response.headers, + response.status_code + ) + end + ## # Access the messages # @return [MessageList] @@ -385,6 +587,45 @@ def inspect end end + class ConversationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConversationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConversationInstance] conversation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConversationInstanceMetadata] The initialized instance with metadata. + def initialize(version, conversation_instance, headers, status_code) + super(version, headers, status_code) + @conversation_instance = conversation_instance + end + + def conversation + @conversation_instance + end + + def to_s + "" + end + end + + class ConversationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conversation_instance = payload.body[key].map do |data| + ConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conversation_instance + @instance + end + end + class ConversationPage < Page ## # Initialize the ConversationPage @@ -413,6 +654,54 @@ def to_s '' end end + + class ConversationPageMetadata < PageMetadata + attr_reader :conversation_page + + def initialize(version, response, solution, limit) + super(version, response) + @conversation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @conversation_page << ConversationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @conversation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConversationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conversation = payload.body[key].map do |data| + ConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conversation + @conversation + end + end + class ConversationInstance < InstanceResource ## # Initialize the ConversationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb b/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb index c777949f9..f315e68c5 100644 --- a/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +++ b/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb @@ -84,6 +84,64 @@ def create( ) end + ## + # Create the MessageInstanceMetadata + # @param [String] author The channel specific identifier of the message's author. Defaults to `system`. + # @param [String] body The content of the message, can be up to 1,600 characters long. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. `null` if the message has not been edited. + # @param [String] attributes A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] media_sid The Media SID to be attached to the new Message. + # @param [String] content_sid The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. + # @param [String] content_variables A structurally valid JSON string that contains values to resolve Rich Content template variables. + # @param [String] subject The subject of the message, can be up to 256 characters long. + # @param [ConversationMessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + author: :unset, + body: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + media_sid: :unset, + content_sid: :unset, + content_variables: :unset, + subject: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Author' => author, + 'Body' => body, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'MediaSid' => media_sid, + 'ContentSid' => content_sid, + 'ContentVariables' => content_variables, + 'Subject' => subject, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInstance records from the API as a list. @@ -127,6 +185,30 @@ def stream(order: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @param [OrderType] order The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default. + # @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_with_metadata(order: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -216,7 +298,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MessageInstanceMetadata + # @param [ConversationMessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code) end ## @@ -239,6 +343,32 @@ def fetch ) end + ## + # Fetch the MessageInstanceMetadata + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessageInstance # @param [String] author The channel specific identifier of the message's author. Defaults to `system`. @@ -283,6 +413,56 @@ def update( ) end + ## + # Update the MessageInstanceMetadata + # @param [String] author The channel specific identifier of the message's author. Defaults to `system`. + # @param [String] body The content of the message, can be up to 1,600 characters long. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. `null` if the message has not been edited. + # @param [String] attributes A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] subject The subject of the message, can be up to 256 characters long. + # @param [ConversationMessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + author: :unset, + body: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + subject: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Author' => author, + 'Body' => body, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'Subject' => subject, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Access the delivery_receipts # @return [DeliveryReceiptList] @@ -318,6 +498,45 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInstance] message_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def message + @message_instance + end + + def to_s + "" + end + end + + class MessageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_instance = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_instance + @instance + end + end + class MessagePage < Page ## # Initialize the MessagePage @@ -346,6 +565,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb b/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb index 200e98fb6..8fc5226e5 100644 --- a/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +++ b/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DeliveryReceiptPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DeliveryReceiptPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DeliveryReceiptInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +190,33 @@ def fetch ) end + ## + # Fetch the DeliveryReceiptInstanceMetadata + # @return [DeliveryReceiptInstance] Fetched DeliveryReceiptInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + deliveryReceipt_instance = DeliveryReceiptInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + message_sid: @solution[:message_sid], + sid: @solution[:sid], + ) + DeliveryReceiptInstanceMetadata.new( + @version, + deliveryReceipt_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -184,6 +233,45 @@ def inspect end end + class DeliveryReceiptInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DeliveryReceiptInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DeliveryReceiptInstance] delivery_receipt_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DeliveryReceiptInstanceMetadata] The initialized instance with metadata. + def initialize(version, delivery_receipt_instance, headers, status_code) + super(version, headers, status_code) + @delivery_receipt_instance = delivery_receipt_instance + end + + def delivery_receipt + @delivery_receipt_instance + end + + def to_s + "" + end + end + + class DeliveryReceiptListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @delivery_receipt_instance = payload.body[key].map do |data| + DeliveryReceiptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def delivery_receipt_instance + @instance + end + end + class DeliveryReceiptPage < Page ## # Initialize the DeliveryReceiptPage @@ -212,6 +300,54 @@ def to_s '' end end + + class DeliveryReceiptPageMetadata < PageMetadata + attr_reader :delivery_receipt_page + + def initialize(version, response, solution, limit) + super(version, response) + @delivery_receipt_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @delivery_receipt_page << DeliveryReceiptListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @delivery_receipt_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DeliveryReceiptListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @delivery_receipt = payload.body[key].map do |data| + DeliveryReceiptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def delivery_receipt + @delivery_receipt + end + end + class DeliveryReceiptInstance < InstanceResource ## # Initialize the DeliveryReceiptInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb b/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb index 6ce5207f0..9747b9fa0 100644 --- a/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +++ b/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb @@ -81,6 +81,61 @@ def create( ) end + ## + # Create the ParticipantInstanceMetadata + # @param [String] identity A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters. + # @param [String] messaging_binding_address The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with proxy_address) is only null when the participant is interacting from an SDK endpoint (see the 'identity' field). + # @param [String] messaging_binding_proxy_address The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the 'identity' field). + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] messaging_binding_projected_address The address of the Twilio phone number that is used in Group MMS. Communication mask for the Conversation participant with Identity. + # @param [String] role_sid The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. + # @param [ConversationParticipantEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ParticipantInstance] Created ParticipantInstance + def create_with_metadata( + identity: :unset, + messaging_binding_address: :unset, + messaging_binding_proxy_address: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + messaging_binding_projected_address: :unset, + role_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'MessagingBinding.Address' => messaging_binding_address, + 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Lists ParticipantInstance records from the API as a list. @@ -120,6 +175,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -206,7 +283,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ParticipantInstanceMetadata + # @param [ConversationParticipantEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new(@version, participant_instance, response.headers, response.status_code) end ## @@ -229,6 +328,32 @@ def fetch ) end + ## + # Fetch the ParticipantInstanceMetadata + # @return [ParticipantInstance] Fetched ParticipantInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Update the ParticipantInstance # @param [Time] date_created The date that this resource was created. @@ -282,6 +407,65 @@ def update( ) end + ## + # Update the ParticipantInstanceMetadata + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] role_sid The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. + # @param [String] messaging_binding_proxy_address The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it. + # @param [String] messaging_binding_projected_address The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it. + # @param [String] identity A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters. + # @param [String] last_read_message_index Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant. + # @param [String] last_read_timestamp Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant. + # @param [ConversationParticipantEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ParticipantInstance] Updated ParticipantInstance + def update_with_metadata( + date_created: :unset, + date_updated: :unset, + attributes: :unset, + role_sid: :unset, + messaging_binding_proxy_address: :unset, + messaging_binding_projected_address: :unset, + identity: :unset, + last_read_message_index: :unset, + last_read_timestamp: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'RoleSid' => role_sid, + 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address, + 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address, + 'Identity' => identity, + 'LastReadMessageIndex' => last_read_message_index, + 'LastReadTimestamp' => last_read_timestamp, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -298,6 +482,45 @@ def inspect end end + class ParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ParticipantInstance] participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, participant_instance, headers, status_code) + super(version, headers, status_code) + @participant_instance = participant_instance + end + + def participant + @participant_instance + end + + def to_s + "" + end + end + + class ParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_instance = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_instance + @instance + end + end + class ParticipantPage < Page ## # Initialize the ParticipantPage @@ -326,6 +549,54 @@ def to_s '' end end + + class ParticipantPageMetadata < PageMetadata + attr_reader :participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_page << ParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant + @participant + end + end + class ParticipantInstance < InstanceResource ## # Initialize the ParticipantInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb b/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb index b3167cf2f..b90f628d8 100644 --- a/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb +++ b/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb @@ -76,6 +76,56 @@ def create( ) end + ## + # Create the WebhookInstanceMetadata + # @param [Target] target + # @param [String] configuration_url The absolute url the webhook request should be sent to. + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters The list of events, firing webhook event for this Conversation. + # @param [Array[String]] configuration_triggers The list of keywords, firing webhook event for this Conversation. + # @param [String] configuration_flow_sid The studio flow SID, where the webhook should be sent to. + # @param [String] configuration_replay_after The message index for which and it's successors the webhook will be replayed. Not set by default + # @return [WebhookInstance] Created WebhookInstance + def create_with_metadata( + target: nil, + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset, + configuration_replay_after: :unset + ) + + data = Twilio::Values.of({ + 'Target' => target, + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + 'Configuration.ReplayAfter' => configuration_replay_after, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Lists WebhookInstance records from the API as a list. @@ -115,6 +165,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WebhookPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WebhookPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WebhookInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -198,7 +270,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WebhookInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new(@version, webhook_instance, response.headers, response.status_code) end ## @@ -221,6 +312,32 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebhookInstance # @param [String] configuration_url The absolute url the webhook request should be sent to. @@ -260,6 +377,51 @@ def update( ) end + ## + # Update the WebhookInstanceMetadata + # @param [String] configuration_url The absolute url the webhook request should be sent to. + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters The list of events, firing webhook event for this Conversation. + # @param [Array[String]] configuration_triggers The list of keywords, firing webhook event for this Conversation. + # @param [String] configuration_flow_sid The studio flow SID, where the webhook should be sent to. + # @return [WebhookInstance] Updated WebhookInstance + def update_with_metadata( + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset + ) + + data = Twilio::Values.of({ + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -276,6 +438,45 @@ def inspect end end + class WebhookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebhookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebhookInstance] webhook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebhookInstanceMetadata] The initialized instance with metadata. + def initialize(version, webhook_instance, headers, status_code) + super(version, headers, status_code) + @webhook_instance = webhook_instance + end + + def webhook + @webhook_instance + end + + def to_s + "" + end + end + + class WebhookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook_instance = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook_instance + @instance + end + end + class WebhookPage < Page ## # Initialize the WebhookPage @@ -304,6 +505,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/conversation_with_participants.rb b/lib/twilio-ruby/rest/conversations/v1/conversation_with_participants.rb index da314288b..5dcda73f9 100644 --- a/lib/twilio-ruby/rest/conversations/v1/conversation_with_participants.rb +++ b/lib/twilio-ruby/rest/conversations/v1/conversation_with_participants.rb @@ -90,6 +90,72 @@ def create( ) end + ## + # Create the ConversationWithParticipantsInstanceMetadata + # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [String] messaging_service_sid The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [State] state + # @param [String] timers_inactive ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + # @param [String] timers_closed ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + # @param [String] bindings_email_address The default email address that will be used when sending outbound emails in this conversation. + # @param [String] bindings_email_name The default name that will be used when sending outbound emails in this conversation. + # @param [Array[String]] participant The participant to be added to the conversation in JSON format. The JSON object attributes are as parameters in [Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource). The maximum number of participants that can be added in a single request is 10. + # @param [ConversationWithParticipantsEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ConversationWithParticipantsInstance] Created ConversationWithParticipantsInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + date_created: :unset, + date_updated: :unset, + messaging_service_sid: :unset, + attributes: :unset, + state: :unset, + timers_inactive: :unset, + timers_closed: :unset, + bindings_email_address: :unset, + bindings_email_name: :unset, + participant: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'MessagingServiceSid' => messaging_service_sid, + 'Attributes' => attributes, + 'State' => state, + 'Timers.Inactive' => timers_inactive, + 'Timers.Closed' => timers_closed, + 'Bindings.Email.Address' => bindings_email_address, + 'Bindings.Email.Name' => bindings_email_name, + 'Participant' => Twilio.serialize_list(participant) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + conversationWithParticipants_instance = ConversationWithParticipantsInstance.new( + @version, + response.body, + ) + ConversationWithParticipantsInstanceMetadata.new( + @version, + conversationWithParticipants_instance, + response.headers, + response.status_code + ) + end + @@ -127,6 +193,54 @@ def to_s '' end end + + class ConversationWithParticipantsPageMetadata < PageMetadata + attr_reader :conversation_with_participants_page + + def initialize(version, response, solution, limit) + super(version, response) + @conversation_with_participants_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @conversation_with_participants_page << ConversationWithParticipantsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @conversation_with_participants_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConversationWithParticipantsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conversation_with_participants = payload.body[key].map do |data| + ConversationWithParticipantsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conversation_with_participants + @conversation_with_participants + end + end + class ConversationWithParticipantsInstance < InstanceResource ## # Initialize the ConversationWithParticipantsInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/credential.rb b/lib/twilio-ruby/rest/conversations/v1/credential.rb index 58e6eab49..63114dd61 100644 --- a/lib/twilio-ruby/rest/conversations/v1/credential.rb +++ b/lib/twilio-ruby/rest/conversations/v1/credential.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CredentialInstanceMetadata + # @param [PushType] type + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`. + # @param [String] private_key [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`. + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + # @param [String] secret [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. + # @return [CredentialInstance] Created CredentialInstance + def create_with_metadata( + type: nil, + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialInstance records from the API as a list. @@ -112,6 +161,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code) end ## @@ -216,6 +306,31 @@ def fetch ) end + ## + # Fetch the CredentialInstanceMetadata + # @return [CredentialInstance] Fetched CredentialInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialInstance # @param [PushType] type @@ -260,6 +375,56 @@ def update( ) end + ## + # Update the CredentialInstanceMetadata + # @param [PushType] type + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`. + # @param [String] private_key [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`. + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + # @param [String] secret [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. + # @return [CredentialInstance] Updated CredentialInstance + def update_with_metadata( + type: :unset, + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -276,6 +441,45 @@ def inspect end end + class CredentialInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialInstance] credential_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_instance, headers, status_code) + super(version, headers, status_code) + @credential_instance = credential_instance + end + + def credential + @credential_instance + end + + def to_s + "" + end + end + + class CredentialListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_instance = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_instance + @instance + end + end + class CredentialPage < Page ## # Initialize the CredentialPage @@ -304,6 +508,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/participant_conversation.rb b/lib/twilio-ruby/rest/conversations/v1/participant_conversation.rb index bf0360ba5..3a221dcc9 100644 --- a/lib/twilio-ruby/rest/conversations/v1/participant_conversation.rb +++ b/lib/twilio-ruby/rest/conversations/v1/participant_conversation.rb @@ -77,6 +77,32 @@ def stream(identity: :unset, address: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantConversationPageMetadata records from the API as a list. + # @param [String] identity A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters. + # @param [String] address A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded. + # @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_with_metadata(identity: :unset, address: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Identity' => identity, + 'Address' => address, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantConversationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantConversationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -166,6 +192,54 @@ def to_s '' end end + + class ParticipantConversationPageMetadata < PageMetadata + attr_reader :participant_conversation_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_conversation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_conversation_page << ParticipantConversationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_conversation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantConversationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_conversation = payload.body[key].map do |data| + ParticipantConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_conversation + @participant_conversation + end + end + class ParticipantConversationInstance < InstanceResource ## # Initialize the ParticipantConversationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/role.rb b/lib/twilio-ruby/rest/conversations/v1/role.rb index 5e62c34dc..9122996af 100644 --- a/lib/twilio-ruby/rest/conversations/v1/role.rb +++ b/lib/twilio-ruby/rest/conversations/v1/role.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the RoleInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [RoleType] type + # @param [Array[String]] permission A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type`. + # @return [RoleInstance] Created RoleInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + permission: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoleInstance records from the API as a list. @@ -100,6 +137,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RolePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RolePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoleInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoleInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new(@version, role_instance, response.headers, response.status_code) end ## @@ -204,6 +282,31 @@ def fetch ) end + ## + # Fetch the RoleInstanceMetadata + # @return [RoleInstance] Fetched RoleInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Update the RoleInstance # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`. @@ -230,6 +333,38 @@ def update( ) end + ## + # Update the RoleInstanceMetadata + # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`. + # @return [RoleInstance] Updated RoleInstance + def update_with_metadata( + permission: nil + ) + + data = Twilio::Values.of({ + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -246,6 +381,45 @@ def inspect end end + class RoleInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoleInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoleInstance] role_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoleInstanceMetadata] The initialized instance with metadata. + def initialize(version, role_instance, headers, status_code) + super(version, headers, status_code) + @role_instance = role_instance + end + + def role + @role_instance + end + + def to_s + "" + end + end + + class RoleListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_instance = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_instance + @instance + end + end + class RolePage < Page ## # Initialize the RolePage @@ -274,6 +448,54 @@ def to_s '' end end + + class RolePageMetadata < PageMetadata + attr_reader :role_page + + def initialize(version, response, solution, limit) + super(version, response) + @role_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @role_page << RoleListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @role_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoleListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role + @role + end + end + class RoleInstance < InstanceResource ## # Initialize the RoleInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service.rb b/lib/twilio-ruby/rest/conversations/v1/service.rb index 9aafa83c0..8c99be08d 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name The human-readable name of this service, limited to 256 characters. Optional. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -94,6 +125,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -183,7 +236,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -205,6 +277,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the participant_conversations # @return [ParticipantConversationList] @@ -329,6 +426,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -357,6 +493,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/binding.rb b/lib/twilio-ruby/rest/conversations/v1/service/binding.rb index 2a0ecde15..6eeb5e071 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/binding.rb @@ -79,6 +79,34 @@ def stream(binding_type: :unset, identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BindingPageMetadata records from the API as a list. + # @param [Array[BindingType]] binding_type The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, `fcm`, or `twilsock`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. + # @param [Array[String]] identity The identity of a [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource) this binding belongs to. See [access tokens](https://www.twilio.com/docs/conversations/create-tokens) for more details. + # @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_with_metadata(binding_type: :unset, identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'BindingType' => Twilio.serialize_list(binding_type) { |e| e }, + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BindingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BindingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,7 +196,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BindingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new(@version, binding_instance, response.headers, response.status_code) end ## @@ -191,6 +238,32 @@ def fetch ) end + ## + # Fetch the BindingInstanceMetadata + # @return [BindingInstance] Fetched BindingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new( + @version, + binding_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -207,6 +280,45 @@ def inspect end end + class BindingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BindingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BindingInstance] binding_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BindingInstanceMetadata] The initialized instance with metadata. + def initialize(version, binding_instance, headers, status_code) + super(version, headers, status_code) + @binding_instance = binding_instance + end + + def binding + @binding_instance + end + + def to_s + "" + end + end + + class BindingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding_instance = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding_instance + @instance + end + end + class BindingPage < Page ## # Initialize the BindingPage @@ -235,6 +347,54 @@ def to_s '' end end + + class BindingPageMetadata < PageMetadata + attr_reader :binding_page + + def initialize(version, response, solution, limit) + super(version, response) + @binding_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @binding_page << BindingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @binding_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BindingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding + @binding + end + end + class BindingInstance < InstanceResource ## # Initialize the BindingInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb b/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb index 67fb7ee92..d0306ed24 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb @@ -78,6 +78,31 @@ def fetch ) end + ## + # Fetch the ConfigurationInstanceMetadata + # @return [ConfigurationInstance] Fetched ConfigurationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + configuration_instance = ConfigurationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + ConfigurationInstanceMetadata.new( + @version, + configuration_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConfigurationInstance # @param [String] default_conversation_creator_role_sid The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. @@ -113,6 +138,47 @@ def update( ) end + ## + # Update the ConfigurationInstanceMetadata + # @param [String] default_conversation_creator_role_sid The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + # @param [String] default_conversation_role_sid The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + # @param [String] default_chat_service_role_sid The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + # @param [Boolean] reachability_enabled Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`. + # @return [ConfigurationInstance] Updated ConfigurationInstance + def update_with_metadata( + default_conversation_creator_role_sid: :unset, + default_conversation_role_sid: :unset, + default_chat_service_role_sid: :unset, + reachability_enabled: :unset + ) + + data = Twilio::Values.of({ + 'DefaultConversationCreatorRoleSid' => default_conversation_creator_role_sid, + 'DefaultConversationRoleSid' => default_conversation_role_sid, + 'DefaultChatServiceRoleSid' => default_chat_service_role_sid, + 'ReachabilityEnabled' => reachability_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + configuration_instance = ConfigurationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + ConfigurationInstanceMetadata.new( + @version, + configuration_instance, + response.headers, + response.status_code + ) + end + ## # Access the webhooks # @return [WebhookList] @@ -149,6 +215,45 @@ def inspect end end + class ConfigurationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConfigurationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConfigurationInstance] configuration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConfigurationInstanceMetadata] The initialized instance with metadata. + def initialize(version, configuration_instance, headers, status_code) + super(version, headers, status_code) + @configuration_instance = configuration_instance + end + + def configuration + @configuration_instance + end + + def to_s + "" + end + end + + class ConfigurationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configuration_instance = payload.body[key].map do |data| + ConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configuration_instance + @instance + end + end + class ConfigurationPage < Page ## # Initialize the ConfigurationPage @@ -177,6 +282,54 @@ def to_s '' end end + + class ConfigurationPageMetadata < PageMetadata + attr_reader :configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @configuration_page << ConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configuration = payload.body[key].map do |data| + ConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configuration + @configuration + end + end + class ConfigurationInstance < InstanceResource ## # Initialize the ConfigurationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb b/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb index b99fefc15..149808ed5 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb @@ -77,6 +77,31 @@ def fetch ) end + ## + # Fetch the NotificationInstanceMetadata + # @return [NotificationInstance] Fetched NotificationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + notification_instance = NotificationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + NotificationInstanceMetadata.new( + @version, + notification_instance, + response.headers, + response.status_code + ) + end + ## # Update the NotificationInstance # @param [Boolean] log_enabled Weather the notification logging is enabled. @@ -139,6 +164,74 @@ def update( ) end + ## + # Update the NotificationInstanceMetadata + # @param [Boolean] log_enabled Weather the notification logging is enabled. + # @param [Boolean] new_message_enabled Whether to send a notification when a new message is added to a conversation. The default is `false`. + # @param [String] new_message_template The template to use to create the notification text displayed when a new message is added to a conversation and `new_message.enabled` is `true`. + # @param [String] new_message_sound The name of the sound to play when a new message is added to a conversation and `new_message.enabled` is `true`. + # @param [Boolean] new_message_badge_count_enabled Whether the new message badge is enabled. The default is `false`. + # @param [Boolean] added_to_conversation_enabled Whether to send a notification when a participant is added to a conversation. The default is `false`. + # @param [String] added_to_conversation_template The template to use to create the notification text displayed when a participant is added to a conversation and `added_to_conversation.enabled` is `true`. + # @param [String] added_to_conversation_sound The name of the sound to play when a participant is added to a conversation and `added_to_conversation.enabled` is `true`. + # @param [Boolean] removed_from_conversation_enabled Whether to send a notification to a user when they are removed from a conversation. The default is `false`. + # @param [String] removed_from_conversation_template The template to use to create the notification text displayed to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`. + # @param [String] removed_from_conversation_sound The name of the sound to play to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`. + # @param [Boolean] new_message_with_media_enabled Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is `false`. + # @param [String] new_message_with_media_template The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation and `new_message.attachments.enabled` is `true`. + # @return [NotificationInstance] Updated NotificationInstance + def update_with_metadata( + log_enabled: :unset, + new_message_enabled: :unset, + new_message_template: :unset, + new_message_sound: :unset, + new_message_badge_count_enabled: :unset, + added_to_conversation_enabled: :unset, + added_to_conversation_template: :unset, + added_to_conversation_sound: :unset, + removed_from_conversation_enabled: :unset, + removed_from_conversation_template: :unset, + removed_from_conversation_sound: :unset, + new_message_with_media_enabled: :unset, + new_message_with_media_template: :unset + ) + + data = Twilio::Values.of({ + 'LogEnabled' => log_enabled, + 'NewMessage.Enabled' => new_message_enabled, + 'NewMessage.Template' => new_message_template, + 'NewMessage.Sound' => new_message_sound, + 'NewMessage.BadgeCountEnabled' => new_message_badge_count_enabled, + 'AddedToConversation.Enabled' => added_to_conversation_enabled, + 'AddedToConversation.Template' => added_to_conversation_template, + 'AddedToConversation.Sound' => added_to_conversation_sound, + 'RemovedFromConversation.Enabled' => removed_from_conversation_enabled, + 'RemovedFromConversation.Template' => removed_from_conversation_template, + 'RemovedFromConversation.Sound' => removed_from_conversation_sound, + 'NewMessage.WithMedia.Enabled' => new_message_with_media_enabled, + 'NewMessage.WithMedia.Template' => new_message_with_media_template, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + notification_instance = NotificationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + NotificationInstanceMetadata.new( + @version, + notification_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -155,6 +248,45 @@ def inspect end end + class NotificationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NotificationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NotificationInstance] notification_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NotificationInstanceMetadata] The initialized instance with metadata. + def initialize(version, notification_instance, headers, status_code) + super(version, headers, status_code) + @notification_instance = notification_instance + end + + def notification + @notification_instance + end + + def to_s + "" + end + end + + class NotificationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification_instance = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification_instance + @instance + end + end + class NotificationPage < Page ## # Initialize the NotificationPage @@ -183,6 +315,54 @@ def to_s '' end end + + class NotificationPageMetadata < PageMetadata + attr_reader :notification_page + + def initialize(version, response, solution, limit) + super(version, response) + @notification_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @notification_page << NotificationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @notification_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NotificationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification + @notification + end + end + class NotificationInstance < InstanceResource ## # Initialize the NotificationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb b/lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb index c18d573f9..5ca817ef0 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb @@ -77,6 +77,31 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebhookInstance # @param [String] pre_webhook_url The absolute url the pre-event webhook request should be sent to. @@ -112,6 +137,47 @@ def update( ) end + ## + # Update the WebhookInstanceMetadata + # @param [String] pre_webhook_url The absolute url the pre-event webhook request should be sent to. + # @param [String] post_webhook_url The absolute url the post-event webhook request should be sent to. + # @param [Array[String]] filters The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are `onParticipantAdd`, `onParticipantAdded`, `onDeliveryUpdated`, `onConversationUpdated`, `onConversationRemove`, `onParticipantRemove`, `onConversationUpdate`, `onMessageAdd`, `onMessageRemoved`, `onParticipantUpdated`, `onConversationAdded`, `onMessageAdded`, `onConversationAdd`, `onConversationRemoved`, `onParticipantUpdate`, `onMessageRemove`, `onMessageUpdated`, `onParticipantRemoved`, `onMessageUpdate` or `onConversationStateUpdated`. + # @param [String] method The HTTP method to be used when sending a webhook request. One of `GET` or `POST`. + # @return [WebhookInstance] Updated WebhookInstance + def update_with_metadata( + pre_webhook_url: :unset, + post_webhook_url: :unset, + filters: :unset, + method: :unset + ) + + data = Twilio::Values.of({ + 'PreWebhookUrl' => pre_webhook_url, + 'PostWebhookUrl' => post_webhook_url, + 'Filters' => Twilio.serialize_list(filters) { |e| e }, + 'Method' => method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -128,6 +194,45 @@ def inspect end end + class WebhookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebhookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebhookInstance] webhook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebhookInstanceMetadata] The initialized instance with metadata. + def initialize(version, webhook_instance, headers, status_code) + super(version, headers, status_code) + @webhook_instance = webhook_instance + end + + def webhook + @webhook_instance + end + + def to_s + "" + end + end + + class WebhookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook_instance = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook_instance + @instance + end + end + class WebhookPage < Page ## # Initialize the WebhookPage @@ -156,6 +261,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb b/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb index d9e7bc7d0..1309c91c3 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb @@ -90,6 +90,70 @@ def create( ) end + ## + # Create the ConversationInstanceMetadata + # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] messaging_service_sid The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [State] state + # @param [String] timers_inactive ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + # @param [String] timers_closed ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + # @param [String] bindings_email_address The default email address that will be used when sending outbound emails in this conversation. + # @param [String] bindings_email_name The default name that will be used when sending outbound emails in this conversation. + # @param [ServiceConversationEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ConversationInstance] Created ConversationInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset, + messaging_service_sid: :unset, + date_created: :unset, + date_updated: :unset, + state: :unset, + timers_inactive: :unset, + timers_closed: :unset, + bindings_email_address: :unset, + bindings_email_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + 'MessagingServiceSid' => messaging_service_sid, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'State' => state, + 'Timers.Inactive' => timers_inactive, + 'Timers.Closed' => timers_closed, + 'Bindings.Email.Address' => bindings_email_address, + 'Bindings.Email.Name' => bindings_email_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + ConversationInstanceMetadata.new( + @version, + conversation_instance, + response.headers, + response.status_code + ) + end + ## # Lists ConversationInstance records from the API as a list. @@ -141,6 +205,34 @@ def stream(start_date: :unset, end_date: :unset, state: :unset, limit: nil, page @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConversationPageMetadata records from the API as a list. + # @param [String] start_date Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + # @param [String] end_date Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + # @param [State] state State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` + # @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_with_metadata(start_date: :unset, end_date: :unset, state: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'StartDate' => start_date, + 'EndDate' => end_date, + 'State' => state, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConversationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConversationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -236,7 +328,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ConversationInstanceMetadata + # @param [ServiceConversationEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConversationInstanceMetadata.new(@version, conversation_instance, response.headers, response.status_code) end ## @@ -259,6 +373,32 @@ def fetch ) end + ## + # Fetch the ConversationInstanceMetadata + # @return [ConversationInstance] Fetched ConversationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + sid: @solution[:sid], + ) + ConversationInstanceMetadata.new( + @version, + conversation_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConversationInstance # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. @@ -318,6 +458,71 @@ def update( ) end + ## + # Update the ConversationInstanceMetadata + # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] messaging_service_sid The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + # @param [State] state + # @param [String] timers_inactive ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + # @param [String] timers_closed ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + # @param [String] bindings_email_address The default email address that will be used when sending outbound emails in this conversation. + # @param [String] bindings_email_name The default name that will be used when sending outbound emails in this conversation. + # @param [ServiceConversationEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ConversationInstance] Updated ConversationInstance + def update_with_metadata( + friendly_name: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + messaging_service_sid: :unset, + state: :unset, + timers_inactive: :unset, + timers_closed: :unset, + unique_name: :unset, + bindings_email_address: :unset, + bindings_email_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'MessagingServiceSid' => messaging_service_sid, + 'State' => state, + 'Timers.Inactive' => timers_inactive, + 'Timers.Closed' => timers_closed, + 'UniqueName' => unique_name, + 'Bindings.Email.Address' => bindings_email_address, + 'Bindings.Email.Name' => bindings_email_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + conversation_instance = ConversationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + sid: @solution[:sid], + ) + ConversationInstanceMetadata.new( + @version, + conversation_instance, + response.headers, + response.status_code + ) + end + ## # Access the participants # @return [ParticipantList] @@ -391,6 +596,45 @@ def inspect end end + class ConversationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConversationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConversationInstance] conversation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConversationInstanceMetadata] The initialized instance with metadata. + def initialize(version, conversation_instance, headers, status_code) + super(version, headers, status_code) + @conversation_instance = conversation_instance + end + + def conversation + @conversation_instance + end + + def to_s + "" + end + end + + class ConversationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conversation_instance = payload.body[key].map do |data| + ConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conversation_instance + @instance + end + end + class ConversationPage < Page ## # Initialize the ConversationPage @@ -419,6 +663,54 @@ def to_s '' end end + + class ConversationPageMetadata < PageMetadata + attr_reader :conversation_page + + def initialize(version, response, solution, limit) + super(version, response) + @conversation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @conversation_page << ConversationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @conversation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConversationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conversation = payload.body[key].map do |data| + ConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conversation + @conversation + end + end + class ConversationInstance < InstanceResource ## # Initialize the ConversationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb b/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb index 11eaeb49a..cd6f68cc0 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb @@ -86,6 +86,65 @@ def create( ) end + ## + # Create the MessageInstanceMetadata + # @param [String] author The channel specific identifier of the message's author. Defaults to `system`. + # @param [String] body The content of the message, can be up to 1,600 characters long. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. `null` if the message has not been edited. + # @param [String] attributes A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] media_sid The Media SID to be attached to the new Message. + # @param [String] content_sid The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. + # @param [String] content_variables A structurally valid JSON string that contains values to resolve Rich Content template variables. + # @param [String] subject The subject of the message, can be up to 256 characters long. + # @param [ServiceConversationMessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + author: :unset, + body: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + media_sid: :unset, + content_sid: :unset, + content_variables: :unset, + subject: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Author' => author, + 'Body' => body, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'MediaSid' => media_sid, + 'ContentSid' => content_sid, + 'ContentVariables' => content_variables, + 'Subject' => subject, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInstance records from the API as a list. @@ -129,6 +188,30 @@ def stream(order: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @param [OrderType] order The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending), with `asc` as the default. + # @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_with_metadata(order: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -219,7 +302,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MessageInstanceMetadata + # @param [ServiceConversationMessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code) end ## @@ -243,6 +348,33 @@ def fetch ) end + ## + # Fetch the MessageInstanceMetadata + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessageInstance # @param [String] author The channel specific identifier of the message's author. Defaults to `system`. @@ -288,6 +420,57 @@ def update( ) end + ## + # Update the MessageInstanceMetadata + # @param [String] author The channel specific identifier of the message's author. Defaults to `system`. + # @param [String] body The content of the message, can be up to 1,600 characters long. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. `null` if the message has not been edited. + # @param [String] attributes A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [String] subject The subject of the message, can be up to 256 characters long. + # @param [ServiceConversationMessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + author: :unset, + body: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + subject: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Author' => author, + 'Body' => body, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'Subject' => subject, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Access the delivery_receipts # @return [DeliveryReceiptList] @@ -323,6 +506,45 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInstance] message_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def message + @message_instance + end + + def to_s + "" + end + end + + class MessageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_instance = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_instance + @instance + end + end + class MessagePage < Page ## # Initialize the MessagePage @@ -351,6 +573,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb b/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb index 9bb5899ae..a1b829d50 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb @@ -73,6 +73,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DeliveryReceiptPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DeliveryReceiptPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DeliveryReceiptInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -171,6 +193,34 @@ def fetch ) end + ## + # Fetch the DeliveryReceiptInstanceMetadata + # @return [DeliveryReceiptInstance] Fetched DeliveryReceiptInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + deliveryReceipt_instance = DeliveryReceiptInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + message_sid: @solution[:message_sid], + sid: @solution[:sid], + ) + DeliveryReceiptInstanceMetadata.new( + @version, + deliveryReceipt_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -187,6 +237,45 @@ def inspect end end + class DeliveryReceiptInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DeliveryReceiptInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DeliveryReceiptInstance] delivery_receipt_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DeliveryReceiptInstanceMetadata] The initialized instance with metadata. + def initialize(version, delivery_receipt_instance, headers, status_code) + super(version, headers, status_code) + @delivery_receipt_instance = delivery_receipt_instance + end + + def delivery_receipt + @delivery_receipt_instance + end + + def to_s + "" + end + end + + class DeliveryReceiptListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @delivery_receipt_instance = payload.body[key].map do |data| + DeliveryReceiptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def delivery_receipt_instance + @instance + end + end + class DeliveryReceiptPage < Page ## # Initialize the DeliveryReceiptPage @@ -215,6 +304,54 @@ def to_s '' end end + + class DeliveryReceiptPageMetadata < PageMetadata + attr_reader :delivery_receipt_page + + def initialize(version, response, solution, limit) + super(version, response) + @delivery_receipt_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @delivery_receipt_page << DeliveryReceiptListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @delivery_receipt_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DeliveryReceiptListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @delivery_receipt = payload.body[key].map do |data| + DeliveryReceiptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def delivery_receipt + @delivery_receipt + end + end + class DeliveryReceiptInstance < InstanceResource ## # Initialize the DeliveryReceiptInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb b/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb index e0066b59d..9fa0a4fc9 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb @@ -83,6 +83,62 @@ def create( ) end + ## + # Create the ParticipantInstanceMetadata + # @param [String] identity A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + # @param [String] messaging_binding_address The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with `proxy_address`) is only null when the participant is interacting from an SDK endpoint (see the `identity` field). + # @param [String] messaging_binding_proxy_address The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the `identity` field). + # @param [Time] date_created The date on which this resource was created. + # @param [Time] date_updated The date on which this resource was last updated. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned. + # @param [String] messaging_binding_projected_address The address of the Twilio phone number that is used in Group MMS. + # @param [String] role_sid The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. + # @param [ServiceConversationParticipantEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ParticipantInstance] Created ParticipantInstance + def create_with_metadata( + identity: :unset, + messaging_binding_address: :unset, + messaging_binding_proxy_address: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + messaging_binding_projected_address: :unset, + role_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'MessagingBinding.Address' => messaging_binding_address, + 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Lists ParticipantInstance records from the API as a list. @@ -122,6 +178,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -209,7 +287,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ParticipantInstanceMetadata + # @param [ServiceConversationParticipantEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new(@version, participant_instance, response.headers, response.status_code) end ## @@ -233,6 +333,33 @@ def fetch ) end + ## + # Fetch the ParticipantInstanceMetadata + # @return [ParticipantInstance] Fetched ParticipantInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Update the ParticipantInstance # @param [Time] date_created The date on which this resource was created. @@ -287,6 +414,66 @@ def update( ) end + ## + # Update the ParticipantInstanceMetadata + # @param [Time] date_created The date on which this resource was created. + # @param [Time] date_updated The date on which this resource was last updated. + # @param [String] identity A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set `{}` will be returned. + # @param [String] role_sid The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. + # @param [String] messaging_binding_proxy_address The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it. + # @param [String] messaging_binding_projected_address The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it. + # @param [String] last_read_message_index Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant. + # @param [String] last_read_timestamp Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant. + # @param [ServiceConversationParticipantEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ParticipantInstance] Updated ParticipantInstance + def update_with_metadata( + date_created: :unset, + date_updated: :unset, + identity: :unset, + attributes: :unset, + role_sid: :unset, + messaging_binding_proxy_address: :unset, + messaging_binding_projected_address: :unset, + last_read_message_index: :unset, + last_read_timestamp: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Identity' => identity, + 'Attributes' => attributes, + 'RoleSid' => role_sid, + 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address, + 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address, + 'LastReadMessageIndex' => last_read_message_index, + 'LastReadTimestamp' => last_read_timestamp, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -303,6 +490,45 @@ def inspect end end + class ParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ParticipantInstance] participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, participant_instance, headers, status_code) + super(version, headers, status_code) + @participant_instance = participant_instance + end + + def participant + @participant_instance + end + + def to_s + "" + end + end + + class ParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_instance = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_instance + @instance + end + end + class ParticipantPage < Page ## # Initialize the ParticipantPage @@ -331,6 +557,54 @@ def to_s '' end end + + class ParticipantPageMetadata < PageMetadata + attr_reader :participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_page << ParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant + @participant + end + end + class ParticipantInstance < InstanceResource ## # Initialize the ParticipantInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb b/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb index 1009364c9..8cf72cef9 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb @@ -78,6 +78,57 @@ def create( ) end + ## + # Create the WebhookInstanceMetadata + # @param [Target] target + # @param [String] configuration_url The absolute url the webhook request should be sent to. + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters The list of events, firing webhook event for this Conversation. + # @param [Array[String]] configuration_triggers The list of keywords, firing webhook event for this Conversation. + # @param [String] configuration_flow_sid The studio flow SID, where the webhook should be sent to. + # @param [String] configuration_replay_after The message index for which and it's successors the webhook will be replayed. Not set by default + # @return [WebhookInstance] Created WebhookInstance + def create_with_metadata( + target: nil, + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset, + configuration_replay_after: :unset + ) + + data = Twilio::Values.of({ + 'Target' => target, + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + 'Configuration.ReplayAfter' => configuration_replay_after, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Lists WebhookInstance records from the API as a list. @@ -117,6 +168,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WebhookPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WebhookPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WebhookInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -201,7 +274,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WebhookInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new(@version, webhook_instance, response.headers, response.status_code) end ## @@ -225,6 +317,33 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebhookInstance # @param [String] configuration_url The absolute url the webhook request should be sent to. @@ -265,6 +384,52 @@ def update( ) end + ## + # Update the WebhookInstanceMetadata + # @param [String] configuration_url The absolute url the webhook request should be sent to. + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters The list of events, firing webhook event for this Conversation. + # @param [Array[String]] configuration_triggers The list of keywords, firing webhook event for this Conversation. + # @param [String] configuration_flow_sid The studio flow SID, where the webhook should be sent to. + # @return [WebhookInstance] Updated WebhookInstance + def update_with_metadata( + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset + ) + + data = Twilio::Values.of({ + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + conversation_sid: @solution[:conversation_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -281,6 +446,45 @@ def inspect end end + class WebhookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebhookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebhookInstance] webhook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebhookInstanceMetadata] The initialized instance with metadata. + def initialize(version, webhook_instance, headers, status_code) + super(version, headers, status_code) + @webhook_instance = webhook_instance + end + + def webhook + @webhook_instance + end + + def to_s + "" + end + end + + class WebhookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook_instance = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook_instance + @instance + end + end + class WebhookPage < Page ## # Initialize the WebhookPage @@ -309,6 +513,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/conversation_with_participants.rb b/lib/twilio-ruby/rest/conversations/v1/service/conversation_with_participants.rb index d3373bc6d..0bf29bdc9 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/conversation_with_participants.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/conversation_with_participants.rb @@ -93,6 +93,73 @@ def create( ) end + ## + # Create the ConversationWithParticipantsInstanceMetadata + # @param [String] friendly_name The human-readable name of this conversation, limited to 256 characters. Optional. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + # @param [Time] date_created The date that this resource was created. + # @param [Time] date_updated The date that this resource was last updated. + # @param [String] messaging_service_sid The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + # @param [String] attributes An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + # @param [State] state + # @param [String] timers_inactive ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + # @param [String] timers_closed ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + # @param [String] bindings_email_address The default email address that will be used when sending outbound emails in this conversation. + # @param [String] bindings_email_name The default name that will be used when sending outbound emails in this conversation. + # @param [Array[String]] participant The participant to be added to the conversation in JSON format. The JSON object attributes are as parameters in [Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource). The maximum number of participants that can be added in a single request is 10. + # @param [ServiceConversationWithParticipantsEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ConversationWithParticipantsInstance] Created ConversationWithParticipantsInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + date_created: :unset, + date_updated: :unset, + messaging_service_sid: :unset, + attributes: :unset, + state: :unset, + timers_inactive: :unset, + timers_closed: :unset, + bindings_email_address: :unset, + bindings_email_name: :unset, + participant: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'MessagingServiceSid' => messaging_service_sid, + 'Attributes' => attributes, + 'State' => state, + 'Timers.Inactive' => timers_inactive, + 'Timers.Closed' => timers_closed, + 'Bindings.Email.Address' => bindings_email_address, + 'Bindings.Email.Name' => bindings_email_name, + 'Participant' => Twilio.serialize_list(participant) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + conversationWithParticipants_instance = ConversationWithParticipantsInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + ConversationWithParticipantsInstanceMetadata.new( + @version, + conversationWithParticipants_instance, + response.headers, + response.status_code + ) + end + @@ -130,6 +197,54 @@ def to_s '' end end + + class ConversationWithParticipantsPageMetadata < PageMetadata + attr_reader :conversation_with_participants_page + + def initialize(version, response, solution, limit) + super(version, response) + @conversation_with_participants_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @conversation_with_participants_page << ConversationWithParticipantsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @conversation_with_participants_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConversationWithParticipantsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conversation_with_participants = payload.body[key].map do |data| + ConversationWithParticipantsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conversation_with_participants + @conversation_with_participants + end + end + class ConversationWithParticipantsInstance < InstanceResource ## # Initialize the ConversationWithParticipantsInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/participant_conversation.rb b/lib/twilio-ruby/rest/conversations/v1/service/participant_conversation.rb index 3571a10e4..a82c8b1b3 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/participant_conversation.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/participant_conversation.rb @@ -79,6 +79,32 @@ def stream(identity: :unset, address: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantConversationPageMetadata records from the API as a list. + # @param [String] identity A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters. + # @param [String] address A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded. + # @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_with_metadata(identity: :unset, address: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Identity' => identity, + 'Address' => address, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantConversationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantConversationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +194,54 @@ def to_s '' end end + + class ParticipantConversationPageMetadata < PageMetadata + attr_reader :participant_conversation_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_conversation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_conversation_page << ParticipantConversationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_conversation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantConversationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_conversation = payload.body[key].map do |data| + ParticipantConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_conversation + @participant_conversation + end + end + class ParticipantConversationInstance < InstanceResource ## # Initialize the ParticipantConversationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/role.rb b/lib/twilio-ruby/rest/conversations/v1/service/role.rb index 467a3c12f..83344a7fa 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/role.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/role.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the RoleInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new resource. It can be up to 64 characters long. + # @param [RoleType] type + # @param [Array[String]] permission A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role's `type`. + # @return [RoleInstance] Created RoleInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + permission: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoleInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RolePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RolePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoleInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +246,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoleInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new(@version, role_instance, response.headers, response.status_code) end ## @@ -209,6 +288,32 @@ def fetch ) end + ## + # Fetch the RoleInstanceMetadata + # @return [RoleInstance] Fetched RoleInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Update the RoleInstance # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`. @@ -236,6 +341,39 @@ def update( ) end + ## + # Update the RoleInstanceMetadata + # @param [Array[String]] permission A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role's `type`. + # @return [RoleInstance] Updated RoleInstance + def update_with_metadata( + permission: nil + ) + + data = Twilio::Values.of({ + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -252,6 +390,45 @@ def inspect end end + class RoleInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoleInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoleInstance] role_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoleInstanceMetadata] The initialized instance with metadata. + def initialize(version, role_instance, headers, status_code) + super(version, headers, status_code) + @role_instance = role_instance + end + + def role + @role_instance + end + + def to_s + "" + end + end + + class RoleListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_instance = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_instance + @instance + end + end + class RolePage < Page ## # Initialize the RolePage @@ -280,6 +457,54 @@ def to_s '' end end + + class RolePageMetadata < PageMetadata + attr_reader :role_page + + def initialize(version, response, solution, limit) + super(version, response) + @role_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @role_page << RoleListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @role_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoleListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role + @role + end + end + class RoleInstance < InstanceResource ## # Initialize the RoleInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/user.rb b/lib/twilio-ruby/rest/conversations/v1/service/user.rb index aba5c09b7..2925b1164 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/user.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/user.rb @@ -69,6 +69,49 @@ def create( ) end + ## + # Create the UserInstanceMetadata + # @param [String] identity The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive. + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] attributes The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned. + # @param [String] role_sid The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user. + # @param [ServiceUserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Created UserInstance + def create_with_metadata( + identity: nil, + friendly_name: :unset, + attributes: :unset, + role_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'FriendlyName' => friendly_name, + 'Attributes' => attributes, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Lists UserInstance records from the API as a list. @@ -108,6 +151,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -195,7 +260,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserInstanceMetadata + # @param [ServiceUserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code) end ## @@ -218,6 +305,32 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] friendly_name The string that you assigned to describe the resource. @@ -253,6 +366,47 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] attributes The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned. + # @param [String] role_sid The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user. + # @param [ServiceUserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + friendly_name: :unset, + attributes: :unset, + role_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Attributes' => attributes, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Access the user_conversations # @return [UserConversationList] @@ -288,6 +442,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -316,6 +509,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb b/lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb index 2ab7dbfa6..b755809ac 100644 --- a/lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb +++ b/lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserConversationPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserConversationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserConversationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserConversationInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + userConversation_instance = UserConversationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserConversationInstanceMetadata.new(@version, userConversation_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the UserConversationInstanceMetadata + # @return [UserConversationInstance] Fetched UserConversationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + userConversation_instance = UserConversationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + user_sid: @solution[:user_sid], + conversation_sid: @solution[:conversation_sid], + ) + UserConversationInstanceMetadata.new( + @version, + userConversation_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserConversationInstance # @param [NotificationLevel] notification_level @@ -214,6 +282,46 @@ def update( ) end + ## + # Update the UserConversationInstanceMetadata + # @param [NotificationLevel] notification_level + # @param [Time] last_read_timestamp The date of the last message read in conversation by the user, given in ISO 8601 format. + # @param [String] last_read_message_index The index of the last Message in the Conversation that the Participant has read. + # @return [UserConversationInstance] Updated UserConversationInstance + def update_with_metadata( + notification_level: :unset, + last_read_timestamp: :unset, + last_read_message_index: :unset + ) + + data = Twilio::Values.of({ + 'NotificationLevel' => notification_level, + 'LastReadTimestamp' => Twilio.serialize_iso8601_datetime(last_read_timestamp), + 'LastReadMessageIndex' => last_read_message_index, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + userConversation_instance = UserConversationInstance.new( + @version, + response.body, + chat_service_sid: @solution[:chat_service_sid], + user_sid: @solution[:user_sid], + conversation_sid: @solution[:conversation_sid], + ) + UserConversationInstanceMetadata.new( + @version, + userConversation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -230,6 +338,45 @@ def inspect end end + class UserConversationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserConversationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserConversationInstance] user_conversation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserConversationInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_conversation_instance, headers, status_code) + super(version, headers, status_code) + @user_conversation_instance = user_conversation_instance + end + + def user_conversation + @user_conversation_instance + end + + def to_s + "" + end + end + + class UserConversationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_conversation_instance = payload.body[key].map do |data| + UserConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_conversation_instance + @instance + end + end + class UserConversationPage < Page ## # Initialize the UserConversationPage @@ -258,6 +405,54 @@ def to_s '' end end + + class UserConversationPageMetadata < PageMetadata + attr_reader :user_conversation_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_conversation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_conversation_page << UserConversationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_conversation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserConversationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_conversation = payload.body[key].map do |data| + UserConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_conversation + @user_conversation + end + end + class UserConversationInstance < InstanceResource ## # Initialize the UserConversationInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/user.rb b/lib/twilio-ruby/rest/conversations/v1/user.rb index d455907de..6583cd049 100644 --- a/lib/twilio-ruby/rest/conversations/v1/user.rb +++ b/lib/twilio-ruby/rest/conversations/v1/user.rb @@ -66,6 +66,48 @@ def create( ) end + ## + # Create the UserInstanceMetadata + # @param [String] identity The application-defined string that uniquely identifies the resource's User within the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource). This value is often a username or an email address, and is case-sensitive. + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] attributes The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned. + # @param [String] role_sid The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user. + # @param [UserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Created UserInstance + def create_with_metadata( + identity: nil, + friendly_name: :unset, + attributes: :unset, + role_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'FriendlyName' => friendly_name, + 'Attributes' => attributes, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Lists UserInstance records from the API as a list. @@ -105,6 +147,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -191,7 +255,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserInstanceMetadata + # @param [UserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code) end ## @@ -213,6 +299,31 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] friendly_name The string that you assigned to describe the resource. @@ -247,6 +358,46 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] attributes The JSON Object string that stores application-specific data. If attributes have not been set, `{}` is returned. + # @param [String] role_sid The SID of a service-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the user. + # @param [UserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + friendly_name: :unset, + attributes: :unset, + role_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Attributes' => attributes, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Access the user_conversations # @return [UserConversationList] @@ -282,6 +433,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -310,6 +500,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb b/lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb index 47c37cd68..18ccd95cf 100644 --- a/lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb +++ b/lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserConversationPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserConversationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserConversationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -154,7 +176,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserConversationInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + userConversation_instance = UserConversationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserConversationInstanceMetadata.new(@version, userConversation_instance, response.headers, response.status_code) end ## @@ -177,6 +218,32 @@ def fetch ) end + ## + # Fetch the UserConversationInstanceMetadata + # @return [UserConversationInstance] Fetched UserConversationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + userConversation_instance = UserConversationInstance.new( + @version, + response.body, + user_sid: @solution[:user_sid], + conversation_sid: @solution[:conversation_sid], + ) + UserConversationInstanceMetadata.new( + @version, + userConversation_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserConversationInstance # @param [NotificationLevel] notification_level @@ -210,6 +277,45 @@ def update( ) end + ## + # Update the UserConversationInstanceMetadata + # @param [NotificationLevel] notification_level + # @param [Time] last_read_timestamp The date of the last message read in conversation by the user, given in ISO 8601 format. + # @param [String] last_read_message_index The index of the last Message in the Conversation that the Participant has read. + # @return [UserConversationInstance] Updated UserConversationInstance + def update_with_metadata( + notification_level: :unset, + last_read_timestamp: :unset, + last_read_message_index: :unset + ) + + data = Twilio::Values.of({ + 'NotificationLevel' => notification_level, + 'LastReadTimestamp' => Twilio.serialize_iso8601_datetime(last_read_timestamp), + 'LastReadMessageIndex' => last_read_message_index, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + userConversation_instance = UserConversationInstance.new( + @version, + response.body, + user_sid: @solution[:user_sid], + conversation_sid: @solution[:conversation_sid], + ) + UserConversationInstanceMetadata.new( + @version, + userConversation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -226,6 +332,45 @@ def inspect end end + class UserConversationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserConversationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserConversationInstance] user_conversation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserConversationInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_conversation_instance, headers, status_code) + super(version, headers, status_code) + @user_conversation_instance = user_conversation_instance + end + + def user_conversation + @user_conversation_instance + end + + def to_s + "" + end + end + + class UserConversationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_conversation_instance = payload.body[key].map do |data| + UserConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_conversation_instance + @instance + end + end + class UserConversationPage < Page ## # Initialize the UserConversationPage @@ -254,6 +399,54 @@ def to_s '' end end + + class UserConversationPageMetadata < PageMetadata + attr_reader :user_conversation_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_conversation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_conversation_page << UserConversationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_conversation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserConversationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_conversation = payload.body[key].map do |data| + UserConversationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_conversation + @user_conversation + end + end + class UserConversationInstance < InstanceResource ## # Initialize the UserConversationInstance diff --git a/lib/twilio-ruby/rest/events/v1/event_type.rb b/lib/twilio-ruby/rest/events/v1/event_type.rb index c75f8d1b6..096457d52 100644 --- a/lib/twilio-ruby/rest/events/v1/event_type.rb +++ b/lib/twilio-ruby/rest/events/v1/event_type.rb @@ -73,6 +73,30 @@ def stream(schema_id: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EventTypePageMetadata records from the API as a list. + # @param [String] schema_id A string parameter filtering the results to return only the Event Types using a given schema. + # @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_with_metadata(schema_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'SchemaId' => schema_id, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EventTypePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EventTypeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -167,6 +191,31 @@ def fetch ) end + ## + # Fetch the EventTypeInstanceMetadata + # @return [EventTypeInstance] Fetched EventTypeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + eventType_instance = EventTypeInstance.new( + @version, + response.body, + type: @solution[:type], + ) + EventTypeInstanceMetadata.new( + @version, + eventType_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -183,6 +232,45 @@ def inspect end end + class EventTypeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EventTypeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EventTypeInstance] event_type_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EventTypeInstanceMetadata] The initialized instance with metadata. + def initialize(version, event_type_instance, headers, status_code) + super(version, headers, status_code) + @event_type_instance = event_type_instance + end + + def event_type + @event_type_instance + end + + def to_s + "" + end + end + + class EventTypeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event_type_instance = payload.body[key].map do |data| + EventTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event_type_instance + @instance + end + end + class EventTypePage < Page ## # Initialize the EventTypePage @@ -211,6 +299,54 @@ def to_s '' end end + + class EventTypePageMetadata < PageMetadata + attr_reader :event_type_page + + def initialize(version, response, solution, limit) + super(version, response) + @event_type_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @event_type_page << EventTypeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @event_type_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EventTypeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event_type = payload.body[key].map do |data| + EventTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event_type + @event_type + end + end + class EventTypeInstance < InstanceResource ## # Initialize the EventTypeInstance diff --git a/lib/twilio-ruby/rest/events/v1/schema.rb b/lib/twilio-ruby/rest/events/v1/schema.rb index 1f5f7c1ae..a381c04b8 100644 --- a/lib/twilio-ruby/rest/events/v1/schema.rb +++ b/lib/twilio-ruby/rest/events/v1/schema.rb @@ -75,6 +75,31 @@ def fetch ) end + ## + # Fetch the SchemaInstanceMetadata + # @return [SchemaInstance] Fetched SchemaInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + schema_instance = SchemaInstance.new( + @version, + response.body, + id: @solution[:id], + ) + SchemaInstanceMetadata.new( + @version, + schema_instance, + response.headers, + response.status_code + ) + end + ## # Access the versions # @return [SchemaVersionList] @@ -110,6 +135,45 @@ def inspect end end + class SchemaInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SchemaInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SchemaInstance] schema_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SchemaInstanceMetadata] The initialized instance with metadata. + def initialize(version, schema_instance, headers, status_code) + super(version, headers, status_code) + @schema_instance = schema_instance + end + + def schema + @schema_instance + end + + def to_s + "" + end + end + + class SchemaListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @schema_instance = payload.body[key].map do |data| + SchemaInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def schema_instance + @instance + end + end + class SchemaPage < Page ## # Initialize the SchemaPage @@ -138,6 +202,54 @@ def to_s '' end end + + class SchemaPageMetadata < PageMetadata + attr_reader :schema_page + + def initialize(version, response, solution, limit) + super(version, response) + @schema_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @schema_page << SchemaListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @schema_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SchemaListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @schema = payload.body[key].map do |data| + SchemaInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def schema + @schema + end + end + class SchemaInstance < InstanceResource ## # Initialize the SchemaInstance diff --git a/lib/twilio-ruby/rest/events/v1/schema/schema_version.rb b/lib/twilio-ruby/rest/events/v1/schema/schema_version.rb index a27236897..ec5d811fa 100644 --- a/lib/twilio-ruby/rest/events/v1/schema/schema_version.rb +++ b/lib/twilio-ruby/rest/events/v1/schema/schema_version.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SchemaVersionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SchemaVersionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SchemaVersionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the SchemaVersionInstanceMetadata + # @return [SchemaVersionInstance] Fetched SchemaVersionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + schemaVersion_instance = SchemaVersionInstance.new( + @version, + response.body, + id: @solution[:id], + schema_version: @solution[:schema_version], + ) + SchemaVersionInstanceMetadata.new( + @version, + schemaVersion_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class SchemaVersionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SchemaVersionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SchemaVersionInstance] schema_version_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SchemaVersionInstanceMetadata] The initialized instance with metadata. + def initialize(version, schema_version_instance, headers, status_code) + super(version, headers, status_code) + @schema_version_instance = schema_version_instance + end + + def schema_version + @schema_version_instance + end + + def to_s + "" + end + end + + class SchemaVersionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @schema_version_instance = payload.body[key].map do |data| + SchemaVersionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def schema_version_instance + @instance + end + end + class SchemaVersionPage < Page ## # Initialize the SchemaVersionPage @@ -209,6 +296,54 @@ def to_s '' end end + + class SchemaVersionPageMetadata < PageMetadata + attr_reader :schema_version_page + + def initialize(version, response, solution, limit) + super(version, response) + @schema_version_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @schema_version_page << SchemaVersionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @schema_version_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SchemaVersionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @schema_version = payload.body[key].map do |data| + SchemaVersionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def schema_version + @schema_version + end + end + class SchemaVersionInstance < InstanceResource ## # Initialize the SchemaVersionInstance diff --git a/lib/twilio-ruby/rest/events/v1/sink.rb b/lib/twilio-ruby/rest/events/v1/sink.rb index ac5f66622..4791ea22b 100644 --- a/lib/twilio-ruby/rest/events/v1/sink.rb +++ b/lib/twilio-ruby/rest/events/v1/sink.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the SinkInstanceMetadata + # @param [String] description A human readable description for the Sink **This value should not contain PII.** + # @param [Object] sink_configuration The information required for Twilio to connect to the provided Sink encoded as JSON. + # @param [SinkType] sink_type + # @return [SinkInstance] Created SinkInstance + def create_with_metadata( + description: nil, + sink_configuration: nil, + sink_type: nil + ) + + data = Twilio::Values.of({ + 'Description' => description, + 'SinkConfiguration' => Twilio.serialize_object(sink_configuration), + 'SinkType' => sink_type, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + sink_instance = SinkInstance.new( + @version, + response.body, + ) + SinkInstanceMetadata.new( + @version, + sink_instance, + response.headers, + response.status_code + ) + end + ## # Lists SinkInstance records from the API as a list. @@ -108,6 +145,32 @@ def stream(in_use: :unset, status: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SinkPageMetadata records from the API as a list. + # @param [Boolean] in_use A boolean query parameter filtering the results to return sinks used/not used by a subscription. + # @param [String] status A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`. + # @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_with_metadata(in_use: :unset, status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'InUse' => in_use, + 'Status' => status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SinkPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SinkInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -196,7 +259,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SinkInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + sink_instance = SinkInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SinkInstanceMetadata.new(@version, sink_instance, response.headers, response.status_code) end ## @@ -218,6 +300,31 @@ def fetch ) end + ## + # Fetch the SinkInstanceMetadata + # @return [SinkInstance] Fetched SinkInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + sink_instance = SinkInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SinkInstanceMetadata.new( + @version, + sink_instance, + response.headers, + response.status_code + ) + end + ## # Update the SinkInstance # @param [String] description A human readable description for the Sink **This value should not contain PII.** @@ -244,6 +351,38 @@ def update( ) end + ## + # Update the SinkInstanceMetadata + # @param [String] description A human readable description for the Sink **This value should not contain PII.** + # @return [SinkInstance] Updated SinkInstance + def update_with_metadata( + description: nil + ) + + data = Twilio::Values.of({ + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + sink_instance = SinkInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SinkInstanceMetadata.new( + @version, + sink_instance, + response.headers, + response.status_code + ) + end + ## # Access the sink_test # @return [SinkTestList] @@ -282,6 +421,45 @@ def inspect end end + class SinkInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SinkInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SinkInstance] sink_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SinkInstanceMetadata] The initialized instance with metadata. + def initialize(version, sink_instance, headers, status_code) + super(version, headers, status_code) + @sink_instance = sink_instance + end + + def sink + @sink_instance + end + + def to_s + "" + end + end + + class SinkListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sink_instance = payload.body[key].map do |data| + SinkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sink_instance + @instance + end + end + class SinkPage < Page ## # Initialize the SinkPage @@ -310,6 +488,54 @@ def to_s '' end end + + class SinkPageMetadata < PageMetadata + attr_reader :sink_page + + def initialize(version, response, solution, limit) + super(version, response) + @sink_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sink_page << SinkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sink_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SinkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sink = payload.body[key].map do |data| + SinkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sink + @sink + end + end + class SinkInstance < InstanceResource ## # Initialize the SinkInstance diff --git a/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb b/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb index 861bba7d4..0dc0e988a 100644 --- a/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +++ b/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb @@ -51,6 +51,31 @@ def create ) end + ## + # Create the SinkTestInstanceMetadata + # @return [SinkTestInstance] Created SinkTestInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + sinkTest_instance = SinkTestInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SinkTestInstanceMetadata.new( + @version, + sinkTest_instance, + response.headers, + response.status_code + ) + end + @@ -88,6 +113,54 @@ def to_s '' end end + + class SinkTestPageMetadata < PageMetadata + attr_reader :sink_test_page + + def initialize(version, response, solution, limit) + super(version, response) + @sink_test_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sink_test_page << SinkTestListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sink_test_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SinkTestListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sink_test = payload.body[key].map do |data| + SinkTestInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sink_test + @sink_test + end + end + class SinkTestInstance < InstanceResource ## # Initialize the SinkTestInstance diff --git a/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb b/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb index 1cfdecfd7..b80e5053b 100644 --- a/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +++ b/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the SinkValidateInstanceMetadata + # @param [String] test_id A 34 character string that uniquely identifies the test event for a Sink being validated. + # @return [SinkValidateInstance] Created SinkValidateInstance + def create_with_metadata( + test_id: nil + ) + + data = Twilio::Values.of({ + 'TestId' => test_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + sinkValidate_instance = SinkValidateInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SinkValidateInstanceMetadata.new( + @version, + sinkValidate_instance, + response.headers, + response.status_code + ) + end + @@ -95,6 +127,54 @@ def to_s '' end end + + class SinkValidatePageMetadata < PageMetadata + attr_reader :sink_validate_page + + def initialize(version, response, solution, limit) + super(version, response) + @sink_validate_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sink_validate_page << SinkValidateListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sink_validate_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SinkValidateListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sink_validate = payload.body[key].map do |data| + SinkValidateInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sink_validate + @sink_validate + end + end + class SinkValidateInstance < InstanceResource ## # Initialize the SinkValidateInstance diff --git a/lib/twilio-ruby/rest/events/v1/subscription.rb b/lib/twilio-ruby/rest/events/v1/subscription.rb index 78740a07e..d9d0b5174 100644 --- a/lib/twilio-ruby/rest/events/v1/subscription.rb +++ b/lib/twilio-ruby/rest/events/v1/subscription.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the SubscriptionInstanceMetadata + # @param [String] description A human readable description for the Subscription **This value should not contain PII.** + # @param [String] sink_sid The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. + # @param [Array[Hash]] types An array of objects containing the subscribed Event Types + # @return [SubscriptionInstance] Created SubscriptionInstance + def create_with_metadata( + description: nil, + sink_sid: nil, + types: nil + ) + + data = Twilio::Values.of({ + 'Description' => description, + 'SinkSid' => sink_sid, + 'Types' => Twilio.serialize_list(types) { |e| Twilio.serialize_object(e) }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + subscription_instance = SubscriptionInstance.new( + @version, + response.body, + ) + SubscriptionInstanceMetadata.new( + @version, + subscription_instance, + response.headers, + response.status_code + ) + end + ## # Lists SubscriptionInstance records from the API as a list. @@ -104,6 +141,30 @@ def stream(sink_sid: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SubscriptionPageMetadata records from the API as a list. + # @param [String] sink_sid The SID of the sink that the list of Subscriptions should be filtered 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_with_metadata(sink_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'SinkSid' => sink_sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SubscriptionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SubscriptionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -189,7 +250,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SubscriptionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + subscription_instance = SubscriptionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SubscriptionInstanceMetadata.new(@version, subscription_instance, response.headers, response.status_code) end ## @@ -211,6 +291,31 @@ def fetch ) end + ## + # Fetch the SubscriptionInstanceMetadata + # @return [SubscriptionInstance] Fetched SubscriptionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + subscription_instance = SubscriptionInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SubscriptionInstanceMetadata.new( + @version, + subscription_instance, + response.headers, + response.status_code + ) + end + ## # Update the SubscriptionInstance # @param [String] description A human readable description for the Subscription. @@ -237,6 +342,38 @@ def update( ) end + ## + # Update the SubscriptionInstanceMetadata + # @param [String] description A human readable description for the Subscription. + # @return [SubscriptionInstance] Updated SubscriptionInstance + def update_with_metadata( + description: :unset + ) + + data = Twilio::Values.of({ + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + subscription_instance = SubscriptionInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SubscriptionInstanceMetadata.new( + @version, + subscription_instance, + response.headers, + response.status_code + ) + end + ## # Access the subscribed_events # @return [SubscribedEventList] @@ -272,6 +409,45 @@ def inspect end end + class SubscriptionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SubscriptionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SubscriptionInstance] subscription_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SubscriptionInstanceMetadata] The initialized instance with metadata. + def initialize(version, subscription_instance, headers, status_code) + super(version, headers, status_code) + @subscription_instance = subscription_instance + end + + def subscription + @subscription_instance + end + + def to_s + "" + end + end + + class SubscriptionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @subscription_instance = payload.body[key].map do |data| + SubscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def subscription_instance + @instance + end + end + class SubscriptionPage < Page ## # Initialize the SubscriptionPage @@ -300,6 +476,54 @@ def to_s '' end end + + class SubscriptionPageMetadata < PageMetadata + attr_reader :subscription_page + + def initialize(version, response, solution, limit) + super(version, response) + @subscription_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @subscription_page << SubscriptionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @subscription_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SubscriptionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @subscription = payload.body[key].map do |data| + SubscriptionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def subscription + @subscription + end + end + class SubscriptionInstance < InstanceResource ## # Initialize the SubscriptionInstance diff --git a/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb b/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb index 43a2c49c5..cfabb1ccf 100644 --- a/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +++ b/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the SubscribedEventInstanceMetadata + # @param [String] type Type of event being subscribed to. + # @param [String] schema_version The schema version that the Subscription should use. + # @return [SubscribedEventInstance] Created SubscribedEventInstance + def create_with_metadata( + type: nil, + schema_version: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'SchemaVersion' => schema_version, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + subscribedEvent_instance = SubscribedEventInstance.new( + @version, + response.body, + subscription_sid: @solution[:subscription_sid], + ) + SubscribedEventInstanceMetadata.new( + @version, + subscribedEvent_instance, + response.headers, + response.status_code + ) + end + ## # Lists SubscribedEventInstance records from the API as a list. @@ -100,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SubscribedEventPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SubscribedEventPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SubscribedEventInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -183,7 +240,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SubscribedEventInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + subscribedEvent_instance = SubscribedEventInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SubscribedEventInstanceMetadata.new(@version, subscribedEvent_instance, response.headers, response.status_code) end ## @@ -206,6 +282,32 @@ def fetch ) end + ## + # Fetch the SubscribedEventInstanceMetadata + # @return [SubscribedEventInstance] Fetched SubscribedEventInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + subscribedEvent_instance = SubscribedEventInstance.new( + @version, + response.body, + subscription_sid: @solution[:subscription_sid], + type: @solution[:type], + ) + SubscribedEventInstanceMetadata.new( + @version, + subscribedEvent_instance, + response.headers, + response.status_code + ) + end + ## # Update the SubscribedEventInstance # @param [String] schema_version The schema version that the Subscription should use. @@ -233,6 +335,39 @@ def update( ) end + ## + # Update the SubscribedEventInstanceMetadata + # @param [String] schema_version The schema version that the Subscription should use. + # @return [SubscribedEventInstance] Updated SubscribedEventInstance + def update_with_metadata( + schema_version: :unset + ) + + data = Twilio::Values.of({ + 'SchemaVersion' => schema_version, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + subscribedEvent_instance = SubscribedEventInstance.new( + @version, + response.body, + subscription_sid: @solution[:subscription_sid], + type: @solution[:type], + ) + SubscribedEventInstanceMetadata.new( + @version, + subscribedEvent_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -249,6 +384,45 @@ def inspect end end + class SubscribedEventInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SubscribedEventInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SubscribedEventInstance] subscribed_event_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SubscribedEventInstanceMetadata] The initialized instance with metadata. + def initialize(version, subscribed_event_instance, headers, status_code) + super(version, headers, status_code) + @subscribed_event_instance = subscribed_event_instance + end + + def subscribed_event + @subscribed_event_instance + end + + def to_s + "" + end + end + + class SubscribedEventListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @subscribed_event_instance = payload.body[key].map do |data| + SubscribedEventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def subscribed_event_instance + @instance + end + end + class SubscribedEventPage < Page ## # Initialize the SubscribedEventPage @@ -277,6 +451,54 @@ def to_s '' end end + + class SubscribedEventPageMetadata < PageMetadata + attr_reader :subscribed_event_page + + def initialize(version, response, solution, limit) + super(version, response) + @subscribed_event_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @subscribed_event_page << SubscribedEventListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @subscribed_event_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SubscribedEventListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @subscribed_event = payload.body[key].map do |data| + SubscribedEventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def subscribed_event + @subscribed_event + end + end + class SubscribedEventInstance < InstanceResource ## # Initialize the SubscribedEventInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/assessments.rb b/lib/twilio-ruby/rest/flex_api/v1/assessments.rb index c189bd83b..f1ec58369 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/assessments.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/assessments.rb @@ -84,6 +84,66 @@ def create( ) end + ## + # Create the AssessmentsInstanceMetadata + # @param [String] category_sid The SID of the category + # @param [String] category_name The name of the category + # @param [String] segment_id Segment Id of the conversation + # @param [String] agent_id The id of the Agent + # @param [Float] offset The offset of the conversation. + # @param [String] metric_id The question SID selected for assessment + # @param [String] metric_name The question name of the assessment + # @param [String] answer_text The answer text selected by user + # @param [String] answer_id The id of the answer selected by user + # @param [String] questionnaire_sid Questionnaire SID of the associated question + # @param [String] authorization The Authorization HTTP request header + # @return [AssessmentsInstance] Created AssessmentsInstance + def create_with_metadata( + category_sid: nil, + category_name: nil, + segment_id: nil, + agent_id: nil, + offset: nil, + metric_id: nil, + metric_name: nil, + answer_text: nil, + answer_id: nil, + questionnaire_sid: nil, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'CategorySid' => category_sid, + 'CategoryName' => category_name, + 'SegmentId' => segment_id, + 'AgentId' => agent_id, + 'Offset' => offset, + 'MetricId' => metric_id, + 'MetricName' => metric_name, + 'AnswerText' => answer_text, + 'AnswerId' => answer_id, + 'QuestionnaireSid' => questionnaire_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + assessments_instance = AssessmentsInstance.new( + @version, + response.body, + ) + AssessmentsInstanceMetadata.new( + @version, + assessments_instance, + response.headers, + response.status_code + ) + end + ## # Lists AssessmentsInstance records from the API as a list. @@ -131,6 +191,32 @@ def stream(authorization: :unset, segment_id: :unset, limit: nil, page_size: nil @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssessmentsPageMetadata records from the API as a list. + # @param [String] authorization The Authorization HTTP request header + # @param [String] segment_id The id of the segment. + # @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_with_metadata(authorization: :unset, segment_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Authorization' => authorization, + 'SegmentId' => segment_id, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssessmentsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssessmentsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -242,6 +328,46 @@ def update( ) end + ## + # Update the AssessmentsInstanceMetadata + # @param [Float] offset The offset of the conversation + # @param [String] answer_text The answer text selected by user + # @param [String] answer_id The id of the answer selected by user + # @param [String] authorization The Authorization HTTP request header + # @return [AssessmentsInstance] Updated AssessmentsInstance + def update_with_metadata( + offset: nil, + answer_text: nil, + answer_id: nil, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'Offset' => offset, + 'AnswerText' => answer_text, + 'AnswerId' => answer_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + assessments_instance = AssessmentsInstance.new( + @version, + response.body, + assessment_sid: @solution[:assessment_sid], + ) + AssessmentsInstanceMetadata.new( + @version, + assessments_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -258,6 +384,45 @@ def inspect end end + class AssessmentsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssessmentsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssessmentsInstance] assessments_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssessmentsInstanceMetadata] The initialized instance with metadata. + def initialize(version, assessments_instance, headers, status_code) + super(version, headers, status_code) + @assessments_instance = assessments_instance + end + + def assessments + @assessments_instance + end + + def to_s + "" + end + end + + class AssessmentsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assessments_instance = payload.body[key].map do |data| + AssessmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assessments_instance + @instance + end + end + class AssessmentsPage < Page ## # Initialize the AssessmentsPage @@ -286,6 +451,54 @@ def to_s '' end end + + class AssessmentsPageMetadata < PageMetadata + attr_reader :assessments_page + + def initialize(version, response, solution, limit) + super(version, response) + @assessments_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @assessments_page << AssessmentsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @assessments_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssessmentsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @assessments = payload.body[key].map do |data| + AssessmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def assessments + @assessments + end + end + class AssessmentsInstance < InstanceResource ## # Initialize the AssessmentsInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/channel.rb b/lib/twilio-ruby/rest/flex_api/v1/channel.rb index 67655157e..e66717e6c 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/channel.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/channel.rb @@ -82,6 +82,64 @@ def create( ) end + ## + # Create the ChannelInstanceMetadata + # @param [String] flex_flow_sid The SID of the Flex Flow. + # @param [String] identity The `identity` value that uniquely identifies the new resource's chat User. + # @param [String] chat_user_friendly_name The chat participant's friendly name. + # @param [String] chat_friendly_name The chat channel's friendly name. + # @param [String] target The Target Contact Identity, for example the phone number of an SMS. + # @param [String] chat_unique_name The chat channel's unique name. + # @param [String] pre_engagement_data The pre-engagement data. + # @param [String] task_sid The SID of the TaskRouter Task. Only valid when integration type is `task`. `null` for integration types `studio` & `external` + # @param [String] task_attributes The Task attributes to be added for the TaskRouter Task. + # @param [Boolean] long_lived Whether to create the channel as long-lived. + # @return [ChannelInstance] Created ChannelInstance + def create_with_metadata( + flex_flow_sid: nil, + identity: nil, + chat_user_friendly_name: nil, + chat_friendly_name: nil, + target: :unset, + chat_unique_name: :unset, + pre_engagement_data: :unset, + task_sid: :unset, + task_attributes: :unset, + long_lived: :unset + ) + + data = Twilio::Values.of({ + 'FlexFlowSid' => flex_flow_sid, + 'Identity' => identity, + 'ChatUserFriendlyName' => chat_user_friendly_name, + 'ChatFriendlyName' => chat_friendly_name, + 'Target' => target, + 'ChatUniqueName' => chat_unique_name, + 'PreEngagementData' => pre_engagement_data, + 'TaskSid' => task_sid, + 'TaskAttributes' => task_attributes, + 'LongLived' => long_lived, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChannelInstance records from the API as a list. @@ -121,6 +179,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -203,7 +283,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ChannelInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new(@version, channel_instance, response.headers, response.status_code) end ## @@ -225,6 +324,31 @@ def fetch ) end + ## + # Fetch the ChannelInstanceMetadata + # @return [ChannelInstance] Fetched ChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -241,6 +365,45 @@ def inspect end end + class ChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelInstance] channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, channel_instance, headers, status_code) + super(version, headers, status_code) + @channel_instance = channel_instance + end + + def channel + @channel_instance + end + + def to_s + "" + end + end + + class ChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_instance = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_instance + @instance + end + end + class ChannelPage < Page ## # Initialize the ChannelPage @@ -269,6 +432,54 @@ def to_s '' end end + + class ChannelPageMetadata < PageMetadata + attr_reader :channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channel_page << ChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel + @channel + end + end + class ChannelInstance < InstanceResource ## # Initialize the ChannelInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/configuration.rb b/lib/twilio-ruby/rest/flex_api/v1/configuration.rb index 89b963600..001f26d7d 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/configuration.rb @@ -78,6 +78,36 @@ def fetch( ) end + ## + # Fetch the ConfigurationInstanceMetadata + # @param [String] ui_version The Pinned UI version of the Configuration resource to fetch. + # @return [ConfigurationInstance] Fetched ConfigurationInstance + def fetch_with_metadata( + ui_version: :unset + ) + + params = Twilio::Values.of({ + 'UiVersion' => ui_version, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + configuration_instance = ConfigurationInstance.new( + @version, + response.body, + ) + ConfigurationInstanceMetadata.new( + @version, + configuration_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConfigurationInstance # @param [Object] body @@ -98,6 +128,32 @@ def update(body: :unset ) end + ## + # Update the ConfigurationInstanceMetadata + # @param [Object] body + # @return [ConfigurationInstance] Updated ConfigurationInstance + def update_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers, data: body.to_json) + configuration_instance = ConfigurationInstance.new( + @version, + response.body, + ) + ConfigurationInstanceMetadata.new( + @version, + configuration_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -114,6 +170,45 @@ def inspect end end + class ConfigurationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConfigurationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConfigurationInstance] configuration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConfigurationInstanceMetadata] The initialized instance with metadata. + def initialize(version, configuration_instance, headers, status_code) + super(version, headers, status_code) + @configuration_instance = configuration_instance + end + + def configuration + @configuration_instance + end + + def to_s + "" + end + end + + class ConfigurationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configuration_instance = payload.body[key].map do |data| + ConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configuration_instance + @instance + end + end + class ConfigurationPage < Page ## # Initialize the ConfigurationPage @@ -142,6 +237,54 @@ def to_s '' end end + + class ConfigurationPageMetadata < PageMetadata + attr_reader :configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @configuration_page << ConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configuration = payload.body[key].map do |data| + ConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configuration + @configuration + end + end + class ConfigurationInstance < InstanceResource ## # Initialize the ConfigurationInstance 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 e2b4dbc8c..3551df79e 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb @@ -103,6 +103,85 @@ def create( ) end + ## + # Create the FlexFlowInstanceMetadata + # @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 [ChannelType] channel_type + # @param [String] contact_identity The channel contact's Identity. + # @param [Boolean] enabled Whether the new Flex Flow is enabled. + # @param [IntegrationType] integration_type + # @param [String] integration_flow_sid The SID of the Studio Flow. Required when `integrationType` is `studio`. + # @param [String] integration_url The URL of the external webhook. Required when `integrationType` is `external`. + # @param [String] integration_workspace_sid The Workspace SID for a new Task. Required when `integrationType` is `task`. + # @param [String] integration_workflow_sid The Workflow SID for a new Task. Required when `integrationType` is `task`. + # @param [String] integration_channel The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`. + # @param [String] integration_timeout The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise. + # @param [String] integration_priority The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise. + # @param [Boolean] integration_creation_on_message In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging. + # @param [Boolean] long_lived When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`. + # @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 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_with_metadata( + 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({ + 'FriendlyName' => friendly_name, + 'ChatServiceSid' => chat_service_sid, + 'ChannelType' => channel_type, + 'ContactIdentity' => contact_identity, + 'Enabled' => enabled, + 'IntegrationType' => integration_type, + 'Integration.FlowSid' => integration_flow_sid, + 'Integration.Url' => integration_url, + 'Integration.WorkspaceSid' => integration_workspace_sid, + 'Integration.WorkflowSid' => integration_workflow_sid, + 'Integration.Channel' => integration_channel, + 'Integration.Timeout' => integration_timeout, + 'Integration.Priority' => integration_priority, + 'Integration.CreationOnMessage' => integration_creation_on_message, + 'LongLived' => long_lived, + 'JanitorEnabled' => janitor_enabled, + 'Integration.RetryCount' => integration_retry_count, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + flexFlow_instance = FlexFlowInstance.new( + @version, + response.body, + ) + FlexFlowInstanceMetadata.new( + @version, + flexFlow_instance, + response.headers, + response.status_code + ) + end + ## # Lists FlexFlowInstance records from the API as a list. @@ -146,6 +225,30 @@ def stream(friendly_name: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FlexFlowPageMetadata records from the API as a list. + # @param [String] friendly_name The `friendly_name` of the Flex Flow resources to read. + # @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_with_metadata(friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FlexFlowPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FlexFlowInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -230,7 +333,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the FlexFlowInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + flexFlow_instance = FlexFlowInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + FlexFlowInstanceMetadata.new(@version, flexFlow_instance, response.headers, response.status_code) end ## @@ -252,6 +374,31 @@ def fetch ) end + ## + # Fetch the FlexFlowInstanceMetadata + # @return [FlexFlowInstance] Fetched FlexFlowInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + flexFlow_instance = FlexFlowInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FlexFlowInstanceMetadata.new( + @version, + flexFlow_instance, + response.headers, + response.status_code + ) + end + ## # Update the FlexFlowInstance # @param [String] friendly_name A descriptive string that you create to describe the Flex Flow resource. @@ -326,6 +473,86 @@ def update( ) end + ## + # Update the FlexFlowInstanceMetadata + # @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 [ChannelType] channel_type + # @param [String] contact_identity The channel contact's Identity. + # @param [Boolean] enabled Whether the new Flex Flow is enabled. + # @param [IntegrationType] integration_type + # @param [String] integration_flow_sid The SID of the Studio Flow. Required when `integrationType` is `studio`. + # @param [String] integration_url The URL of the external webhook. Required when `integrationType` is `external`. + # @param [String] integration_workspace_sid The Workspace SID for a new Task. Required when `integrationType` is `task`. + # @param [String] integration_workflow_sid The Workflow SID for a new Task. Required when `integrationType` is `task`. + # @param [String] integration_channel The Task Channel SID (TCXXXX) or unique name (e.g., `sms`) to use for the Task that will be created. Applicable and required when `integrationType` is `task`. The default value is `default`. + # @param [String] integration_timeout The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when `integrationType` is `task`, not applicable otherwise. + # @param [String] integration_priority The Task priority of a new Task. The default priority is 0. Optional when `integrationType` is `task`, not applicable otherwise. + # @param [Boolean] integration_creation_on_message In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging. + # @param [Boolean] long_lived When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to `false`. + # @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 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_with_metadata( + 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({ + 'FriendlyName' => friendly_name, + 'ChatServiceSid' => chat_service_sid, + 'ChannelType' => channel_type, + 'ContactIdentity' => contact_identity, + 'Enabled' => enabled, + 'IntegrationType' => integration_type, + 'Integration.FlowSid' => integration_flow_sid, + 'Integration.Url' => integration_url, + 'Integration.WorkspaceSid' => integration_workspace_sid, + 'Integration.WorkflowSid' => integration_workflow_sid, + 'Integration.Channel' => integration_channel, + 'Integration.Timeout' => integration_timeout, + 'Integration.Priority' => integration_priority, + 'Integration.CreationOnMessage' => integration_creation_on_message, + 'LongLived' => long_lived, + 'JanitorEnabled' => janitor_enabled, + 'Integration.RetryCount' => integration_retry_count, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + flexFlow_instance = FlexFlowInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FlexFlowInstanceMetadata.new( + @version, + flexFlow_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -342,6 +569,45 @@ def inspect end end + class FlexFlowInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FlexFlowInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FlexFlowInstance] flex_flow_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FlexFlowInstanceMetadata] The initialized instance with metadata. + def initialize(version, flex_flow_instance, headers, status_code) + super(version, headers, status_code) + @flex_flow_instance = flex_flow_instance + end + + def flex_flow + @flex_flow_instance + end + + def to_s + "" + end + end + + class FlexFlowListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flex_flow_instance = payload.body[key].map do |data| + FlexFlowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flex_flow_instance + @instance + end + end + class FlexFlowPage < Page ## # Initialize the FlexFlowPage @@ -370,6 +636,54 @@ def to_s '' end end + + class FlexFlowPageMetadata < PageMetadata + attr_reader :flex_flow_page + + def initialize(version, response, solution, limit) + super(version, response) + @flex_flow_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @flex_flow_page << FlexFlowListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @flex_flow_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FlexFlowListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flex_flow = payload.body[key].map do |data| + FlexFlowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flex_flow + @flex_flow + end + end + class FlexFlowInstance < InstanceResource ## # Initialize the FlexFlowInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_assessments_comment.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_assessments_comment.rb index d4080d1e2..0576ed070 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_assessments_comment.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_assessments_comment.rb @@ -72,6 +72,54 @@ def create( ) end + ## + # Create the InsightsAssessmentsCommentInstanceMetadata + # @param [String] category_id The ID of the category + # @param [String] category_name The name of the category + # @param [String] comment The Assessment comment. + # @param [String] segment_id The id of the segment. + # @param [String] agent_id The id of the agent. + # @param [Float] offset The offset + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsAssessmentsCommentInstance] Created InsightsAssessmentsCommentInstance + def create_with_metadata( + category_id: nil, + category_name: nil, + comment: nil, + segment_id: nil, + agent_id: nil, + offset: nil, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'CategoryId' => category_id, + 'CategoryName' => category_name, + 'Comment' => comment, + 'SegmentId' => segment_id, + 'AgentId' => agent_id, + 'Offset' => offset, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + insightsAssessmentsComment_instance = InsightsAssessmentsCommentInstance.new( + @version, + response.body, + ) + InsightsAssessmentsCommentInstanceMetadata.new( + @version, + insightsAssessmentsComment_instance, + response.headers, + response.status_code + ) + end + ## # Lists InsightsAssessmentsCommentInstance records from the API as a list. @@ -123,6 +171,34 @@ def stream(authorization: :unset, segment_id: :unset, agent_id: :unset, limit: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InsightsAssessmentsCommentPageMetadata records from the API as a list. + # @param [String] authorization The Authorization HTTP request header + # @param [String] segment_id The id of the segment. + # @param [String] agent_id The id of the agent. + # @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_with_metadata(authorization: :unset, segment_id: :unset, agent_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Authorization' => authorization, + 'SegmentId' => segment_id, + 'AgentId' => agent_id, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InsightsAssessmentsCommentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InsightsAssessmentsCommentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -214,6 +290,54 @@ def to_s '' end end + + class InsightsAssessmentsCommentPageMetadata < PageMetadata + attr_reader :insights_assessments_comment_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_assessments_comment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_assessments_comment_page << InsightsAssessmentsCommentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_assessments_comment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsAssessmentsCommentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_assessments_comment = payload.body[key].map do |data| + InsightsAssessmentsCommentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_assessments_comment + @insights_assessments_comment + end + end + class InsightsAssessmentsCommentInstance < InstanceResource ## # Initialize the InsightsAssessmentsCommentInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_conversations.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_conversations.rb index 2e872f6c9..ead8daf3d 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_conversations.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_conversations.rb @@ -77,6 +77,32 @@ def stream(authorization: :unset, segment_id: :unset, limit: nil, page_size: nil @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InsightsConversationsPageMetadata records from the API as a list. + # @param [String] authorization The Authorization HTTP request header + # @param [String] segment_id Unique Id of the segment for which conversation details needs to be fetched + # @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_with_metadata(authorization: :unset, segment_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Authorization' => authorization, + 'SegmentId' => segment_id, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InsightsConversationsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InsightsConversationsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -166,6 +192,54 @@ def to_s '' end end + + class InsightsConversationsPageMetadata < PageMetadata + attr_reader :insights_conversations_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_conversations_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_conversations_page << InsightsConversationsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_conversations_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsConversationsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_conversations = payload.body[key].map do |data| + InsightsConversationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_conversations + @insights_conversations + end + end + class InsightsConversationsInstance < InstanceResource ## # Initialize the InsightsConversationsInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires.rb index 1560eb75e..a90351382 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires.rb @@ -66,6 +66,48 @@ def create( ) end + ## + # Create the InsightsQuestionnairesInstanceMetadata + # @param [String] name The name of this questionnaire + # @param [String] description The description of this questionnaire + # @param [Boolean] active The flag to enable or disable questionnaire + # @param [Array[String]] question_sids The list of questions sids under a questionnaire + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsQuestionnairesInstance] Created InsightsQuestionnairesInstance + def create_with_metadata( + name: nil, + description: :unset, + active: :unset, + question_sids: :unset, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'Name' => name, + 'Description' => description, + 'Active' => active, + 'QuestionSids' => Twilio.serialize_list(question_sids) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + insightsQuestionnaires_instance = InsightsQuestionnairesInstance.new( + @version, + response.body, + ) + InsightsQuestionnairesInstanceMetadata.new( + @version, + insightsQuestionnaires_instance, + response.headers, + response.status_code + ) + end + ## # Lists InsightsQuestionnairesInstance records from the API as a list. @@ -113,6 +155,32 @@ def stream(authorization: :unset, include_inactive: :unset, limit: nil, page_siz @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InsightsQuestionnairesPageMetadata records from the API as a list. + # @param [String] authorization The Authorization HTTP request header + # @param [Boolean] include_inactive Flag indicating whether to include inactive questionnaires or not + # @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_with_metadata(authorization: :unset, include_inactive: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Authorization' => authorization, + 'IncludeInactive' => include_inactive, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InsightsQuestionnairesPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InsightsQuestionnairesInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -202,7 +270,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InsightsQuestionnairesInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + insightsQuestionnaires_instance = InsightsQuestionnairesInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InsightsQuestionnairesInstanceMetadata.new(@version, insightsQuestionnaires_instance, response.headers, response.status_code) end ## @@ -227,6 +317,34 @@ def fetch( ) end + ## + # Fetch the InsightsQuestionnairesInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsQuestionnairesInstance] Fetched InsightsQuestionnairesInstance + def fetch_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + insightsQuestionnaires_instance = InsightsQuestionnairesInstance.new( + @version, + response.body, + questionnaire_sid: @solution[:questionnaire_sid], + ) + InsightsQuestionnairesInstanceMetadata.new( + @version, + insightsQuestionnaires_instance, + response.headers, + response.status_code + ) + end + ## # Update the InsightsQuestionnairesInstance # @param [Boolean] active The flag to enable or disable questionnaire @@ -264,6 +382,49 @@ def update( ) end + ## + # Update the InsightsQuestionnairesInstanceMetadata + # @param [Boolean] active The flag to enable or disable questionnaire + # @param [String] name The name of this questionnaire + # @param [String] description The description of this questionnaire + # @param [Array[String]] question_sids The list of questions sids under a questionnaire + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsQuestionnairesInstance] Updated InsightsQuestionnairesInstance + def update_with_metadata( + active: nil, + name: :unset, + description: :unset, + question_sids: :unset, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'Active' => active, + 'Name' => name, + 'Description' => description, + 'QuestionSids' => Twilio.serialize_list(question_sids) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + insightsQuestionnaires_instance = InsightsQuestionnairesInstance.new( + @version, + response.body, + questionnaire_sid: @solution[:questionnaire_sid], + ) + InsightsQuestionnairesInstanceMetadata.new( + @version, + insightsQuestionnaires_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -280,6 +441,45 @@ def inspect end end + class InsightsQuestionnairesInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InsightsQuestionnairesInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InsightsQuestionnairesInstance] insights_questionnaires_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InsightsQuestionnairesInstanceMetadata] The initialized instance with metadata. + def initialize(version, insights_questionnaires_instance, headers, status_code) + super(version, headers, status_code) + @insights_questionnaires_instance = insights_questionnaires_instance + end + + def insights_questionnaires + @insights_questionnaires_instance + end + + def to_s + "" + end + end + + class InsightsQuestionnairesListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_questionnaires_instance = payload.body[key].map do |data| + InsightsQuestionnairesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_questionnaires_instance + @instance + end + end + class InsightsQuestionnairesPage < Page ## # Initialize the InsightsQuestionnairesPage @@ -308,6 +508,54 @@ def to_s '' end end + + class InsightsQuestionnairesPageMetadata < PageMetadata + attr_reader :insights_questionnaires_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_questionnaires_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_questionnaires_page << InsightsQuestionnairesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_questionnaires_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsQuestionnairesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_questionnaires = payload.body[key].map do |data| + InsightsQuestionnairesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_questionnaires + @insights_questionnaires + end + end + class InsightsQuestionnairesInstance < InstanceResource ## # Initialize the InsightsQuestionnairesInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_category.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_category.rb index b00ec179c..5b23b6eaf 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_category.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_category.rb @@ -57,6 +57,39 @@ def create( ) end + ## + # Create the InsightsQuestionnairesCategoryInstanceMetadata + # @param [String] name The name of this category. + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsQuestionnairesCategoryInstance] Created InsightsQuestionnairesCategoryInstance + def create_with_metadata( + name: nil, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'Name' => name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + insightsQuestionnairesCategory_instance = InsightsQuestionnairesCategoryInstance.new( + @version, + response.body, + ) + InsightsQuestionnairesCategoryInstanceMetadata.new( + @version, + insightsQuestionnairesCategory_instance, + response.headers, + response.status_code + ) + end + ## # Lists InsightsQuestionnairesCategoryInstance records from the API as a list. @@ -100,6 +133,30 @@ def stream(authorization: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InsightsQuestionnairesCategoryPageMetadata records from the API as a list. + # @param [String] authorization The Authorization HTTP request header + # @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_with_metadata(authorization: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Authorization' => authorization, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InsightsQuestionnairesCategoryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InsightsQuestionnairesCategoryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -187,7 +244,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InsightsQuestionnairesCategoryInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + insightsQuestionnairesCategory_instance = InsightsQuestionnairesCategoryInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InsightsQuestionnairesCategoryInstanceMetadata.new(@version, insightsQuestionnairesCategory_instance, response.headers, response.status_code) end ## @@ -218,6 +297,40 @@ def update( ) end + ## + # Update the InsightsQuestionnairesCategoryInstanceMetadata + # @param [String] name The name of this category. + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsQuestionnairesCategoryInstance] Updated InsightsQuestionnairesCategoryInstance + def update_with_metadata( + name: nil, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'Name' => name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + insightsQuestionnairesCategory_instance = InsightsQuestionnairesCategoryInstance.new( + @version, + response.body, + category_sid: @solution[:category_sid], + ) + InsightsQuestionnairesCategoryInstanceMetadata.new( + @version, + insightsQuestionnairesCategory_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -234,6 +347,45 @@ def inspect end end + class InsightsQuestionnairesCategoryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InsightsQuestionnairesCategoryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InsightsQuestionnairesCategoryInstance] insights_questionnaires_category_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InsightsQuestionnairesCategoryInstanceMetadata] The initialized instance with metadata. + def initialize(version, insights_questionnaires_category_instance, headers, status_code) + super(version, headers, status_code) + @insights_questionnaires_category_instance = insights_questionnaires_category_instance + end + + def insights_questionnaires_category + @insights_questionnaires_category_instance + end + + def to_s + "" + end + end + + class InsightsQuestionnairesCategoryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_questionnaires_category_instance = payload.body[key].map do |data| + InsightsQuestionnairesCategoryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_questionnaires_category_instance + @instance + end + end + class InsightsQuestionnairesCategoryPage < Page ## # Initialize the InsightsQuestionnairesCategoryPage @@ -262,6 +414,54 @@ def to_s '' end end + + class InsightsQuestionnairesCategoryPageMetadata < PageMetadata + attr_reader :insights_questionnaires_category_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_questionnaires_category_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_questionnaires_category_page << InsightsQuestionnairesCategoryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_questionnaires_category_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsQuestionnairesCategoryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_questionnaires_category = payload.body[key].map do |data| + InsightsQuestionnairesCategoryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_questionnaires_category + @insights_questionnaires_category + end + end + class InsightsQuestionnairesCategoryInstance < InstanceResource ## # Initialize the InsightsQuestionnairesCategoryInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_question.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_question.rb index 688b0f41c..0df2ccb11 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_question.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_question.rb @@ -69,6 +69,51 @@ def create( ) end + ## + # Create the InsightsQuestionnairesQuestionInstanceMetadata + # @param [String] category_sid The SID of the category + # @param [String] question The question. + # @param [String] answer_set_id The answer_set for the question. + # @param [Boolean] allow_na The flag to enable for disable NA for answer. + # @param [String] description The description for the question. + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsQuestionnairesQuestionInstance] Created InsightsQuestionnairesQuestionInstance + def create_with_metadata( + category_sid: nil, + question: nil, + answer_set_id: nil, + allow_na: nil, + description: :unset, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'CategorySid' => category_sid, + 'Question' => question, + 'AnswerSetId' => answer_set_id, + 'AllowNa' => allow_na, + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + insightsQuestionnairesQuestion_instance = InsightsQuestionnairesQuestionInstance.new( + @version, + response.body, + ) + InsightsQuestionnairesQuestionInstanceMetadata.new( + @version, + insightsQuestionnairesQuestion_instance, + response.headers, + response.status_code + ) + end + ## # Lists InsightsQuestionnairesQuestionInstance records from the API as a list. @@ -116,6 +161,33 @@ def stream(authorization: :unset, category_sid: :unset, limit: nil, page_size: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InsightsQuestionnairesQuestionPageMetadata records from the API as a list. + # @param [String] authorization The Authorization HTTP request header + # @param [Array[String]] category_sid The list of category SIDs + # @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_with_metadata(authorization: :unset, category_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Authorization' => authorization, + + 'CategorySid' => Twilio.serialize_list(category_sid) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InsightsQuestionnairesQuestionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InsightsQuestionnairesQuestionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -206,7 +278,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InsightsQuestionnairesQuestionInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + insightsQuestionnairesQuestion_instance = InsightsQuestionnairesQuestionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InsightsQuestionnairesQuestionInstanceMetadata.new(@version, insightsQuestionnairesQuestion_instance, response.headers, response.status_code) end ## @@ -249,6 +343,52 @@ def update( ) end + ## + # Update the InsightsQuestionnairesQuestionInstanceMetadata + # @param [Boolean] allow_na The flag to enable for disable NA for answer. + # @param [String] category_sid The SID of the category + # @param [String] question The question. + # @param [String] description The description for the question. + # @param [String] answer_set_id The answer_set for the question. + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsQuestionnairesQuestionInstance] Updated InsightsQuestionnairesQuestionInstance + def update_with_metadata( + allow_na: nil, + category_sid: :unset, + question: :unset, + description: :unset, + answer_set_id: :unset, + authorization: :unset + ) + + data = Twilio::Values.of({ + 'AllowNa' => allow_na, + 'CategorySid' => category_sid, + 'Question' => question, + 'Description' => description, + 'AnswerSetId' => answer_set_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + insightsQuestionnairesQuestion_instance = InsightsQuestionnairesQuestionInstance.new( + @version, + response.body, + question_sid: @solution[:question_sid], + ) + InsightsQuestionnairesQuestionInstanceMetadata.new( + @version, + insightsQuestionnairesQuestion_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -265,6 +405,45 @@ def inspect end end + class InsightsQuestionnairesQuestionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InsightsQuestionnairesQuestionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InsightsQuestionnairesQuestionInstance] insights_questionnaires_question_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InsightsQuestionnairesQuestionInstanceMetadata] The initialized instance with metadata. + def initialize(version, insights_questionnaires_question_instance, headers, status_code) + super(version, headers, status_code) + @insights_questionnaires_question_instance = insights_questionnaires_question_instance + end + + def insights_questionnaires_question + @insights_questionnaires_question_instance + end + + def to_s + "" + end + end + + class InsightsQuestionnairesQuestionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_questionnaires_question_instance = payload.body[key].map do |data| + InsightsQuestionnairesQuestionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_questionnaires_question_instance + @instance + end + end + class InsightsQuestionnairesQuestionPage < Page ## # Initialize the InsightsQuestionnairesQuestionPage @@ -293,6 +472,54 @@ def to_s '' end end + + class InsightsQuestionnairesQuestionPageMetadata < PageMetadata + attr_reader :insights_questionnaires_question_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_questionnaires_question_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_questionnaires_question_page << InsightsQuestionnairesQuestionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_questionnaires_question_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsQuestionnairesQuestionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_questionnaires_question = payload.body[key].map do |data| + InsightsQuestionnairesQuestionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_questionnaires_question + @insights_questionnaires_question + end + end + class InsightsQuestionnairesQuestionInstance < InstanceResource ## # Initialize the InsightsQuestionnairesQuestionInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_segments.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_segments.rb index 987913c9a..2038abf75 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_segments.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_segments.rb @@ -81,6 +81,35 @@ def stream(authorization: :unset, segment_id: :unset, reservation_id: :unset, li @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InsightsSegmentsPageMetadata records from the API as a list. + # @param [String] authorization The Authorization HTTP request header + # @param [String] segment_id To unique id of the segment + # @param [Array[String]] reservation_id The list of reservation Ids + # @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_with_metadata(authorization: :unset, segment_id: :unset, reservation_id: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Authorization' => authorization, + 'SegmentId' => segment_id, + + 'ReservationId' => Twilio.serialize_list(reservation_id) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InsightsSegmentsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InsightsSegmentsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -173,6 +202,54 @@ def to_s '' end end + + class InsightsSegmentsPageMetadata < PageMetadata + attr_reader :insights_segments_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_segments_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_segments_page << InsightsSegmentsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_segments_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsSegmentsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_segments = payload.body[key].map do |data| + InsightsSegmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_segments + @insights_segments + end + end + class InsightsSegmentsInstance < InstanceResource ## # Initialize the InsightsSegmentsInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_session.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_session.rb index 0073e93ea..6fa2c3632 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_session.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_session.rb @@ -75,6 +75,33 @@ def create( ) end + ## + # Create the InsightsSessionInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsSessionInstance] Created InsightsSessionInstance + def create_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + insightsSession_instance = InsightsSessionInstance.new( + @version, + response.body, + ) + InsightsSessionInstanceMetadata.new( + @version, + insightsSession_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -91,6 +118,45 @@ def inspect end end + class InsightsSessionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InsightsSessionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InsightsSessionInstance] insights_session_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InsightsSessionInstanceMetadata] The initialized instance with metadata. + def initialize(version, insights_session_instance, headers, status_code) + super(version, headers, status_code) + @insights_session_instance = insights_session_instance + end + + def insights_session + @insights_session_instance + end + + def to_s + "" + end + end + + class InsightsSessionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_session_instance = payload.body[key].map do |data| + InsightsSessionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_session_instance + @instance + end + end + class InsightsSessionPage < Page ## # Initialize the InsightsSessionPage @@ -119,6 +185,54 @@ def to_s '' end end + + class InsightsSessionPageMetadata < PageMetadata + attr_reader :insights_session_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_session_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_session_page << InsightsSessionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_session_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsSessionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_session = payload.body[key].map do |data| + InsightsSessionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_session + @insights_session + end + end + class InsightsSessionInstance < InstanceResource ## # Initialize the InsightsSessionInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_settings_answer_sets.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_settings_answer_sets.rb index 304e74cb7..118bdfa23 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_settings_answer_sets.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_settings_answer_sets.rb @@ -51,6 +51,33 @@ def fetch( ) end + ## + # Fetch the InsightsSettingsAnswerSetsInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsSettingsAnswerSetsInstance] Fetched InsightsSettingsAnswerSetsInstance + def fetch_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + insightsSettingsAnswerSets_instance = InsightsSettingsAnswerSetsInstance.new( + @version, + response.body, + ) + InsightsSettingsAnswerSetsInstanceMetadata.new( + @version, + insightsSettingsAnswerSets_instance, + response.headers, + response.status_code + ) + end + @@ -88,6 +115,54 @@ def to_s '' end end + + class InsightsSettingsAnswerSetsPageMetadata < PageMetadata + attr_reader :insights_settings_answer_sets_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_settings_answer_sets_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_settings_answer_sets_page << InsightsSettingsAnswerSetsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_settings_answer_sets_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsSettingsAnswerSetsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_settings_answer_sets = payload.body[key].map do |data| + InsightsSettingsAnswerSetsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_settings_answer_sets + @insights_settings_answer_sets + end + end + class InsightsSettingsAnswerSetsInstance < InstanceResource ## # Initialize the InsightsSettingsAnswerSetsInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_settings_comment.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_settings_comment.rb index b50537b9c..6a8d335c2 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_settings_comment.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_settings_comment.rb @@ -51,6 +51,33 @@ def fetch( ) end + ## + # Fetch the InsightsSettingsCommentInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsSettingsCommentInstance] Fetched InsightsSettingsCommentInstance + def fetch_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + insightsSettingsComment_instance = InsightsSettingsCommentInstance.new( + @version, + response.body, + ) + InsightsSettingsCommentInstanceMetadata.new( + @version, + insightsSettingsComment_instance, + response.headers, + response.status_code + ) + end + @@ -88,6 +115,54 @@ def to_s '' end end + + class InsightsSettingsCommentPageMetadata < PageMetadata + attr_reader :insights_settings_comment_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_settings_comment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_settings_comment_page << InsightsSettingsCommentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_settings_comment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsSettingsCommentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_settings_comment = payload.body[key].map do |data| + InsightsSettingsCommentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_settings_comment + @insights_settings_comment + end + end + class InsightsSettingsCommentInstance < InstanceResource ## # Initialize the InsightsSettingsCommentInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/insights_user_roles.rb b/lib/twilio-ruby/rest/flex_api/v1/insights_user_roles.rb index 0f63be201..1d01fa320 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/insights_user_roles.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/insights_user_roles.rb @@ -75,6 +75,33 @@ def fetch( ) end + ## + # Fetch the InsightsUserRolesInstanceMetadata + # @param [String] authorization The Authorization HTTP request header + # @return [InsightsUserRolesInstance] Fetched InsightsUserRolesInstance + def fetch_with_metadata( + authorization: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => authorization, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + insightsUserRoles_instance = InsightsUserRolesInstance.new( + @version, + response.body, + ) + InsightsUserRolesInstanceMetadata.new( + @version, + insightsUserRoles_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -91,6 +118,45 @@ def inspect end end + class InsightsUserRolesInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InsightsUserRolesInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InsightsUserRolesInstance] insights_user_roles_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InsightsUserRolesInstanceMetadata] The initialized instance with metadata. + def initialize(version, insights_user_roles_instance, headers, status_code) + super(version, headers, status_code) + @insights_user_roles_instance = insights_user_roles_instance + end + + def insights_user_roles + @insights_user_roles_instance + end + + def to_s + "" + end + end + + class InsightsUserRolesListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_user_roles_instance = payload.body[key].map do |data| + InsightsUserRolesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_user_roles_instance + @instance + end + end + class InsightsUserRolesPage < Page ## # Initialize the InsightsUserRolesPage @@ -119,6 +185,54 @@ def to_s '' end end + + class InsightsUserRolesPageMetadata < PageMetadata + attr_reader :insights_user_roles_page + + def initialize(version, response, solution, limit) + super(version, response) + @insights_user_roles_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @insights_user_roles_page << InsightsUserRolesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @insights_user_roles_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InsightsUserRolesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @insights_user_roles = payload.body[key].map do |data| + InsightsUserRolesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def insights_user_roles + @insights_user_roles + end + end + class InsightsUserRolesInstance < InstanceResource ## # Initialize the InsightsUserRolesInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/interaction.rb b/lib/twilio-ruby/rest/flex_api/v1/interaction.rb index 0c6c34a25..d3e7545a9 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/interaction.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/interaction.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the InteractionInstanceMetadata + # @param [Object] channel The Interaction's channel. + # @param [Object] routing The Interaction's routing logic. + # @param [String] interaction_context_sid The Interaction context sid is used for adding a context lookup sid + # @param [String] webhook_ttid The unique identifier for Interaction level webhook + # @return [InteractionInstance] Created InteractionInstance + def create_with_metadata( + channel: nil, + routing: :unset, + interaction_context_sid: :unset, + webhook_ttid: :unset + ) + + data = Twilio::Values.of({ + 'Channel' => Twilio.serialize_object(channel), + 'Routing' => Twilio.serialize_object(routing), + 'InteractionContextSid' => interaction_context_sid, + 'WebhookTtid' => webhook_ttid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + interaction_instance = InteractionInstance.new( + @version, + response.body, + ) + InteractionInstanceMetadata.new( + @version, + interaction_instance, + response.headers, + response.status_code + ) + end + @@ -109,6 +149,31 @@ def fetch ) end + ## + # Fetch the InteractionInstanceMetadata + # @return [InteractionInstance] Fetched InteractionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + interaction_instance = InteractionInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + InteractionInstanceMetadata.new( + @version, + interaction_instance, + response.headers, + response.status_code + ) + end + ## # Update the InteractionInstance # @param [String] webhook_ttid The unique identifier for Interaction level webhook @@ -135,6 +200,38 @@ def update( ) end + ## + # Update the InteractionInstanceMetadata + # @param [String] webhook_ttid The unique identifier for Interaction level webhook + # @return [InteractionInstance] Updated InteractionInstance + def update_with_metadata( + webhook_ttid: :unset + ) + + data = Twilio::Values.of({ + 'WebhookTtid' => webhook_ttid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + interaction_instance = InteractionInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + InteractionInstanceMetadata.new( + @version, + interaction_instance, + response.headers, + response.status_code + ) + end + ## # Access the channels # @return [InteractionChannelList] @@ -170,6 +267,45 @@ def inspect end end + class InteractionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InteractionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InteractionInstance] interaction_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InteractionInstanceMetadata] The initialized instance with metadata. + def initialize(version, interaction_instance, headers, status_code) + super(version, headers, status_code) + @interaction_instance = interaction_instance + end + + def interaction + @interaction_instance + end + + def to_s + "" + end + end + + class InteractionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_instance = payload.body[key].map do |data| + InteractionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_instance + @instance + end + end + class InteractionPage < Page ## # Initialize the InteractionPage @@ -198,6 +334,54 @@ def to_s '' end end + + class InteractionPageMetadata < PageMetadata + attr_reader :interaction_page + + def initialize(version, response, solution, limit) + super(version, response) + @interaction_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @interaction_page << InteractionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @interaction_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InteractionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction = payload.body[key].map do |data| + InteractionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction + @interaction + end + end + class InteractionInstance < InstanceResource ## # Initialize the InteractionInstance 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 index 320bcf2fa..33d98560b 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InteractionChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InteractionChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InteractionChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +190,32 @@ def fetch ) end + ## + # Fetch the InteractionChannelInstanceMetadata + # @return [InteractionChannelInstance] Fetched InteractionChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + interactionChannel_instance = InteractionChannelInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + sid: @solution[:sid], + ) + InteractionChannelInstanceMetadata.new( + @version, + interactionChannel_instance, + response.headers, + response.status_code + ) + end + ## # Update the InteractionChannelInstance # @param [UpdateChannelStatus] status @@ -198,6 +246,42 @@ def update( ) end + ## + # Update the InteractionChannelInstanceMetadata + # @param [UpdateChannelStatus] status + # @param [Object] routing It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`. + # @return [InteractionChannelInstance] Updated InteractionChannelInstance + def update_with_metadata( + status: nil, + routing: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'Routing' => Twilio.serialize_object(routing), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + interactionChannel_instance = InteractionChannelInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + sid: @solution[:sid], + ) + InteractionChannelInstanceMetadata.new( + @version, + interactionChannel_instance, + response.headers, + response.status_code + ) + end + ## # Access the invites # @return [InteractionChannelInviteList] @@ -263,6 +347,45 @@ def inspect end end + class InteractionChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InteractionChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InteractionChannelInstance] interaction_channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InteractionChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, interaction_channel_instance, headers, status_code) + super(version, headers, status_code) + @interaction_channel_instance = interaction_channel_instance + end + + def interaction_channel + @interaction_channel_instance + end + + def to_s + "" + end + end + + class InteractionChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_channel_instance = payload.body[key].map do |data| + InteractionChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_channel_instance + @instance + end + end + class InteractionChannelPage < Page ## # Initialize the InteractionChannelPage @@ -291,6 +414,54 @@ def to_s '' end end + + class InteractionChannelPageMetadata < PageMetadata + attr_reader :interaction_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @interaction_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @interaction_channel_page << InteractionChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @interaction_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InteractionChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_channel = payload.body[key].map do |data| + InteractionChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_channel + @interaction_channel + end + end + class InteractionChannelInstance < InstanceResource ## # Initialize the InteractionChannelInstance 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 index 5dbc4b921..1d2e0a4d7 100644 --- 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 @@ -60,6 +60,39 @@ def create( ) end + ## + # Create the InteractionChannelInviteInstanceMetadata + # @param [Object] routing The Interaction's routing logic. + # @return [InteractionChannelInviteInstance] Created InteractionChannelInviteInstance + def create_with_metadata( + routing: nil + ) + + data = Twilio::Values.of({ + 'Routing' => Twilio.serialize_object(routing), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + interactionChannelInvite_instance = InteractionChannelInviteInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + ) + InteractionChannelInviteInstanceMetadata.new( + @version, + interactionChannelInvite_instance, + response.headers, + response.status_code + ) + end + ## # Lists InteractionChannelInviteInstance records from the API as a list. @@ -99,6 +132,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InteractionChannelInvitePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InteractionChannelInvitePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InteractionChannelInviteInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,6 +239,54 @@ def to_s '' end end + + class InteractionChannelInvitePageMetadata < PageMetadata + attr_reader :interaction_channel_invite_page + + def initialize(version, response, solution, limit) + super(version, response) + @interaction_channel_invite_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @interaction_channel_invite_page << InteractionChannelInviteListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @interaction_channel_invite_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InteractionChannelInviteListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_channel_invite = payload.body[key].map do |data| + InteractionChannelInviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_channel_invite + @interaction_channel_invite + end + end + class InteractionChannelInviteInstance < InstanceResource ## # Initialize the InteractionChannelInviteInstance 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 index 5729b3a0f..222e7aa2d 100644 --- 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 @@ -66,6 +66,45 @@ def create( ) end + ## + # Create the InteractionChannelParticipantInstanceMetadata + # @param [Type] type + # @param [Object] media_properties JSON representing the Media Properties for the new Participant. + # @param [Object] routing_properties Object representing the Routing Properties for the new Participant. + # @return [InteractionChannelParticipantInstance] Created InteractionChannelParticipantInstance + def create_with_metadata( + type: nil, + media_properties: nil, + routing_properties: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'MediaProperties' => Twilio.serialize_object(media_properties), + 'RoutingProperties' => Twilio.serialize_object(routing_properties), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + interactionChannelParticipant_instance = InteractionChannelParticipantInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + ) + InteractionChannelParticipantInstanceMetadata.new( + @version, + interactionChannelParticipant_instance, + response.headers, + response.status_code + ) + end + ## # Lists InteractionChannelParticipantInstance records from the API as a list. @@ -105,6 +144,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InteractionChannelParticipantPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InteractionChannelParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InteractionChannelParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -208,6 +269,40 @@ def update( ) end + ## + # Update the InteractionChannelParticipantInstanceMetadata + # @param [Status] status + # @return [InteractionChannelParticipantInstance] Updated InteractionChannelParticipantInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + interactionChannelParticipant_instance = InteractionChannelParticipantInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + InteractionChannelParticipantInstanceMetadata.new( + @version, + interactionChannelParticipant_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -224,6 +319,45 @@ def inspect end end + class InteractionChannelParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InteractionChannelParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InteractionChannelParticipantInstance] interaction_channel_participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InteractionChannelParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, interaction_channel_participant_instance, headers, status_code) + super(version, headers, status_code) + @interaction_channel_participant_instance = interaction_channel_participant_instance + end + + def interaction_channel_participant + @interaction_channel_participant_instance + end + + def to_s + "" + end + end + + class InteractionChannelParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_channel_participant_instance = payload.body[key].map do |data| + InteractionChannelParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_channel_participant_instance + @instance + end + end + class InteractionChannelParticipantPage < Page ## # Initialize the InteractionChannelParticipantPage @@ -252,6 +386,54 @@ def to_s '' end end + + class InteractionChannelParticipantPageMetadata < PageMetadata + attr_reader :interaction_channel_participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @interaction_channel_participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @interaction_channel_participant_page << InteractionChannelParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @interaction_channel_participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InteractionChannelParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_channel_participant = payload.body[key].map do |data| + InteractionChannelParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_channel_participant + @interaction_channel_participant + end + end + class InteractionChannelParticipantInstance < InstanceResource ## # Initialize the InteractionChannelParticipantInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_transfer.rb b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_transfer.rb index c2479a9a7..967962d87 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_transfer.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_transfer.rb @@ -55,6 +55,34 @@ def create(body: :unset ) end + ## + # Create the InteractionTransferInstanceMetadata + # @param [Object] body + # @return [InteractionTransferInstance] Created InteractionTransferInstance + def create_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: body.to_json) + interactionTransfer_instance = InteractionTransferInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + ) + InteractionTransferInstanceMetadata.new( + @version, + interactionTransfer_instance, + response.headers, + response.status_code + ) + end + @@ -103,6 +131,33 @@ def fetch ) end + ## + # Fetch the InteractionTransferInstanceMetadata + # @return [InteractionTransferInstance] Fetched InteractionTransferInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + interactionTransfer_instance = InteractionTransferInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + InteractionTransferInstanceMetadata.new( + @version, + interactionTransfer_instance, + response.headers, + response.status_code + ) + end + ## # Update the InteractionTransferInstance # @param [Object] body @@ -126,6 +181,35 @@ def update(body: :unset ) end + ## + # Update the InteractionTransferInstanceMetadata + # @param [Object] body + # @return [InteractionTransferInstance] Updated InteractionTransferInstance + def update_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers, data: body.to_json) + interactionTransfer_instance = InteractionTransferInstance.new( + @version, + response.body, + interaction_sid: @solution[:interaction_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + InteractionTransferInstanceMetadata.new( + @version, + interactionTransfer_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -142,6 +226,45 @@ def inspect end end + class InteractionTransferInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InteractionTransferInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InteractionTransferInstance] interaction_transfer_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InteractionTransferInstanceMetadata] The initialized instance with metadata. + def initialize(version, interaction_transfer_instance, headers, status_code) + super(version, headers, status_code) + @interaction_transfer_instance = interaction_transfer_instance + end + + def interaction_transfer + @interaction_transfer_instance + end + + def to_s + "" + end + end + + class InteractionTransferListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_transfer_instance = payload.body[key].map do |data| + InteractionTransferInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_transfer_instance + @instance + end + end + class InteractionTransferPage < Page ## # Initialize the InteractionTransferPage @@ -170,6 +293,54 @@ def to_s '' end end + + class InteractionTransferPageMetadata < PageMetadata + attr_reader :interaction_transfer_page + + def initialize(version, response, solution, limit) + super(version, response) + @interaction_transfer_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @interaction_transfer_page << InteractionTransferListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @interaction_transfer_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InteractionTransferListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_transfer = payload.body[key].map do |data| + InteractionTransferInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_transfer + @interaction_transfer + end + end + class InteractionTransferInstance < InstanceResource ## # Initialize the InteractionTransferInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin.rb index e8564dc26..bcd91aa7d 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin.rb @@ -63,6 +63,45 @@ def create( ) end + ## + # Create the PluginInstanceMetadata + # @param [String] unique_name The Flex Plugin's unique name. + # @param [String] friendly_name The Flex Plugin's friendly name. + # @param [String] description A descriptive string that you create to describe the plugin resource. It can be up to 500 characters long + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginInstance] Created PluginInstance + def create_with_metadata( + unique_name: nil, + friendly_name: :unset, + description: :unset, + flex_metadata: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'FriendlyName' => friendly_name, + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + plugin_instance = PluginInstance.new( + @version, + response.body, + ) + PluginInstanceMetadata.new( + @version, + plugin_instance, + response.headers, + response.status_code + ) + end + ## # Lists PluginInstance records from the API as a list. @@ -106,6 +145,30 @@ def stream(flex_metadata: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PluginPageMetadata records from the API as a list. + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @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_with_metadata(flex_metadata: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Flex-Metadata' => flex_metadata, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PluginPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PluginInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -204,6 +267,34 @@ def fetch( ) end + ## + # Fetch the PluginInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginInstance] Fetched PluginInstance + def fetch_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + plugin_instance = PluginInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PluginInstanceMetadata.new( + @version, + plugin_instance, + response.headers, + response.status_code + ) + end + ## # Update the PluginInstance # @param [String] friendly_name The Flex Plugin's friendly name. @@ -235,6 +326,43 @@ def update( ) end + ## + # Update the PluginInstanceMetadata + # @param [String] friendly_name The Flex Plugin's friendly name. + # @param [String] description A descriptive string that you update to describe the plugin resource. It can be up to 500 characters long + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginInstance] Updated PluginInstance + def update_with_metadata( + friendly_name: :unset, + description: :unset, + flex_metadata: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + plugin_instance = PluginInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PluginInstanceMetadata.new( + @version, + plugin_instance, + response.headers, + response.status_code + ) + end + ## # Access the plugin_versions # @return [PluginVersionsList] @@ -270,6 +398,45 @@ def inspect end end + class PluginInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PluginInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PluginInstance] plugin_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PluginInstanceMetadata] The initialized instance with metadata. + def initialize(version, plugin_instance, headers, status_code) + super(version, headers, status_code) + @plugin_instance = plugin_instance + end + + def plugin + @plugin_instance + end + + def to_s + "" + end + end + + class PluginListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_instance = payload.body[key].map do |data| + PluginInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_instance + @instance + end + end + class PluginPage < Page ## # Initialize the PluginPage @@ -298,6 +465,54 @@ def to_s '' end end + + class PluginPageMetadata < PageMetadata + attr_reader :plugin_page + + def initialize(version, response, solution, limit) + super(version, response) + @plugin_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @plugin_page << PluginListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @plugin_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PluginListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin = payload.body[key].map do |data| + PluginInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin + @plugin + end + end + class PluginInstance < InstanceResource ## # Initialize the PluginInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin/plugin_versions.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin/plugin_versions.rb index da0f44b0d..abd159042 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin/plugin_versions.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin/plugin_versions.rb @@ -75,6 +75,55 @@ def create( ) end + ## + # Create the PluginVersionsInstanceMetadata + # @param [String] version The Flex Plugin Version's version. + # @param [String] plugin_url The URL of the Flex Plugin Version bundle + # @param [String] changelog The changelog of the Flex Plugin Version. + # @param [Boolean] private Whether this Flex Plugin Version requires authorization. + # @param [String] cli_version The version of Flex Plugins CLI used to create this plugin + # @param [String] validate_status The validation status of the plugin, indicating whether it has been validated + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginVersionsInstance] Created PluginVersionsInstance + def create_with_metadata( + version: nil, + plugin_url: nil, + changelog: :unset, + private: :unset, + cli_version: :unset, + validate_status: :unset, + flex_metadata: :unset + ) + + data = Twilio::Values.of({ + 'Version' => version, + 'PluginUrl' => plugin_url, + 'Changelog' => changelog, + 'Private' => private, + 'CliVersion' => cli_version, + 'ValidateStatus' => validate_status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + pluginVersions_instance = PluginVersionsInstance.new( + @version, + response.body, + plugin_sid: @solution[:plugin_sid], + ) + PluginVersionsInstanceMetadata.new( + @version, + pluginVersions_instance, + response.headers, + response.status_code + ) + end + ## # Lists PluginVersionsInstance records from the API as a list. @@ -118,6 +167,30 @@ def stream(flex_metadata: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PluginVersionsPageMetadata records from the API as a list. + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @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_with_metadata(flex_metadata: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Flex-Metadata' => flex_metadata, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PluginVersionsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PluginVersionsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -217,6 +290,35 @@ def fetch( ) end + ## + # Fetch the PluginVersionsInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginVersionsInstance] Fetched PluginVersionsInstance + def fetch_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + pluginVersions_instance = PluginVersionsInstance.new( + @version, + response.body, + plugin_sid: @solution[:plugin_sid], + sid: @solution[:sid], + ) + PluginVersionsInstanceMetadata.new( + @version, + pluginVersions_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -233,6 +335,45 @@ def inspect end end + class PluginVersionsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PluginVersionsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PluginVersionsInstance] plugin_versions_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PluginVersionsInstanceMetadata] The initialized instance with metadata. + def initialize(version, plugin_versions_instance, headers, status_code) + super(version, headers, status_code) + @plugin_versions_instance = plugin_versions_instance + end + + def plugin_versions + @plugin_versions_instance + end + + def to_s + "" + end + end + + class PluginVersionsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_versions_instance = payload.body[key].map do |data| + PluginVersionsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_versions_instance + @instance + end + end + class PluginVersionsPage < Page ## # Initialize the PluginVersionsPage @@ -261,6 +402,54 @@ def to_s '' end end + + class PluginVersionsPageMetadata < PageMetadata + attr_reader :plugin_versions_page + + def initialize(version, response, solution, limit) + super(version, response) + @plugin_versions_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @plugin_versions_page << PluginVersionsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @plugin_versions_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PluginVersionsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_versions = payload.body[key].map do |data| + PluginVersionsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_versions + @plugin_versions + end + end + class PluginVersionsInstance < InstanceResource ## # Initialize the PluginVersionsInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin_archive.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin_archive.rb index d5401eab0..ca9a9e1dc 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin_archive.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin_archive.rb @@ -77,6 +77,34 @@ def update( ) end + ## + # Update the PluginArchiveInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginArchiveInstance] Updated PluginArchiveInstance + def update_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers) + pluginArchive_instance = PluginArchiveInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PluginArchiveInstanceMetadata.new( + @version, + pluginArchive_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -93,6 +121,45 @@ def inspect end end + class PluginArchiveInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PluginArchiveInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PluginArchiveInstance] plugin_archive_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PluginArchiveInstanceMetadata] The initialized instance with metadata. + def initialize(version, plugin_archive_instance, headers, status_code) + super(version, headers, status_code) + @plugin_archive_instance = plugin_archive_instance + end + + def plugin_archive + @plugin_archive_instance + end + + def to_s + "" + end + end + + class PluginArchiveListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_archive_instance = payload.body[key].map do |data| + PluginArchiveInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_archive_instance + @instance + end + end + class PluginArchivePage < Page ## # Initialize the PluginArchivePage @@ -121,6 +188,54 @@ def to_s '' end end + + class PluginArchivePageMetadata < PageMetadata + attr_reader :plugin_archive_page + + def initialize(version, response, solution, limit) + super(version, response) + @plugin_archive_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @plugin_archive_page << PluginArchiveListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @plugin_archive_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PluginArchiveListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_archive = payload.body[key].map do |data| + PluginArchiveInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_archive + @plugin_archive + end + end + class PluginArchiveInstance < InstanceResource ## # Initialize the PluginArchiveInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration.rb index e7d7e25d9..194764d6a 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration.rb @@ -63,6 +63,45 @@ def create( ) end + ## + # Create the PluginConfigurationInstanceMetadata + # @param [String] name The Flex Plugin Configuration's name. + # @param [Array[Hash]] plugins A list of objects that describe the plugin versions included in the configuration. Each object contains the sid of the plugin version. + # @param [String] description The Flex Plugin Configuration's description. + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginConfigurationInstance] Created PluginConfigurationInstance + def create_with_metadata( + name: nil, + plugins: :unset, + description: :unset, + flex_metadata: :unset + ) + + data = Twilio::Values.of({ + 'Name' => name, + 'Plugins' => Twilio.serialize_list(plugins) { |e| Twilio.serialize_object(e) }, + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + pluginConfiguration_instance = PluginConfigurationInstance.new( + @version, + response.body, + ) + PluginConfigurationInstanceMetadata.new( + @version, + pluginConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Lists PluginConfigurationInstance records from the API as a list. @@ -106,6 +145,30 @@ def stream(flex_metadata: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PluginConfigurationPageMetadata records from the API as a list. + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @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_with_metadata(flex_metadata: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Flex-Metadata' => flex_metadata, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PluginConfigurationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PluginConfigurationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -204,6 +267,34 @@ def fetch( ) end + ## + # Fetch the PluginConfigurationInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginConfigurationInstance] Fetched PluginConfigurationInstance + def fetch_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + pluginConfiguration_instance = PluginConfigurationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PluginConfigurationInstanceMetadata.new( + @version, + pluginConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Access the plugins # @return [ConfiguredPluginList] @@ -239,6 +330,45 @@ def inspect end end + class PluginConfigurationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PluginConfigurationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PluginConfigurationInstance] plugin_configuration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PluginConfigurationInstanceMetadata] The initialized instance with metadata. + def initialize(version, plugin_configuration_instance, headers, status_code) + super(version, headers, status_code) + @plugin_configuration_instance = plugin_configuration_instance + end + + def plugin_configuration + @plugin_configuration_instance + end + + def to_s + "" + end + end + + class PluginConfigurationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_configuration_instance = payload.body[key].map do |data| + PluginConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_configuration_instance + @instance + end + end + class PluginConfigurationPage < Page ## # Initialize the PluginConfigurationPage @@ -267,6 +397,54 @@ def to_s '' end end + + class PluginConfigurationPageMetadata < PageMetadata + attr_reader :plugin_configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @plugin_configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @plugin_configuration_page << PluginConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @plugin_configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PluginConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_configuration = payload.body[key].map do |data| + PluginConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_configuration + @plugin_configuration + end + end + class PluginConfigurationInstance < InstanceResource ## # Initialize the PluginConfigurationInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration/configured_plugin.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration/configured_plugin.rb index 072ed2f12..a195e442a 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration/configured_plugin.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration/configured_plugin.rb @@ -75,6 +75,30 @@ def stream(flex_metadata: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConfiguredPluginPageMetadata records from the API as a list. + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @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_with_metadata(flex_metadata: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Flex-Metadata' => flex_metadata, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConfiguredPluginPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConfiguredPluginInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -174,6 +198,35 @@ def fetch( ) end + ## + # Fetch the ConfiguredPluginInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [ConfiguredPluginInstance] Fetched ConfiguredPluginInstance + def fetch_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + configuredPlugin_instance = ConfiguredPluginInstance.new( + @version, + response.body, + configuration_sid: @solution[:configuration_sid], + plugin_sid: @solution[:plugin_sid], + ) + ConfiguredPluginInstanceMetadata.new( + @version, + configuredPlugin_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -190,6 +243,45 @@ def inspect end end + class ConfiguredPluginInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConfiguredPluginInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConfiguredPluginInstance] configured_plugin_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConfiguredPluginInstanceMetadata] The initialized instance with metadata. + def initialize(version, configured_plugin_instance, headers, status_code) + super(version, headers, status_code) + @configured_plugin_instance = configured_plugin_instance + end + + def configured_plugin + @configured_plugin_instance + end + + def to_s + "" + end + end + + class ConfiguredPluginListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configured_plugin_instance = payload.body[key].map do |data| + ConfiguredPluginInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configured_plugin_instance + @instance + end + end + class ConfiguredPluginPage < Page ## # Initialize the ConfiguredPluginPage @@ -218,6 +310,54 @@ def to_s '' end end + + class ConfiguredPluginPageMetadata < PageMetadata + attr_reader :configured_plugin_page + + def initialize(version, response, solution, limit) + super(version, response) + @configured_plugin_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @configured_plugin_page << ConfiguredPluginListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @configured_plugin_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConfiguredPluginListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @configured_plugin = payload.body[key].map do |data| + ConfiguredPluginInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def configured_plugin + @configured_plugin + end + end + class ConfiguredPluginInstance < InstanceResource ## # Initialize the ConfiguredPluginInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration_archive.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration_archive.rb index 3a51ebaf2..54ceb40d4 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration_archive.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin_configuration_archive.rb @@ -77,6 +77,34 @@ def update( ) end + ## + # Update the PluginConfigurationArchiveInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginConfigurationArchiveInstance] Updated PluginConfigurationArchiveInstance + def update_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers) + pluginConfigurationArchive_instance = PluginConfigurationArchiveInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PluginConfigurationArchiveInstanceMetadata.new( + @version, + pluginConfigurationArchive_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -93,6 +121,45 @@ def inspect end end + class PluginConfigurationArchiveInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PluginConfigurationArchiveInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PluginConfigurationArchiveInstance] plugin_configuration_archive_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PluginConfigurationArchiveInstanceMetadata] The initialized instance with metadata. + def initialize(version, plugin_configuration_archive_instance, headers, status_code) + super(version, headers, status_code) + @plugin_configuration_archive_instance = plugin_configuration_archive_instance + end + + def plugin_configuration_archive + @plugin_configuration_archive_instance + end + + def to_s + "" + end + end + + class PluginConfigurationArchiveListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_configuration_archive_instance = payload.body[key].map do |data| + PluginConfigurationArchiveInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_configuration_archive_instance + @instance + end + end + class PluginConfigurationArchivePage < Page ## # Initialize the PluginConfigurationArchivePage @@ -121,6 +188,54 @@ def to_s '' end end + + class PluginConfigurationArchivePageMetadata < PageMetadata + attr_reader :plugin_configuration_archive_page + + def initialize(version, response, solution, limit) + super(version, response) + @plugin_configuration_archive_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @plugin_configuration_archive_page << PluginConfigurationArchiveListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @plugin_configuration_archive_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PluginConfigurationArchiveListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_configuration_archive = payload.body[key].map do |data| + PluginConfigurationArchiveInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_configuration_archive + @plugin_configuration_archive + end + end + class PluginConfigurationArchiveInstance < InstanceResource ## # Initialize the PluginConfigurationArchiveInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin_release.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin_release.rb index d43c1fac0..bf8b8a06e 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin_release.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin_release.rb @@ -57,6 +57,39 @@ def create( ) end + ## + # Create the PluginReleaseInstanceMetadata + # @param [String] configuration_id The SID or the Version of the Flex Plugin Configuration to release. + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginReleaseInstance] Created PluginReleaseInstance + def create_with_metadata( + configuration_id: nil, + flex_metadata: :unset + ) + + data = Twilio::Values.of({ + 'ConfigurationId' => configuration_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + pluginRelease_instance = PluginReleaseInstance.new( + @version, + response.body, + ) + PluginReleaseInstanceMetadata.new( + @version, + pluginRelease_instance, + response.headers, + response.status_code + ) + end + ## # Lists PluginReleaseInstance records from the API as a list. @@ -100,6 +133,30 @@ def stream(flex_metadata: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PluginReleasePageMetadata records from the API as a list. + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @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_with_metadata(flex_metadata: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Flex-Metadata' => flex_metadata, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PluginReleasePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PluginReleaseInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -197,6 +254,34 @@ def fetch( ) end + ## + # Fetch the PluginReleaseInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginReleaseInstance] Fetched PluginReleaseInstance + def fetch_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + pluginRelease_instance = PluginReleaseInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PluginReleaseInstanceMetadata.new( + @version, + pluginRelease_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -213,6 +298,45 @@ def inspect end end + class PluginReleaseInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PluginReleaseInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PluginReleaseInstance] plugin_release_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PluginReleaseInstanceMetadata] The initialized instance with metadata. + def initialize(version, plugin_release_instance, headers, status_code) + super(version, headers, status_code) + @plugin_release_instance = plugin_release_instance + end + + def plugin_release + @plugin_release_instance + end + + def to_s + "" + end + end + + class PluginReleaseListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_release_instance = payload.body[key].map do |data| + PluginReleaseInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_release_instance + @instance + end + end + class PluginReleasePage < Page ## # Initialize the PluginReleasePage @@ -241,6 +365,54 @@ def to_s '' end end + + class PluginReleasePageMetadata < PageMetadata + attr_reader :plugin_release_page + + def initialize(version, response, solution, limit) + super(version, response) + @plugin_release_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @plugin_release_page << PluginReleaseListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @plugin_release_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PluginReleaseListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_release = payload.body[key].map do |data| + PluginReleaseInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_release + @plugin_release + end + end + class PluginReleaseInstance < InstanceResource ## # Initialize the PluginReleaseInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/plugin_version_archive.rb b/lib/twilio-ruby/rest/flex_api/v1/plugin_version_archive.rb index 3973e5d86..fa276e69f 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/plugin_version_archive.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/plugin_version_archive.rb @@ -79,6 +79,35 @@ def update( ) end + ## + # Update the PluginVersionArchiveInstanceMetadata + # @param [String] flex_metadata The Flex-Metadata HTTP request header + # @return [PluginVersionArchiveInstance] Updated PluginVersionArchiveInstance + def update_with_metadata( + flex_metadata: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Flex-Metadata' => flex_metadata, }) + + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers) + pluginVersionArchive_instance = PluginVersionArchiveInstance.new( + @version, + response.body, + plugin_sid: @solution[:plugin_sid], + sid: @solution[:sid], + ) + PluginVersionArchiveInstanceMetadata.new( + @version, + pluginVersionArchive_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -95,6 +124,45 @@ def inspect end end + class PluginVersionArchiveInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PluginVersionArchiveInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PluginVersionArchiveInstance] plugin_version_archive_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PluginVersionArchiveInstanceMetadata] The initialized instance with metadata. + def initialize(version, plugin_version_archive_instance, headers, status_code) + super(version, headers, status_code) + @plugin_version_archive_instance = plugin_version_archive_instance + end + + def plugin_version_archive + @plugin_version_archive_instance + end + + def to_s + "" + end + end + + class PluginVersionArchiveListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_version_archive_instance = payload.body[key].map do |data| + PluginVersionArchiveInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_version_archive_instance + @instance + end + end + class PluginVersionArchivePage < Page ## # Initialize the PluginVersionArchivePage @@ -123,6 +191,54 @@ def to_s '' end end + + class PluginVersionArchivePageMetadata < PageMetadata + attr_reader :plugin_version_archive_page + + def initialize(version, response, solution, limit) + super(version, response) + @plugin_version_archive_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @plugin_version_archive_page << PluginVersionArchiveListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @plugin_version_archive_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PluginVersionArchiveListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @plugin_version_archive = payload.body[key].map do |data| + PluginVersionArchiveInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def plugin_version_archive + @plugin_version_archive + end + end + class PluginVersionArchiveInstance < InstanceResource ## # Initialize the PluginVersionArchiveInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/provisioning_status.rb b/lib/twilio-ruby/rest/flex_api/v1/provisioning_status.rb index d3e72fcc7..7d4721f17 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/provisioning_status.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/provisioning_status.rb @@ -72,6 +72,30 @@ def fetch ) end + ## + # Fetch the ProvisioningStatusInstanceMetadata + # @return [ProvisioningStatusInstance] Fetched ProvisioningStatusInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + provisioningStatus_instance = ProvisioningStatusInstance.new( + @version, + response.body, + ) + ProvisioningStatusInstanceMetadata.new( + @version, + provisioningStatus_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -88,6 +112,45 @@ def inspect end end + class ProvisioningStatusInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ProvisioningStatusInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ProvisioningStatusInstance] provisioning_status_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ProvisioningStatusInstanceMetadata] The initialized instance with metadata. + def initialize(version, provisioning_status_instance, headers, status_code) + super(version, headers, status_code) + @provisioning_status_instance = provisioning_status_instance + end + + def provisioning_status + @provisioning_status_instance + end + + def to_s + "" + end + end + + class ProvisioningStatusListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @provisioning_status_instance = payload.body[key].map do |data| + ProvisioningStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def provisioning_status_instance + @instance + end + end + class ProvisioningStatusPage < Page ## # Initialize the ProvisioningStatusPage @@ -116,6 +179,54 @@ def to_s '' end end + + class ProvisioningStatusPageMetadata < PageMetadata + attr_reader :provisioning_status_page + + def initialize(version, response, solution, limit) + super(version, response) + @provisioning_status_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @provisioning_status_page << ProvisioningStatusListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @provisioning_status_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ProvisioningStatusListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @provisioning_status = payload.body[key].map do |data| + ProvisioningStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def provisioning_status + @provisioning_status + end + end + class ProvisioningStatusInstance < InstanceResource ## # Initialize the ProvisioningStatusInstance diff --git a/lib/twilio-ruby/rest/flex_api/v1/web_channel.rb b/lib/twilio-ruby/rest/flex_api/v1/web_channel.rb index 1280a36e2..4909e00d0 100644 --- a/lib/twilio-ruby/rest/flex_api/v1/web_channel.rb +++ b/lib/twilio-ruby/rest/flex_api/v1/web_channel.rb @@ -70,6 +70,52 @@ def create( ) end + ## + # Create the WebChannelInstanceMetadata + # @param [String] flex_flow_sid The SID of the Flex Flow. + # @param [String] identity The chat identity. + # @param [String] customer_friendly_name The chat participant's friendly name. + # @param [String] chat_friendly_name The chat channel's friendly name. + # @param [String] chat_unique_name The chat channel's unique name. + # @param [String] pre_engagement_data The pre-engagement data. + # @return [WebChannelInstance] Created WebChannelInstance + def create_with_metadata( + flex_flow_sid: nil, + identity: nil, + customer_friendly_name: nil, + chat_friendly_name: nil, + chat_unique_name: :unset, + pre_engagement_data: :unset + ) + + data = Twilio::Values.of({ + 'FlexFlowSid' => flex_flow_sid, + 'Identity' => identity, + 'CustomerFriendlyName' => customer_friendly_name, + 'ChatFriendlyName' => chat_friendly_name, + 'ChatUniqueName' => chat_unique_name, + 'PreEngagementData' => pre_engagement_data, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + webChannel_instance = WebChannelInstance.new( + @version, + response.body, + ) + WebChannelInstanceMetadata.new( + @version, + webChannel_instance, + response.headers, + response.status_code + ) + end + ## # Lists WebChannelInstance records from the API as a list. @@ -109,6 +155,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WebChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WebChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WebChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -191,7 +259,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WebChannelInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + webChannel_instance = WebChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WebChannelInstanceMetadata.new(@version, webChannel_instance, response.headers, response.status_code) end ## @@ -213,6 +300,31 @@ def fetch ) end + ## + # Fetch the WebChannelInstanceMetadata + # @return [WebChannelInstance] Fetched WebChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webChannel_instance = WebChannelInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + WebChannelInstanceMetadata.new( + @version, + webChannel_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebChannelInstance # @param [ChatStatus] chat_status @@ -242,6 +354,41 @@ def update( ) end + ## + # Update the WebChannelInstanceMetadata + # @param [ChatStatus] chat_status + # @param [String] post_engagement_data The post-engagement data. + # @return [WebChannelInstance] Updated WebChannelInstance + def update_with_metadata( + chat_status: :unset, + post_engagement_data: :unset + ) + + data = Twilio::Values.of({ + 'ChatStatus' => chat_status, + 'PostEngagementData' => post_engagement_data, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webChannel_instance = WebChannelInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + WebChannelInstanceMetadata.new( + @version, + webChannel_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -258,6 +405,45 @@ def inspect end end + class WebChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebChannelInstance] web_channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, web_channel_instance, headers, status_code) + super(version, headers, status_code) + @web_channel_instance = web_channel_instance + end + + def web_channel + @web_channel_instance + end + + def to_s + "" + end + end + + class WebChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @web_channel_instance = payload.body[key].map do |data| + WebChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def web_channel_instance + @instance + end + end + class WebChannelPage < Page ## # Initialize the WebChannelPage @@ -286,6 +472,54 @@ def to_s '' end end + + class WebChannelPageMetadata < PageMetadata + attr_reader :web_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @web_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @web_channel_page << WebChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @web_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @web_channel = payload.body[key].map do |data| + WebChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def web_channel + @web_channel + end + end + class WebChannelInstance < InstanceResource ## # Initialize the WebChannelInstance diff --git a/lib/twilio-ruby/rest/flex_api/v2/flex_user.rb b/lib/twilio-ruby/rest/flex_api/v2/flex_user.rb index 6eeaad2db..3870f2f74 100644 --- a/lib/twilio-ruby/rest/flex_api/v2/flex_user.rb +++ b/lib/twilio-ruby/rest/flex_api/v2/flex_user.rb @@ -76,6 +76,32 @@ def fetch ) end + ## + # Fetch the FlexUserInstanceMetadata + # @return [FlexUserInstance] Fetched FlexUserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + flexUser_instance = FlexUserInstance.new( + @version, + response.body, + instance_sid: @solution[:instance_sid], + flex_user_sid: @solution[:flex_user_sid], + ) + FlexUserInstanceMetadata.new( + @version, + flexUser_instance, + response.headers, + response.status_code + ) + end + ## # Update the FlexUserInstance # @param [String] email Email of the User. @@ -109,6 +135,45 @@ def update( ) end + ## + # Update the FlexUserInstanceMetadata + # @param [String] email Email of the User. + # @param [String] user_sid The unique SID identifier of the Twilio Unified User. + # @param [String] locale The locale preference of the user. + # @return [FlexUserInstance] Updated FlexUserInstance + def update_with_metadata( + email: :unset, + user_sid: :unset, + locale: :unset + ) + + data = Twilio::Values.of({ + 'Email' => email, + 'UserSid' => user_sid, + 'Locale' => locale, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + flexUser_instance = FlexUserInstance.new( + @version, + response.body, + instance_sid: @solution[:instance_sid], + flex_user_sid: @solution[:flex_user_sid], + ) + FlexUserInstanceMetadata.new( + @version, + flexUser_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -125,6 +190,45 @@ def inspect end end + class FlexUserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FlexUserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FlexUserInstance] flex_user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FlexUserInstanceMetadata] The initialized instance with metadata. + def initialize(version, flex_user_instance, headers, status_code) + super(version, headers, status_code) + @flex_user_instance = flex_user_instance + end + + def flex_user + @flex_user_instance + end + + def to_s + "" + end + end + + class FlexUserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flex_user_instance = payload.body[key].map do |data| + FlexUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flex_user_instance + @instance + end + end + class FlexUserPage < Page ## # Initialize the FlexUserPage @@ -153,6 +257,54 @@ def to_s '' end end + + class FlexUserPageMetadata < PageMetadata + attr_reader :flex_user_page + + def initialize(version, response, solution, limit) + super(version, response) + @flex_user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @flex_user_page << FlexUserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @flex_user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FlexUserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flex_user = payload.body[key].map do |data| + FlexUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flex_user + @flex_user + end + end + class FlexUserInstance < InstanceResource ## # Initialize the FlexUserInstance diff --git a/lib/twilio-ruby/rest/flex_api/v2/web_channels.rb b/lib/twilio-ruby/rest/flex_api/v2/web_channels.rb index 75807dce1..02144c5bb 100644 --- a/lib/twilio-ruby/rest/flex_api/v2/web_channels.rb +++ b/lib/twilio-ruby/rest/flex_api/v2/web_channels.rb @@ -69,6 +69,51 @@ def create( ) end + ## + # Create the WebChannelsInstanceMetadata + # @param [String] address_sid The SID of the Conversations Address. See [Address Configuration Resource](https://www.twilio.com/docs/conversations/api/address-configuration-resource) for configuration details. When a conversation is created on the Flex backend, the callback URL will be set to the corresponding Studio Flow SID or webhook URL in your address configuration. + # @param [String] chat_friendly_name The Conversation's friendly name. See the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) for an example. + # @param [String] customer_friendly_name The Conversation participant's friendly name. See the [Conversation Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) for an example. + # @param [String] pre_engagement_data The pre-engagement data. + # @param [String] identity The Identity of the guest user. See the [Conversation User Resource](https://www.twilio.com/docs/conversations/api/user-resource) for an example. + # @param [String] ui_version The Ui-Version HTTP request header + # @return [WebChannelsInstance] Created WebChannelsInstance + def create_with_metadata( + address_sid: nil, + chat_friendly_name: :unset, + customer_friendly_name: :unset, + pre_engagement_data: :unset, + identity: :unset, + ui_version: :unset + ) + + data = Twilio::Values.of({ + 'AddressSid' => address_sid, + 'ChatFriendlyName' => chat_friendly_name, + 'CustomerFriendlyName' => customer_friendly_name, + 'PreEngagementData' => pre_engagement_data, + 'Identity' => identity, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Ui-Version' => ui_version, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + webChannels_instance = WebChannelsInstance.new( + @version, + response.body, + ) + WebChannelsInstanceMetadata.new( + @version, + webChannels_instance, + response.headers, + response.status_code + ) + end + @@ -106,6 +151,54 @@ def to_s '' end end + + class WebChannelsPageMetadata < PageMetadata + attr_reader :web_channels_page + + def initialize(version, response, solution, limit) + super(version, response) + @web_channels_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @web_channels_page << WebChannelsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @web_channels_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebChannelsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @web_channels = payload.body[key].map do |data| + WebChannelsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def web_channels + @web_channels + end + end + class WebChannelsInstance < InstanceResource ## # Initialize the WebChannelsInstance diff --git a/lib/twilio-ruby/rest/frontline_api/v1/user.rb b/lib/twilio-ruby/rest/frontline_api/v1/user.rb index 9f577d117..fcec2e4aa 100644 --- a/lib/twilio-ruby/rest/frontline_api/v1/user.rb +++ b/lib/twilio-ruby/rest/frontline_api/v1/user.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] friendly_name The string that you assigned to describe the User. @@ -109,6 +134,47 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the User. + # @param [String] avatar The avatar URL which will be shown in Frontline application. + # @param [StateType] state + # @param [Boolean] is_available Whether the User is available for new conversations. Set to `false` to prevent User from receiving new inbound conversations if you are using [Pool Routing](https://www.twilio.com/docs/frontline/handle-incoming-conversations#3-pool-routing). + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + friendly_name: :unset, + avatar: :unset, + state: :unset, + is_available: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Avatar' => avatar, + 'State' => state, + 'IsAvailable' => is_available, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -125,6 +191,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -153,6 +258,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/iam/v1/api_key.rb b/lib/twilio-ruby/rest/iam/v1/api_key.rb index 52e157432..977efe9cc 100644 --- a/lib/twilio-ruby/rest/iam/v1/api_key.rb +++ b/lib/twilio-ruby/rest/iam/v1/api_key.rb @@ -64,7 +64,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ApiKeyInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + apiKey_instance = ApiKeyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ApiKeyInstanceMetadata.new(@version, apiKey_instance, response.headers, response.status_code) end ## @@ -86,6 +105,31 @@ def fetch ) end + ## + # Fetch the ApiKeyInstanceMetadata + # @return [ApiKeyInstance] Fetched ApiKeyInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + apiKey_instance = ApiKeyInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ApiKeyInstanceMetadata.new( + @version, + apiKey_instance, + response.headers, + response.status_code + ) + end + ## # Update the ApiKeyInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -115,6 +159,41 @@ def update( ) end + ## + # Update the ApiKeyInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [Object] policy The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + # @return [ApiKeyInstance] Updated ApiKeyInstance + def update_with_metadata( + friendly_name: :unset, + policy: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Policy' => Twilio.serialize_object(policy), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + apiKey_instance = ApiKeyInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ApiKeyInstanceMetadata.new( + @version, + apiKey_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -131,6 +210,45 @@ def inspect end end + class ApiKeyInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ApiKeyInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ApiKeyInstance] api_key_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ApiKeyInstanceMetadata] The initialized instance with metadata. + def initialize(version, api_key_instance, headers, status_code) + super(version, headers, status_code) + @api_key_instance = api_key_instance + end + + def api_key + @api_key_instance + end + + def to_s + "" + end + end + + class ApiKeyListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @api_key_instance = payload.body[key].map do |data| + ApiKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def api_key_instance + @instance + end + end + class ApiKeyPage < Page ## # Initialize the ApiKeyPage @@ -159,6 +277,54 @@ def to_s '' end end + + class ApiKeyPageMetadata < PageMetadata + attr_reader :api_key_page + + def initialize(version, response, solution, limit) + super(version, response) + @api_key_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @api_key_page << ApiKeyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @api_key_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ApiKeyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @api_key = payload.body[key].map do |data| + ApiKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def api_key + @api_key + end + end + class ApiKeyInstance < InstanceResource ## # Initialize the ApiKeyInstance diff --git a/lib/twilio-ruby/rest/iam/v1/get_api_keys.rb b/lib/twilio-ruby/rest/iam/v1/get_api_keys.rb index 4e35ba003..6d50b46dd 100644 --- a/lib/twilio-ruby/rest/iam/v1/get_api_keys.rb +++ b/lib/twilio-ruby/rest/iam/v1/get_api_keys.rb @@ -73,6 +73,30 @@ def stream(account_sid: nil, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists GetApiKeysPageMetadata records from the API as a list. + # @param [String] account_sid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + # @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_with_metadata(account_sid: nil, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'AccountSid' => account_sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + GetApiKeysPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields GetApiKeysInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -160,6 +184,54 @@ def to_s '' end end + + class GetApiKeysPageMetadata < PageMetadata + attr_reader :get_api_keys_page + + def initialize(version, response, solution, limit) + super(version, response) + @get_api_keys_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @get_api_keys_page << GetApiKeysListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @get_api_keys_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class GetApiKeysListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @get_api_keys = payload.body[key].map do |data| + GetApiKeysInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def get_api_keys + @get_api_keys + end + end + class GetApiKeysInstance < InstanceResource ## # Initialize the GetApiKeysInstance diff --git a/lib/twilio-ruby/rest/iam/v1/new_api_key.rb b/lib/twilio-ruby/rest/iam/v1/new_api_key.rb index b5f962c3a..720a2cdd3 100644 --- a/lib/twilio-ruby/rest/iam/v1/new_api_key.rb +++ b/lib/twilio-ruby/rest/iam/v1/new_api_key.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the NewApiKeyInstanceMetadata + # @param [String] account_sid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [Keytype] key_type + # @param [Object] policy The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). + # @return [NewApiKeyInstance] Created NewApiKeyInstance + def create_with_metadata( + account_sid: nil, + friendly_name: :unset, + key_type: :unset, + policy: :unset + ) + + data = Twilio::Values.of({ + 'AccountSid' => account_sid, + 'FriendlyName' => friendly_name, + 'KeyType' => key_type, + 'Policy' => Twilio.serialize_object(policy), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + newApiKey_instance = NewApiKeyInstance.new( + @version, + response.body, + ) + NewApiKeyInstanceMetadata.new( + @version, + newApiKey_instance, + response.headers, + response.status_code + ) + end + @@ -101,6 +141,54 @@ def to_s '' end end + + class NewApiKeyPageMetadata < PageMetadata + attr_reader :new_api_key_page + + def initialize(version, response, solution, limit) + super(version, response) + @new_api_key_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @new_api_key_page << NewApiKeyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @new_api_key_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NewApiKeyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_api_key = payload.body[key].map do |data| + NewApiKeyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_api_key + @new_api_key + end + end + class NewApiKeyInstance < InstanceResource ## # Initialize the NewApiKeyInstance diff --git a/lib/twilio-ruby/rest/iam/v1/o_auth_app.rb b/lib/twilio-ruby/rest/iam/v1/o_auth_app.rb index 99963f98c..7a9152919 100644 --- a/lib/twilio-ruby/rest/iam/v1/o_auth_app.rb +++ b/lib/twilio-ruby/rest/iam/v1/o_auth_app.rb @@ -196,6 +196,32 @@ def create(iam_v1_account_vendor_oauth_app_create_request: nil ) end + ## + # Create the OAuthAppInstanceMetadata + # @param [IamV1AccountVendorOauthAppCreateRequest] iam_v1_account_vendor_oauth_app_create_request + # @return [OAuthAppInstance] Created OAuthAppInstance + def create_with_metadata(iam_v1_account_vendor_oauth_app_create_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: iam_v1_account_vendor_oauth_app_create_request.to_json) + oAuthApp_instance = OAuthAppInstance.new( + @version, + response.body, + ) + OAuthAppInstanceMetadata.new( + @version, + oAuthApp_instance, + response.headers, + response.status_code + ) + end + @@ -230,7 +256,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the OAuthAppInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + oAuthApp_instance = OAuthAppInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + OAuthAppInstanceMetadata.new(@version, oAuthApp_instance, response.headers, response.status_code) end ## @@ -254,6 +299,33 @@ def update(iam_v1_account_vendor_oauth_app_update_request: nil ) end + ## + # Update the OAuthAppInstanceMetadata + # @param [IamV1AccountVendorOauthAppUpdateRequest] iam_v1_account_vendor_oauth_app_update_request + # @return [OAuthAppInstance] Updated OAuthAppInstance + def update_with_metadata(iam_v1_account_vendor_oauth_app_update_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: iam_v1_account_vendor_oauth_app_update_request.to_json) + oAuthApp_instance = OAuthAppInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + OAuthAppInstanceMetadata.new( + @version, + oAuthApp_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -270,6 +342,45 @@ def inspect end end + class OAuthAppInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OAuthAppInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OAuthAppInstance] o_auth_app_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OAuthAppInstanceMetadata] The initialized instance with metadata. + def initialize(version, o_auth_app_instance, headers, status_code) + super(version, headers, status_code) + @o_auth_app_instance = o_auth_app_instance + end + + def o_auth_app + @o_auth_app_instance + end + + def to_s + "" + end + end + + class OAuthAppListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @o_auth_app_instance = payload.body[key].map do |data| + OAuthAppInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def o_auth_app_instance + @instance + end + end + class OAuthAppPage < Page ## # Initialize the OAuthAppPage @@ -298,6 +409,54 @@ def to_s '' end end + + class OAuthAppPageMetadata < PageMetadata + attr_reader :o_auth_app_page + + def initialize(version, response, solution, limit) + super(version, response) + @o_auth_app_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @o_auth_app_page << OAuthAppListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @o_auth_app_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OAuthAppListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @o_auth_app = payload.body[key].map do |data| + OAuthAppInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def o_auth_app + @o_auth_app + end + end + class OAuthAppInstance < InstanceResource ## # Initialize the OAuthAppInstance diff --git a/lib/twilio-ruby/rest/iam/v1/token.rb b/lib/twilio-ruby/rest/iam/v1/token.rb index 4cdcde4c5..bcc3a8420 100644 --- a/lib/twilio-ruby/rest/iam/v1/token.rb +++ b/lib/twilio-ruby/rest/iam/v1/token.rb @@ -76,6 +76,58 @@ def create( ) end + ## + # Create the TokenInstanceMetadata + # @param [String] grant_type Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + # @param [String] client_id A 34 character string that uniquely identifies this OAuth App. + # @param [String] client_secret The credential for confidential OAuth App. + # @param [String] code JWT token related to the authorization code grant type. + # @param [String] redirect_uri The redirect uri + # @param [String] audience The targeted audience uri + # @param [String] refresh_token JWT token related to refresh access token. + # @param [String] scope The scope of token + # @return [TokenInstance] Created TokenInstance + def create_with_metadata( + grant_type: nil, + client_id: nil, + client_secret: :unset, + code: :unset, + redirect_uri: :unset, + audience: :unset, + refresh_token: :unset, + scope: :unset + ) + + data = Twilio::Values.of({ + 'grant_type' => grant_type, + 'client_id' => client_id, + 'client_secret' => client_secret, + 'code' => code, + 'redirect_uri' => redirect_uri, + 'audience' => audience, + 'refresh_token' => refresh_token, + 'scope' => scope, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + token_instance = TokenInstance.new( + @version, + response.body, + ) + TokenInstanceMetadata.new( + @version, + token_instance, + response.headers, + response.status_code + ) + end + @@ -113,6 +165,54 @@ def to_s '' end end + + class TokenPageMetadata < PageMetadata + attr_reader :token_page + + def initialize(version, response, solution, limit) + super(version, response) + @token_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @token_page << TokenListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @token_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TokenListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @token = payload.body[key].map do |data| + TokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def token + @token + end + end + class TokenInstance < InstanceResource ## # Initialize the TokenInstance diff --git a/lib/twilio-ruby/rest/insights/v1/call.rb b/lib/twilio-ruby/rest/insights/v1/call.rb index 58b250785..5ed661562 100644 --- a/lib/twilio-ruby/rest/insights/v1/call.rb +++ b/lib/twilio-ruby/rest/insights/v1/call.rb @@ -78,6 +78,31 @@ def fetch ) end + ## + # Fetch the CallInstanceMetadata + # @return [CallInstance] Fetched CallInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + call_instance = CallInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CallInstanceMetadata.new( + @version, + call_instance, + response.headers, + response.status_code + ) + end + ## # Access the metrics # @return [MetricList] @@ -136,6 +161,45 @@ def inspect end end + class CallInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CallInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CallInstance] call_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CallInstanceMetadata] The initialized instance with metadata. + def initialize(version, call_instance, headers, status_code) + super(version, headers, status_code) + @call_instance = call_instance + end + + def call + @call_instance + end + + def to_s + "" + end + end + + class CallListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @call_instance = payload.body[key].map do |data| + CallInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def call_instance + @instance + end + end + class CallPage < Page ## # Initialize the CallPage @@ -164,6 +228,54 @@ def to_s '' end end + + class CallPageMetadata < PageMetadata + attr_reader :call_page + + def initialize(version, response, solution, limit) + super(version, response) + @call_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @call_page << CallListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @call_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CallListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @call = payload.body[key].map do |data| + CallInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def call + @call + end + end + class CallInstance < InstanceResource ## # Initialize the CallInstance diff --git a/lib/twilio-ruby/rest/insights/v1/call/annotation.rb b/lib/twilio-ruby/rest/insights/v1/call/annotation.rb index 6b7d72394..6dd6b5efc 100644 --- a/lib/twilio-ruby/rest/insights/v1/call/annotation.rb +++ b/lib/twilio-ruby/rest/insights/v1/call/annotation.rb @@ -76,6 +76,31 @@ def fetch ) end + ## + # Fetch the AnnotationInstanceMetadata + # @return [AnnotationInstance] Fetched AnnotationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + annotation_instance = AnnotationInstance.new( + @version, + response.body, + call_sid: @solution[:call_sid], + ) + AnnotationInstanceMetadata.new( + @version, + annotation_instance, + response.headers, + response.status_code + ) + end + ## # Update the AnnotationInstance # @param [AnsweredBy] answered_by @@ -120,6 +145,56 @@ def update( ) end + ## + # Update the AnnotationInstanceMetadata + # @param [AnsweredBy] answered_by + # @param [ConnectivityIssue] connectivity_issue + # @param [String] quality_issues Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call. + # @param [Boolean] spam A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call. + # @param [String] call_score Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + # @param [String] comment Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`. + # @param [String] incident Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`. + # @return [AnnotationInstance] Updated AnnotationInstance + def update_with_metadata( + 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, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + annotation_instance = AnnotationInstance.new( + @version, + response.body, + call_sid: @solution[:call_sid], + ) + AnnotationInstanceMetadata.new( + @version, + annotation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -136,6 +211,45 @@ def inspect end end + class AnnotationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AnnotationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AnnotationInstance] annotation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AnnotationInstanceMetadata] The initialized instance with metadata. + def initialize(version, annotation_instance, headers, status_code) + super(version, headers, status_code) + @annotation_instance = annotation_instance + end + + def annotation + @annotation_instance + end + + def to_s + "" + end + end + + class AnnotationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @annotation_instance = payload.body[key].map do |data| + AnnotationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def annotation_instance + @instance + end + end + class AnnotationPage < Page ## # Initialize the AnnotationPage @@ -164,6 +278,54 @@ def to_s '' end end + + class AnnotationPageMetadata < PageMetadata + attr_reader :annotation_page + + def initialize(version, response, solution, limit) + super(version, response) + @annotation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @annotation_page << AnnotationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @annotation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AnnotationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @annotation = payload.body[key].map do |data| + AnnotationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def annotation + @annotation + end + end + class AnnotationInstance < InstanceResource ## # Initialize the AnnotationInstance diff --git a/lib/twilio-ruby/rest/insights/v1/call/call_summary.rb b/lib/twilio-ruby/rest/insights/v1/call/call_summary.rb index 17533b7d5..a7e2b7598 100644 --- a/lib/twilio-ruby/rest/insights/v1/call/call_summary.rb +++ b/lib/twilio-ruby/rest/insights/v1/call/call_summary.rb @@ -82,6 +82,37 @@ def fetch( ) end + ## + # Fetch the CallSummaryInstanceMetadata + # @param [ProcessingState] processing_state The Processing State of this Call Summary. One of `complete`, `partial` or `all`. + # @return [CallSummaryInstance] Fetched CallSummaryInstance + def fetch_with_metadata( + processing_state: :unset + ) + + params = Twilio::Values.of({ + 'ProcessingState' => processing_state, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + callSummary_instance = CallSummaryInstance.new( + @version, + response.body, + call_sid: @solution[:call_sid], + ) + CallSummaryInstanceMetadata.new( + @version, + callSummary_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +129,45 @@ def inspect end end + class CallSummaryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CallSummaryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CallSummaryInstance] call_summary_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CallSummaryInstanceMetadata] The initialized instance with metadata. + def initialize(version, call_summary_instance, headers, status_code) + super(version, headers, status_code) + @call_summary_instance = call_summary_instance + end + + def call_summary + @call_summary_instance + end + + def to_s + "" + end + end + + class CallSummaryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @call_summary_instance = payload.body[key].map do |data| + CallSummaryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def call_summary_instance + @instance + end + end + class CallSummaryPage < Page ## # Initialize the CallSummaryPage @@ -126,6 +196,54 @@ def to_s '' end end + + class CallSummaryPageMetadata < PageMetadata + attr_reader :call_summary_page + + def initialize(version, response, solution, limit) + super(version, response) + @call_summary_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @call_summary_page << CallSummaryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @call_summary_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CallSummaryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @call_summary = payload.body[key].map do |data| + CallSummaryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def call_summary + @call_summary + end + end + class CallSummaryInstance < InstanceResource ## # Initialize the CallSummaryInstance diff --git a/lib/twilio-ruby/rest/insights/v1/call/event.rb b/lib/twilio-ruby/rest/insights/v1/call/event.rb index a11c50be9..bceb64501 100644 --- a/lib/twilio-ruby/rest/insights/v1/call/event.rb +++ b/lib/twilio-ruby/rest/insights/v1/call/event.rb @@ -75,6 +75,30 @@ def stream(edge: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EventPageMetadata records from the API as a list. + # @param [TwilioEdge] edge The Edge of this Event. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + # @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_with_metadata(edge: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Edge' => edge, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EventPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EventInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -162,6 +186,54 @@ def to_s '' end end + + class EventPageMetadata < PageMetadata + attr_reader :event_page + + def initialize(version, response, solution, limit) + super(version, response) + @event_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @event_page << EventListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @event_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EventListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event = payload.body[key].map do |data| + EventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event + @event + end + end + class EventInstance < InstanceResource ## # Initialize the EventInstance diff --git a/lib/twilio-ruby/rest/insights/v1/call/metric.rb b/lib/twilio-ruby/rest/insights/v1/call/metric.rb index df17f262e..ce2efa175 100644 --- a/lib/twilio-ruby/rest/insights/v1/call/metric.rb +++ b/lib/twilio-ruby/rest/insights/v1/call/metric.rb @@ -79,6 +79,32 @@ def stream(edge: :unset, direction: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MetricPageMetadata records from the API as a list. + # @param [TwilioEdge] edge The Edge of this Metric. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + # @param [StreamDirection] direction The Direction of this Metric. One of `unknown`, `inbound`, `outbound` or `both`. + # @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_with_metadata(edge: :unset, direction: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Edge' => edge, + 'Direction' => direction, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MetricPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MetricInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +194,54 @@ def to_s '' end end + + class MetricPageMetadata < PageMetadata + attr_reader :metric_page + + def initialize(version, response, solution, limit) + super(version, response) + @metric_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @metric_page << MetricListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @metric_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MetricListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @metric = payload.body[key].map do |data| + MetricInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def metric + @metric + end + end + class MetricInstance < InstanceResource ## # Initialize the MetricInstance diff --git a/lib/twilio-ruby/rest/insights/v1/call_summaries.rb b/lib/twilio-ruby/rest/insights/v1/call_summaries.rb index 5aba4ff78..483496c89 100644 --- a/lib/twilio-ruby/rest/insights/v1/call_summaries.rb +++ b/lib/twilio-ruby/rest/insights/v1/call_summaries.rb @@ -213,6 +213,100 @@ def stream(from: :unset, to: :unset, from_carrier: :unset, to_carrier: :unset, f @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CallSummariesPageMetadata records from the API as a list. + # @param [String] from A calling party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + # @param [String] to A called party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + # @param [String] from_carrier An origination carrier. + # @param [String] to_carrier A destination carrier. + # @param [String] from_country_code A source country code based on phone number in From. + # @param [String] to_country_code A destination country code. Based on phone number in To. + # @param [Boolean] verified_caller A boolean flag indicating whether or not the caller was verified using SHAKEN/STIR.One of 'true' or 'false'. + # @param [Boolean] has_tag A boolean flag indicating the presence of one or more [Voice Insights Call Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags). + # @param [String] start_time A Start time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 4h. + # @param [String] end_time An End Time of the calls. xm (x minutes), xh (x hours), xd (x days), 1w, 30m, 3d, 4w or datetime-ISO. Defaults to 0m. + # @param [String] call_type A Call Type of the calls. One of `carrier`, `sip`, `trunking` or `client`. + # @param [String] call_state A Call State of the calls. One of `ringing`, `completed`, `busy`, `fail`, `noanswer`, `canceled`, `answered`, `undialed`. + # @param [String] direction A Direction of the calls. One of `outbound_api`, `outbound_dial`, `inbound`, `trunking_originating`, `trunking_terminating`. + # @param [ProcessingStateRequest] processing_state A Processing State of the Call Summaries. One of `completed`, `partial` or `all`. + # @param [SortBy] sort_by A Sort By criterion for the returned list of Call Summaries. One of `start_time` or `end_time`. + # @param [String] subaccount A unique SID identifier of a Subaccount. + # @param [Boolean] abnormal_session A boolean flag indicating an abnormal session where the last SIP response was not 200 OK. + # @param [AnsweredBy] answered_by An Answered By value for the calls based on `Answering Machine Detection (AMD)`. One of `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `human` or `fax`. + # @param [String] answered_by_annotation Either machine or human. + # @param [String] connectivity_issue_annotation A Connectivity Issue with the calls. One of `no_connectivity_issue`, `invalid_number`, `caller_id`, `dropped_call`, or `number_reachability`. + # @param [String] quality_issue_annotation A subjective Quality Issue with the calls. One of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. + # @param [Boolean] spam_annotation A boolean flag indicating spam calls. + # @param [String] call_score_annotation A Call Score of the calls. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for the rated call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + # @param [Boolean] branded_enabled A boolean flag indicating whether or not the calls were branded using Twilio Branded Calls. One of 'true' or 'false' + # @param [Boolean] voice_integrity_enabled A boolean flag indicating whether or not the phone number had voice integrity enabled.One of 'true' or 'false' + # @param [String] branded_bundle_sid A unique SID identifier of the Branded Call. + # @param [Boolean] branded_logo Indicates whether the branded logo was displayed during the in_brand branded call. Possible values are true (logo was present) or false (logo was not present). + # @param [String] branded_type Indicates whether the Branded Call is in_band vs out_of_band. + # @param [String] branded_use_case Specifies the user-defined purpose for the call, as provided during the setup of in_band branded calling. + # @param [String] branded_call_reason Specifies the user-defined reason for the call, which will be displayed to the end user on their mobile device during an in_band branded call. + # @param [String] voice_integrity_bundle_sid A unique SID identifier of the Voice Integrity Profile. + # @param [String] voice_integrity_use_case A Voice Integrity Use Case . Is of type enum. One of 'abandoned_cart', 'appointment_reminders', 'appointment_scheduling', 'asset_management', 'automated_support', 'call_tracking', 'click_to_call', 'contact_tracing', 'contactless_delivery', 'customer_support', 'dating/social', 'delivery_notifications', 'distance_learning', 'emergency_notifications', 'employee_notifications', 'exam_proctoring', 'field_notifications', 'first_responder', 'fraud_alerts', 'group_messaging', 'identify_&_verification', 'intelligent_routing', 'lead_alerts', 'lead_distribution', 'lead_generation', 'lead_management', 'lead_nurturing', 'marketing_events', 'mass_alerts', 'meetings/collaboration', 'order_notifications', 'outbound_dialer', 'pharmacy', 'phone_system', 'purchase_confirmation', 'remote_appointments', 'rewards_program', 'self-service', 'service_alerts', 'shift_management', 'survey/research', 'telehealth', 'telemarketing', 'therapy_(individual+group)'. + # @param [String] business_profile_identity A Business Identity of the calls. Is of type enum. One of 'direct_customer', 'isv_reseller_or_partner'. + # @param [String] business_profile_industry A Business Industry of the calls. Is of type enum. One of 'automotive', 'agriculture', 'banking', 'consumer', 'construction', 'education', 'engineering', 'energy', 'oil_and_gas', 'fast_moving_consumer_goods', 'financial', 'fintech', 'food_and_beverage', 'government', 'healthcare', 'hospitality', 'insurance', 'legal', 'manufacturing', 'media', 'online', 'professional_services', 'raw_materials', 'real_estate', 'religion', 'retail', 'jewelry', 'technology', 'telecommunications', 'transportation', 'travel', 'electronics', 'not_for_profit' + # @param [String] business_profile_bundle_sid A unique SID identifier of the Business Profile. + # @param [String] business_profile_type A Business Profile Type of the calls. Is of type enum. One of 'primary', 'secondary'. + # @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_with_metadata(from: :unset, to: :unset, from_carrier: :unset, to_carrier: :unset, from_country_code: :unset, to_country_code: :unset, verified_caller: :unset, has_tag: :unset, start_time: :unset, end_time: :unset, call_type: :unset, call_state: :unset, direction: :unset, processing_state: :unset, sort_by: :unset, subaccount: :unset, abnormal_session: :unset, answered_by: :unset, answered_by_annotation: :unset, connectivity_issue_annotation: :unset, quality_issue_annotation: :unset, spam_annotation: :unset, call_score_annotation: :unset, branded_enabled: :unset, voice_integrity_enabled: :unset, branded_bundle_sid: :unset, branded_logo: :unset, branded_type: :unset, branded_use_case: :unset, branded_call_reason: :unset, voice_integrity_bundle_sid: :unset, voice_integrity_use_case: :unset, business_profile_identity: :unset, business_profile_industry: :unset, business_profile_bundle_sid: :unset, business_profile_type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'From' => from, + 'To' => to, + 'FromCarrier' => from_carrier, + 'ToCarrier' => to_carrier, + 'FromCountryCode' => from_country_code, + 'ToCountryCode' => to_country_code, + 'VerifiedCaller' => verified_caller, + 'HasTag' => has_tag, + 'StartTime' => start_time, + 'EndTime' => end_time, + 'CallType' => call_type, + 'CallState' => call_state, + 'Direction' => direction, + 'ProcessingState' => processing_state, + 'SortBy' => sort_by, + 'Subaccount' => subaccount, + 'AbnormalSession' => abnormal_session, + 'AnsweredBy' => answered_by, + 'AnsweredByAnnotation' => answered_by_annotation, + 'ConnectivityIssueAnnotation' => connectivity_issue_annotation, + 'QualityIssueAnnotation' => quality_issue_annotation, + 'SpamAnnotation' => spam_annotation, + 'CallScoreAnnotation' => call_score_annotation, + 'BrandedEnabled' => branded_enabled, + 'VoiceIntegrityEnabled' => voice_integrity_enabled, + 'BrandedBundleSid' => branded_bundle_sid, + 'BrandedLogo' => branded_logo, + 'BrandedType' => branded_type, + 'BrandedUseCase' => branded_use_case, + 'BrandedCallReason' => branded_call_reason, + 'VoiceIntegrityBundleSid' => voice_integrity_bundle_sid, + 'VoiceIntegrityUseCase' => voice_integrity_use_case, + 'BusinessProfileIdentity' => business_profile_identity, + 'BusinessProfileIndustry' => business_profile_industry, + 'BusinessProfileBundleSid' => business_profile_bundle_sid, + 'BusinessProfileType' => business_profile_type, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CallSummariesPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CallSummariesInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -370,6 +464,54 @@ def to_s '' end end + + class CallSummariesPageMetadata < PageMetadata + attr_reader :call_summaries_page + + def initialize(version, response, solution, limit) + super(version, response) + @call_summaries_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @call_summaries_page << CallSummariesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @call_summaries_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CallSummariesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @call_summaries = payload.body[key].map do |data| + CallSummariesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def call_summaries + @call_summaries + end + end + class CallSummariesInstance < InstanceResource ## # Initialize the CallSummariesInstance diff --git a/lib/twilio-ruby/rest/insights/v1/conference.rb b/lib/twilio-ruby/rest/insights/v1/conference.rb index e577a95f7..00c737919 100644 --- a/lib/twilio-ruby/rest/insights/v1/conference.rb +++ b/lib/twilio-ruby/rest/insights/v1/conference.rb @@ -109,6 +109,48 @@ def stream(conference_sid: :unset, friendly_name: :unset, status: :unset, create @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConferencePageMetadata records from the API as a list. + # @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_with_metadata(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) + 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, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConferencePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConferenceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -222,6 +264,31 @@ def fetch ) end + ## + # Fetch the ConferenceInstanceMetadata + # @return [ConferenceInstance] Fetched ConferenceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + conference_instance = ConferenceInstance.new( + @version, + response.body, + conference_sid: @solution[:conference_sid], + ) + ConferenceInstanceMetadata.new( + @version, + conference_instance, + response.headers, + response.status_code + ) + end + ## # Access the conference_participants # @return [ConferenceParticipantList] @@ -257,6 +324,45 @@ def inspect end end + class ConferenceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConferenceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConferenceInstance] conference_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConferenceInstanceMetadata] The initialized instance with metadata. + def initialize(version, conference_instance, headers, status_code) + super(version, headers, status_code) + @conference_instance = conference_instance + end + + def conference + @conference_instance + end + + def to_s + "" + end + end + + class ConferenceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conference_instance = payload.body[key].map do |data| + ConferenceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conference_instance + @instance + end + end + class ConferencePage < Page ## # Initialize the ConferencePage @@ -285,6 +391,54 @@ def to_s '' end end + + class ConferencePageMetadata < PageMetadata + attr_reader :conference_page + + def initialize(version, response, solution, limit) + super(version, response) + @conference_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @conference_page << ConferenceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @conference_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConferenceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conference = payload.body[key].map do |data| + ConferenceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conference + @conference + end + end + class ConferenceInstance < InstanceResource ## # Initialize the ConferenceInstance diff --git a/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb b/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb index 778dcae15..6a13c643a 100644 --- a/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb +++ b/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb @@ -83,6 +83,34 @@ def stream(participant_sid: :unset, label: :unset, events: :unset, limit: nil, p @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConferenceParticipantPageMetadata records from the API as a list. + # @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_with_metadata(participant_sid: :unset, label: :unset, events: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ParticipantSid' => participant_sid, + 'Label' => label, + 'Events' => events, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConferenceParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConferenceParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -192,6 +220,41 @@ def fetch( ) end + ## + # Fetch the ConferenceParticipantInstanceMetadata + # @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_with_metadata( + events: :unset, + metrics: :unset + ) + + params = Twilio::Values.of({ + 'Events' => events, + 'Metrics' => metrics, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + conferenceParticipant_instance = ConferenceParticipantInstance.new( + @version, + response.body, + conference_sid: @solution[:conference_sid], + participant_sid: @solution[:participant_sid], + ) + ConferenceParticipantInstanceMetadata.new( + @version, + conferenceParticipant_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -208,6 +271,45 @@ def inspect end end + class ConferenceParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConferenceParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConferenceParticipantInstance] conference_participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConferenceParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, conference_participant_instance, headers, status_code) + super(version, headers, status_code) + @conference_participant_instance = conference_participant_instance + end + + def conference_participant + @conference_participant_instance + end + + def to_s + "" + end + end + + class ConferenceParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conference_participant_instance = payload.body[key].map do |data| + ConferenceParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conference_participant_instance + @instance + end + end + class ConferenceParticipantPage < Page ## # Initialize the ConferenceParticipantPage @@ -236,6 +338,54 @@ def to_s '' end end + + class ConferenceParticipantPageMetadata < PageMetadata + attr_reader :conference_participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @conference_participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @conference_participant_page << ConferenceParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @conference_participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConferenceParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @conference_participant = payload.body[key].map do |data| + ConferenceParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def conference_participant + @conference_participant + end + end + class ConferenceParticipantInstance < InstanceResource ## # Initialize the ConferenceParticipantInstance diff --git a/lib/twilio-ruby/rest/insights/v1/room.rb b/lib/twilio-ruby/rest/insights/v1/room.rb index 39f89a337..30bf5b1da 100644 --- a/lib/twilio-ruby/rest/insights/v1/room.rb +++ b/lib/twilio-ruby/rest/insights/v1/room.rb @@ -89,6 +89,40 @@ def stream(room_type: :unset, codec: :unset, room_name: :unset, created_after: : @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RoomPageMetadata records from the API as a list. + # @param [Array[RoomType]] room_type Type of room. Can be `go`, `peer_to_peer`, `group`, or `group_small`. + # @param [Array[Codec]] codec Codecs used by participants in the room. Can be `VP8`, `H264`, or `VP9`. + # @param [String] room_name Room friendly name. + # @param [Time] created_after Only read rooms that started on or after this ISO 8601 timestamp. + # @param [Time] created_before Only read rooms that started before this ISO 8601 timestamp. + # @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_with_metadata(room_type: :unset, codec: :unset, room_name: :unset, created_after: :unset, created_before: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'RoomType' => Twilio.serialize_list(room_type) { |e| e }, + + 'Codec' => Twilio.serialize_list(codec) { |e| e }, + 'RoomName' => room_name, + 'CreatedAfter' => Twilio.serialize_iso8601_datetime(created_after), + 'CreatedBefore' => Twilio.serialize_iso8601_datetime(created_before), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RoomPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoomInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,6 +228,31 @@ def fetch ) end + ## + # Fetch the RoomInstanceMetadata + # @return [RoomInstance] Fetched RoomInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + room_instance = RoomInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + ) + RoomInstanceMetadata.new( + @version, + room_instance, + response.headers, + response.status_code + ) + end + ## # Access the participants # @return [ParticipantList] @@ -229,6 +288,45 @@ def inspect end end + class RoomInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoomInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoomInstance] room_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoomInstanceMetadata] The initialized instance with metadata. + def initialize(version, room_instance, headers, status_code) + super(version, headers, status_code) + @room_instance = room_instance + end + + def room + @room_instance + end + + def to_s + "" + end + end + + class RoomListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @room_instance = payload.body[key].map do |data| + RoomInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def room_instance + @instance + end + end + class RoomPage < Page ## # Initialize the RoomPage @@ -257,6 +355,54 @@ def to_s '' end end + + class RoomPageMetadata < PageMetadata + attr_reader :room_page + + def initialize(version, response, solution, limit) + super(version, response) + @room_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @room_page << RoomListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @room_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoomListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @room = payload.body[key].map do |data| + RoomInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def room + @room + end + end + class RoomInstance < InstanceResource ## # Initialize the RoomInstance diff --git a/lib/twilio-ruby/rest/insights/v1/room/participant.rb b/lib/twilio-ruby/rest/insights/v1/room/participant.rb index 22178fb3b..768b78ba8 100644 --- a/lib/twilio-ruby/rest/insights/v1/room/participant.rb +++ b/lib/twilio-ruby/rest/insights/v1/room/participant.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the ParticipantInstanceMetadata + # @return [ParticipantInstance] Fetched ParticipantInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + participant_sid: @solution[:participant_sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class ParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ParticipantInstance] participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, participant_instance, headers, status_code) + super(version, headers, status_code) + @participant_instance = participant_instance + end + + def participant + @participant_instance + end + + def to_s + "" + end + end + + class ParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_instance = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_instance + @instance + end + end + class ParticipantPage < Page ## # Initialize the ParticipantPage @@ -209,6 +296,54 @@ def to_s '' end end + + class ParticipantPageMetadata < PageMetadata + attr_reader :participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_page << ParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant + @participant + end + end + class ParticipantInstance < InstanceResource ## # Initialize the ParticipantInstance diff --git a/lib/twilio-ruby/rest/insights/v1/setting.rb b/lib/twilio-ruby/rest/insights/v1/setting.rb index 89b027ceb..853f572ec 100644 --- a/lib/twilio-ruby/rest/insights/v1/setting.rb +++ b/lib/twilio-ruby/rest/insights/v1/setting.rb @@ -78,6 +78,36 @@ def fetch( ) end + ## + # Fetch the SettingInstanceMetadata + # @param [String] subaccount_sid The unique SID identifier of the Subaccount. + # @return [SettingInstance] Fetched SettingInstance + def fetch_with_metadata( + subaccount_sid: :unset + ) + + params = Twilio::Values.of({ + 'SubaccountSid' => subaccount_sid, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + setting_instance = SettingInstance.new( + @version, + response.body, + ) + SettingInstanceMetadata.new( + @version, + setting_instance, + response.headers, + response.status_code + ) + end + ## # Update the SettingInstance # @param [Boolean] advanced_features A boolean flag to enable Advanced Features for Voice Insights. @@ -109,6 +139,43 @@ def update( ) end + ## + # Update the SettingInstanceMetadata + # @param [Boolean] advanced_features A boolean flag to enable Advanced Features for Voice Insights. + # @param [Boolean] voice_trace A boolean flag to enable Voice Trace. + # @param [String] subaccount_sid The unique SID identifier of the Subaccount. + # @return [SettingInstance] Updated SettingInstance + def update_with_metadata( + advanced_features: :unset, + voice_trace: :unset, + subaccount_sid: :unset + ) + + data = Twilio::Values.of({ + 'AdvancedFeatures' => advanced_features, + 'VoiceTrace' => voice_trace, + 'SubaccountSid' => subaccount_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + setting_instance = SettingInstance.new( + @version, + response.body, + ) + SettingInstanceMetadata.new( + @version, + setting_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -125,6 +192,45 @@ def inspect end end + class SettingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SettingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SettingInstance] setting_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SettingInstanceMetadata] The initialized instance with metadata. + def initialize(version, setting_instance, headers, status_code) + super(version, headers, status_code) + @setting_instance = setting_instance + end + + def setting + @setting_instance + end + + def to_s + "" + end + end + + class SettingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @setting_instance = payload.body[key].map do |data| + SettingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def setting_instance + @instance + end + end + class SettingPage < Page ## # Initialize the SettingPage @@ -153,6 +259,54 @@ def to_s '' end end + + class SettingPageMetadata < PageMetadata + attr_reader :setting_page + + def initialize(version, response, solution, limit) + super(version, response) + @setting_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @setting_page << SettingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @setting_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SettingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @setting = payload.body[key].map do |data| + SettingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def setting + @setting + end + end + class SettingInstance < InstanceResource ## # Initialize the SettingInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb b/lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb index 3a7ded6c6..59405512d 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the CustomOperatorInstanceMetadata + # @param [String] friendly_name A human readable description of the new Operator, up to 64 characters. + # @param [String] operator_type Operator Type for this Operator. References an existing Operator Type resource. + # @param [Object] config Operator configuration, following the schema defined by the Operator Type. + # @return [CustomOperatorInstance] Created CustomOperatorInstance + def create_with_metadata( + friendly_name: nil, + operator_type: nil, + config: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'OperatorType' => operator_type, + 'Config' => Twilio.serialize_object(config), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + customOperator_instance = CustomOperatorInstance.new( + @version, + response.body, + ) + CustomOperatorInstanceMetadata.new( + @version, + customOperator_instance, + response.headers, + response.status_code + ) + end + ## # Lists CustomOperatorInstance records from the API as a list. @@ -108,6 +145,32 @@ def stream(availability: :unset, language_code: :unset, limit: nil, page_size: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CustomOperatorPageMetadata records from the API as a list. + # @param [Availability] availability Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. + # @param [String] language_code Returns Custom Operators that support the provided language code. + # @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_with_metadata(availability: :unset, language_code: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Availability' => availability, + 'LanguageCode' => language_code, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CustomOperatorPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CustomOperatorInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,7 +257,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CustomOperatorInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + customOperator_instance = CustomOperatorInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CustomOperatorInstanceMetadata.new(@version, customOperator_instance, response.headers, response.status_code) end ## @@ -216,6 +298,31 @@ def fetch ) end + ## + # Fetch the CustomOperatorInstanceMetadata + # @return [CustomOperatorInstance] Fetched CustomOperatorInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + customOperator_instance = CustomOperatorInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CustomOperatorInstanceMetadata.new( + @version, + customOperator_instance, + response.headers, + response.status_code + ) + end + ## # Update the CustomOperatorInstance # @param [String] friendly_name A human-readable name of this resource, up to 64 characters. @@ -247,6 +354,43 @@ def update( ) end + ## + # Update the CustomOperatorInstanceMetadata + # @param [String] friendly_name A human-readable name of this resource, up to 64 characters. + # @param [Object] config Operator configuration, following the schema defined by the Operator Type. + # @param [String] if_match The If-Match HTTP request header + # @return [CustomOperatorInstance] Updated CustomOperatorInstance + def update_with_metadata( + friendly_name: nil, + config: nil, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Config' => Twilio.serialize_object(config), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + customOperator_instance = CustomOperatorInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CustomOperatorInstanceMetadata.new( + @version, + customOperator_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -263,6 +407,45 @@ def inspect end end + class CustomOperatorInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CustomOperatorInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CustomOperatorInstance] custom_operator_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CustomOperatorInstanceMetadata] The initialized instance with metadata. + def initialize(version, custom_operator_instance, headers, status_code) + super(version, headers, status_code) + @custom_operator_instance = custom_operator_instance + end + + def custom_operator + @custom_operator_instance + end + + def to_s + "" + end + end + + class CustomOperatorListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @custom_operator_instance = payload.body[key].map do |data| + CustomOperatorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def custom_operator_instance + @instance + end + end + class CustomOperatorPage < Page ## # Initialize the CustomOperatorPage @@ -291,6 +474,54 @@ def to_s '' end end + + class CustomOperatorPageMetadata < PageMetadata + attr_reader :custom_operator_page + + def initialize(version, response, solution, limit) + super(version, response) + @custom_operator_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @custom_operator_page << CustomOperatorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @custom_operator_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CustomOperatorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @custom_operator = payload.body[key].map do |data| + CustomOperatorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def custom_operator + @custom_operator + end + end + class CustomOperatorInstance < InstanceResource ## # Initialize the CustomOperatorInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/operator.rb b/lib/twilio-ruby/rest/intelligence/v2/operator.rb index 118319bb1..5a4327632 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/operator.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/operator.rb @@ -77,6 +77,32 @@ def stream(availability: :unset, language_code: :unset, limit: nil, page_size: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists OperatorPageMetadata records from the API as a list. + # @param [Availability] availability Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. + # @param [String] language_code Returns Operators that support the provided language code. + # @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_with_metadata(availability: :unset, language_code: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Availability' => availability, + 'LanguageCode' => language_code, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + OperatorPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields OperatorInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -173,6 +199,31 @@ def fetch ) end + ## + # Fetch the OperatorInstanceMetadata + # @return [OperatorInstance] Fetched OperatorInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + operator_instance = OperatorInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + OperatorInstanceMetadata.new( + @version, + operator_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -189,6 +240,45 @@ def inspect end end + class OperatorInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OperatorInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OperatorInstance] operator_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OperatorInstanceMetadata] The initialized instance with metadata. + def initialize(version, operator_instance, headers, status_code) + super(version, headers, status_code) + @operator_instance = operator_instance + end + + def operator + @operator_instance + end + + def to_s + "" + end + end + + class OperatorListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_instance = payload.body[key].map do |data| + OperatorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_instance + @instance + end + end + class OperatorPage < Page ## # Initialize the OperatorPage @@ -217,6 +307,54 @@ def to_s '' end end + + class OperatorPageMetadata < PageMetadata + attr_reader :operator_page + + def initialize(version, response, solution, limit) + super(version, response) + @operator_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @operator_page << OperatorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @operator_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OperatorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator = payload.body[key].map do |data| + OperatorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator + @operator + end + end + class OperatorInstance < InstanceResource ## # Initialize the OperatorInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/operator_attachment.rb b/lib/twilio-ruby/rest/intelligence/v2/operator_attachment.rb index 6bf03cb3e..28d82ecf4 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/operator_attachment.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/operator_attachment.rb @@ -76,6 +76,32 @@ def create ) end + ## + # Create the OperatorAttachmentInstanceMetadata + # @return [OperatorAttachmentInstance] Created OperatorAttachmentInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + operatorAttachment_instance = OperatorAttachmentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + operator_sid: @solution[:operator_sid], + ) + OperatorAttachmentInstanceMetadata.new( + @version, + operatorAttachment_instance, + response.headers, + response.status_code + ) + end + ## # Delete the OperatorAttachmentInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -85,7 +111,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the OperatorAttachmentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + operatorAttachment_instance = OperatorAttachmentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + OperatorAttachmentInstanceMetadata.new(@version, operatorAttachment_instance, response.headers, response.status_code) end @@ -104,6 +149,45 @@ def inspect end end + class OperatorAttachmentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OperatorAttachmentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OperatorAttachmentInstance] operator_attachment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OperatorAttachmentInstanceMetadata] The initialized instance with metadata. + def initialize(version, operator_attachment_instance, headers, status_code) + super(version, headers, status_code) + @operator_attachment_instance = operator_attachment_instance + end + + def operator_attachment + @operator_attachment_instance + end + + def to_s + "" + end + end + + class OperatorAttachmentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_attachment_instance = payload.body[key].map do |data| + OperatorAttachmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_attachment_instance + @instance + end + end + class OperatorAttachmentPage < Page ## # Initialize the OperatorAttachmentPage @@ -132,6 +216,54 @@ def to_s '' end end + + class OperatorAttachmentPageMetadata < PageMetadata + attr_reader :operator_attachment_page + + def initialize(version, response, solution, limit) + super(version, response) + @operator_attachment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @operator_attachment_page << OperatorAttachmentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @operator_attachment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OperatorAttachmentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_attachment = payload.body[key].map do |data| + OperatorAttachmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_attachment + @operator_attachment + end + end + class OperatorAttachmentInstance < InstanceResource ## # Initialize the OperatorAttachmentInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/operator_attachments.rb b/lib/twilio-ruby/rest/intelligence/v2/operator_attachments.rb index bb55bf615..4fe303f32 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/operator_attachments.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/operator_attachments.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the OperatorAttachmentsInstanceMetadata + # @return [OperatorAttachmentsInstance] Fetched OperatorAttachmentsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + operatorAttachments_instance = OperatorAttachmentsInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + OperatorAttachmentsInstanceMetadata.new( + @version, + operatorAttachments_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -90,6 +115,45 @@ def inspect end end + class OperatorAttachmentsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OperatorAttachmentsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OperatorAttachmentsInstance] operator_attachments_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OperatorAttachmentsInstanceMetadata] The initialized instance with metadata. + def initialize(version, operator_attachments_instance, headers, status_code) + super(version, headers, status_code) + @operator_attachments_instance = operator_attachments_instance + end + + def operator_attachments + @operator_attachments_instance + end + + def to_s + "" + end + end + + class OperatorAttachmentsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_attachments_instance = payload.body[key].map do |data| + OperatorAttachmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_attachments_instance + @instance + end + end + class OperatorAttachmentsPage < Page ## # Initialize the OperatorAttachmentsPage @@ -118,6 +182,54 @@ def to_s '' end end + + class OperatorAttachmentsPageMetadata < PageMetadata + attr_reader :operator_attachments_page + + def initialize(version, response, solution, limit) + super(version, response) + @operator_attachments_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @operator_attachments_page << OperatorAttachmentsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @operator_attachments_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OperatorAttachmentsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_attachments = payload.body[key].map do |data| + OperatorAttachmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_attachments + @operator_attachments + end + end + class OperatorAttachmentsInstance < InstanceResource ## # Initialize the OperatorAttachmentsInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/operator_type.rb b/lib/twilio-ruby/rest/intelligence/v2/operator_type.rb index 6d2d9991f..cdaec22ce 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/operator_type.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/operator_type.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists OperatorTypePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + OperatorTypePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields OperatorTypeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -161,6 +183,31 @@ def fetch ) end + ## + # Fetch the OperatorTypeInstanceMetadata + # @return [OperatorTypeInstance] Fetched OperatorTypeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + operatorType_instance = OperatorTypeInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + OperatorTypeInstanceMetadata.new( + @version, + operatorType_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -177,6 +224,45 @@ def inspect end end + class OperatorTypeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OperatorTypeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OperatorTypeInstance] operator_type_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OperatorTypeInstanceMetadata] The initialized instance with metadata. + def initialize(version, operator_type_instance, headers, status_code) + super(version, headers, status_code) + @operator_type_instance = operator_type_instance + end + + def operator_type + @operator_type_instance + end + + def to_s + "" + end + end + + class OperatorTypeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_type_instance = payload.body[key].map do |data| + OperatorTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_type_instance + @instance + end + end + class OperatorTypePage < Page ## # Initialize the OperatorTypePage @@ -205,6 +291,54 @@ def to_s '' end end + + class OperatorTypePageMetadata < PageMetadata + attr_reader :operator_type_page + + def initialize(version, response, solution, limit) + super(version, response) + @operator_type_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @operator_type_page << OperatorTypeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @operator_type_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OperatorTypeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_type = payload.body[key].map do |data| + OperatorTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_type + @operator_type + end + end + class OperatorTypeInstance < InstanceResource ## # Initialize the OperatorTypeInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/prebuilt_operator.rb b/lib/twilio-ruby/rest/intelligence/v2/prebuilt_operator.rb index 1a66e8871..f73097a61 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/prebuilt_operator.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/prebuilt_operator.rb @@ -77,6 +77,32 @@ def stream(availability: :unset, language_code: :unset, limit: nil, page_size: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PrebuiltOperatorPageMetadata records from the API as a list. + # @param [Availability] availability Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. + # @param [String] language_code Returns Pre-built Operators that support the provided language code. + # @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_with_metadata(availability: :unset, language_code: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Availability' => availability, + 'LanguageCode' => language_code, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PrebuiltOperatorPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PrebuiltOperatorInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -173,6 +199,31 @@ def fetch ) end + ## + # Fetch the PrebuiltOperatorInstanceMetadata + # @return [PrebuiltOperatorInstance] Fetched PrebuiltOperatorInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + prebuiltOperator_instance = PrebuiltOperatorInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PrebuiltOperatorInstanceMetadata.new( + @version, + prebuiltOperator_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -189,6 +240,45 @@ def inspect end end + class PrebuiltOperatorInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PrebuiltOperatorInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PrebuiltOperatorInstance] prebuilt_operator_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PrebuiltOperatorInstanceMetadata] The initialized instance with metadata. + def initialize(version, prebuilt_operator_instance, headers, status_code) + super(version, headers, status_code) + @prebuilt_operator_instance = prebuilt_operator_instance + end + + def prebuilt_operator + @prebuilt_operator_instance + end + + def to_s + "" + end + end + + class PrebuiltOperatorListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @prebuilt_operator_instance = payload.body[key].map do |data| + PrebuiltOperatorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def prebuilt_operator_instance + @instance + end + end + class PrebuiltOperatorPage < Page ## # Initialize the PrebuiltOperatorPage @@ -217,6 +307,54 @@ def to_s '' end end + + class PrebuiltOperatorPageMetadata < PageMetadata + attr_reader :prebuilt_operator_page + + def initialize(version, response, solution, limit) + super(version, response) + @prebuilt_operator_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @prebuilt_operator_page << PrebuiltOperatorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @prebuilt_operator_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PrebuiltOperatorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @prebuilt_operator = payload.body[key].map do |data| + PrebuiltOperatorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def prebuilt_operator + @prebuilt_operator + end + end + class PrebuiltOperatorInstance < InstanceResource ## # Initialize the PrebuiltOperatorInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/service.rb b/lib/twilio-ruby/rest/intelligence/v2/service.rb index 9c3b774ed..f298f8212 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/service.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/service.rb @@ -82,6 +82,64 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] unique_name Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. + # @param [Boolean] auto_transcribe Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. + # @param [Boolean] data_logging Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. + # @param [String] friendly_name A human readable description of this resource, up to 64 characters. + # @param [String] language_code The language code set during Service creation determines the Transcription language for all call recordings processed by that Service. The default is en-US if no language code is set. A Service can only support one language code, and it cannot be updated once it's set. + # @param [Boolean] auto_redaction Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. + # @param [Boolean] media_redaction Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. + # @param [String] webhook_url The URL Twilio will request when executing the Webhook. + # @param [HttpMethod] webhook_http_method + # @param [String] encryption_credential_sid The unique SID identifier of the Public Key resource used to encrypt the sentences and operator results. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + unique_name: nil, + auto_transcribe: :unset, + data_logging: :unset, + friendly_name: :unset, + language_code: :unset, + auto_redaction: :unset, + media_redaction: :unset, + webhook_url: :unset, + webhook_http_method: :unset, + encryption_credential_sid: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'AutoTranscribe' => auto_transcribe, + 'DataLogging' => data_logging, + 'FriendlyName' => friendly_name, + 'LanguageCode' => language_code, + 'AutoRedaction' => auto_redaction, + 'MediaRedaction' => media_redaction, + 'WebhookUrl' => webhook_url, + 'WebhookHttpMethod' => webhook_http_method, + 'EncryptionCredentialSid' => encryption_credential_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -121,6 +179,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -203,7 +283,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -225,6 +324,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [Boolean] auto_transcribe Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. @@ -277,6 +401,64 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [Boolean] auto_transcribe Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. + # @param [Boolean] data_logging Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. + # @param [String] friendly_name A human readable description of this resource, up to 64 characters. + # @param [String] unique_name Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. + # @param [Boolean] auto_redaction Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. + # @param [Boolean] media_redaction Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. + # @param [String] webhook_url The URL Twilio will request when executing the Webhook. + # @param [HttpMethod] webhook_http_method + # @param [String] encryption_credential_sid The unique SID identifier of the Public Key resource used to encrypt the sentences and operator results. + # @param [String] if_match The If-Match HTTP request header + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + auto_transcribe: :unset, + data_logging: :unset, + friendly_name: :unset, + unique_name: :unset, + auto_redaction: :unset, + media_redaction: :unset, + webhook_url: :unset, + webhook_http_method: :unset, + encryption_credential_sid: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'AutoTranscribe' => auto_transcribe, + 'DataLogging' => data_logging, + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'AutoRedaction' => auto_redaction, + 'MediaRedaction' => media_redaction, + 'WebhookUrl' => webhook_url, + 'WebhookHttpMethod' => webhook_http_method, + 'EncryptionCredentialSid' => encryption_credential_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -293,6 +475,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -321,6 +542,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/transcript.rb b/lib/twilio-ruby/rest/intelligence/v2/transcript.rb index 00896cae4..2fe8119f6 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/transcript.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/transcript.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the TranscriptInstanceMetadata + # @param [String] service_sid The unique SID identifier of the Service. + # @param [Object] channel JSON object describing Media Channel including Source and Participants + # @param [String] customer_key Used to store client provided metadata. Maximum of 64 double-byte UTF8 characters. + # @param [Time] media_start_time The date that this Transcript's media was started, given in ISO 8601 format. + # @return [TranscriptInstance] Created TranscriptInstance + def create_with_metadata( + service_sid: nil, + channel: nil, + customer_key: :unset, + media_start_time: :unset + ) + + data = Twilio::Values.of({ + 'ServiceSid' => service_sid, + 'Channel' => Twilio.serialize_object(channel), + 'CustomerKey' => customer_key, + 'MediaStartTime' => Twilio.serialize_iso8601_datetime(media_start_time), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + transcript_instance = TranscriptInstance.new( + @version, + response.body, + ) + TranscriptInstanceMetadata.new( + @version, + transcript_instance, + response.headers, + response.status_code + ) + end + ## # Lists TranscriptInstance records from the API as a list. @@ -135,6 +175,44 @@ def stream(service_sid: :unset, before_start_time: :unset, after_start_time: :un @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TranscriptPageMetadata records from the API as a list. + # @param [String] service_sid The unique SID identifier of the Service. + # @param [String] before_start_time Filter by before StartTime. + # @param [String] after_start_time Filter by after StartTime. + # @param [String] before_date_created Filter by before DateCreated. + # @param [String] after_date_created Filter by after DateCreated. + # @param [String] status Filter by status. + # @param [String] language_code Filter by Language Code. + # @param [String] source_sid Filter by SourceSid. + # @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_with_metadata(service_sid: :unset, before_start_time: :unset, after_start_time: :unset, before_date_created: :unset, after_date_created: :unset, status: :unset, language_code: :unset, source_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ServiceSid' => service_sid, + 'BeforeStartTime' => before_start_time, + 'AfterStartTime' => after_start_time, + 'BeforeDateCreated' => before_date_created, + 'AfterDateCreated' => after_date_created, + 'Status' => status, + 'LanguageCode' => language_code, + 'SourceSid' => source_sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TranscriptPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TranscriptInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -238,7 +316,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TranscriptInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + transcript_instance = TranscriptInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TranscriptInstanceMetadata.new(@version, transcript_instance, response.headers, response.status_code) end ## @@ -260,6 +357,31 @@ def fetch ) end + ## + # Fetch the TranscriptInstanceMetadata + # @return [TranscriptInstance] Fetched TranscriptInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + transcript_instance = TranscriptInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + TranscriptInstanceMetadata.new( + @version, + transcript_instance, + response.headers, + response.status_code + ) + end + ## # Access the sentences # @return [SentenceList] @@ -336,6 +458,45 @@ def inspect end end + class TranscriptInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TranscriptInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TranscriptInstance] transcript_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TranscriptInstanceMetadata] The initialized instance with metadata. + def initialize(version, transcript_instance, headers, status_code) + super(version, headers, status_code) + @transcript_instance = transcript_instance + end + + def transcript + @transcript_instance + end + + def to_s + "" + end + end + + class TranscriptListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcript_instance = payload.body[key].map do |data| + TranscriptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcript_instance + @instance + end + end + class TranscriptPage < Page ## # Initialize the TranscriptPage @@ -364,6 +525,54 @@ def to_s '' end end + + class TranscriptPageMetadata < PageMetadata + attr_reader :transcript_page + + def initialize(version, response, solution, limit) + super(version, response) + @transcript_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @transcript_page << TranscriptListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @transcript_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TranscriptListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcript = payload.body[key].map do |data| + TranscriptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcript + @transcript + end + end + class TranscriptInstance < InstanceResource ## # Initialize the TranscriptInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_operator_results.rb b/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_operator_results.rb index 06e181017..d25f0b90f 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_operator_results.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_operator_results.rb @@ -82,6 +82,37 @@ def fetch( ) end + ## + # Fetch the EncryptedOperatorResultsInstanceMetadata + # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results. + # @return [EncryptedOperatorResultsInstance] Fetched EncryptedOperatorResultsInstance + def fetch_with_metadata( + redacted: :unset + ) + + params = Twilio::Values.of({ + 'Redacted' => redacted, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + encryptedOperatorResults_instance = EncryptedOperatorResultsInstance.new( + @version, + response.body, + transcript_sid: @solution[:transcript_sid], + ) + EncryptedOperatorResultsInstanceMetadata.new( + @version, + encryptedOperatorResults_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +129,45 @@ def inspect end end + class EncryptedOperatorResultsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EncryptedOperatorResultsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EncryptedOperatorResultsInstance] encrypted_operator_results_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EncryptedOperatorResultsInstanceMetadata] The initialized instance with metadata. + def initialize(version, encrypted_operator_results_instance, headers, status_code) + super(version, headers, status_code) + @encrypted_operator_results_instance = encrypted_operator_results_instance + end + + def encrypted_operator_results + @encrypted_operator_results_instance + end + + def to_s + "" + end + end + + class EncryptedOperatorResultsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @encrypted_operator_results_instance = payload.body[key].map do |data| + EncryptedOperatorResultsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def encrypted_operator_results_instance + @instance + end + end + class EncryptedOperatorResultsPage < Page ## # Initialize the EncryptedOperatorResultsPage @@ -126,6 +196,54 @@ def to_s '' end end + + class EncryptedOperatorResultsPageMetadata < PageMetadata + attr_reader :encrypted_operator_results_page + + def initialize(version, response, solution, limit) + super(version, response) + @encrypted_operator_results_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @encrypted_operator_results_page << EncryptedOperatorResultsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @encrypted_operator_results_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EncryptedOperatorResultsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @encrypted_operator_results = payload.body[key].map do |data| + EncryptedOperatorResultsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def encrypted_operator_results + @encrypted_operator_results + end + end + class EncryptedOperatorResultsInstance < InstanceResource ## # Initialize the EncryptedOperatorResultsInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_sentences.rb b/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_sentences.rb index 608a81467..f19a6d4ba 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_sentences.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/transcript/encrypted_sentences.rb @@ -82,6 +82,37 @@ def fetch( ) end + ## + # Fetch the EncryptedSentencesInstanceMetadata + # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + # @return [EncryptedSentencesInstance] Fetched EncryptedSentencesInstance + def fetch_with_metadata( + redacted: :unset + ) + + params = Twilio::Values.of({ + 'Redacted' => redacted, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + encryptedSentences_instance = EncryptedSentencesInstance.new( + @version, + response.body, + transcript_sid: @solution[:transcript_sid], + ) + EncryptedSentencesInstanceMetadata.new( + @version, + encryptedSentences_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +129,45 @@ def inspect end end + class EncryptedSentencesInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EncryptedSentencesInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EncryptedSentencesInstance] encrypted_sentences_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EncryptedSentencesInstanceMetadata] The initialized instance with metadata. + def initialize(version, encrypted_sentences_instance, headers, status_code) + super(version, headers, status_code) + @encrypted_sentences_instance = encrypted_sentences_instance + end + + def encrypted_sentences + @encrypted_sentences_instance + end + + def to_s + "" + end + end + + class EncryptedSentencesListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @encrypted_sentences_instance = payload.body[key].map do |data| + EncryptedSentencesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def encrypted_sentences_instance + @instance + end + end + class EncryptedSentencesPage < Page ## # Initialize the EncryptedSentencesPage @@ -126,6 +196,54 @@ def to_s '' end end + + class EncryptedSentencesPageMetadata < PageMetadata + attr_reader :encrypted_sentences_page + + def initialize(version, response, solution, limit) + super(version, response) + @encrypted_sentences_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @encrypted_sentences_page << EncryptedSentencesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @encrypted_sentences_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EncryptedSentencesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @encrypted_sentences = payload.body[key].map do |data| + EncryptedSentencesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def encrypted_sentences + @encrypted_sentences + end + end + class EncryptedSentencesInstance < InstanceResource ## # Initialize the EncryptedSentencesInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/transcript/media.rb b/lib/twilio-ruby/rest/intelligence/v2/transcript/media.rb index ef183d4a7..fa2fe1920 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/transcript/media.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/transcript/media.rb @@ -82,6 +82,37 @@ def fetch( ) end + ## + # Fetch the MediaInstanceMetadata + # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Media. If redaction is enabled, the default is `true` to access redacted media. + # @return [MediaInstance] Fetched MediaInstance + def fetch_with_metadata( + redacted: :unset + ) + + params = Twilio::Values.of({ + 'Redacted' => redacted, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + media_instance = MediaInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + MediaInstanceMetadata.new( + @version, + media_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +129,45 @@ def inspect end end + class MediaInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MediaInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MediaInstance] media_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MediaInstanceMetadata] The initialized instance with metadata. + def initialize(version, media_instance, headers, status_code) + super(version, headers, status_code) + @media_instance = media_instance + end + + def media + @media_instance + end + + def to_s + "" + end + end + + class MediaListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @media_instance = payload.body[key].map do |data| + MediaInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def media_instance + @instance + end + end + class MediaPage < Page ## # Initialize the MediaPage @@ -126,6 +196,54 @@ def to_s '' end end + + class MediaPageMetadata < PageMetadata + attr_reader :media_page + + def initialize(version, response, solution, limit) + super(version, response) + @media_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @media_page << MediaListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @media_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MediaListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @media = payload.body[key].map do |data| + MediaInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def media + @media + end + end + class MediaInstance < InstanceResource ## # Initialize the MediaInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/transcript/operator_result.rb b/lib/twilio-ruby/rest/intelligence/v2/transcript/operator_result.rb index 03c7ffb9a..31460340e 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/transcript/operator_result.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/transcript/operator_result.rb @@ -75,6 +75,30 @@ def stream(redacted: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists OperatorResultPageMetadata records from the API as a list. + # @param [Boolean] redacted Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + # @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_with_metadata(redacted: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Redacted' => redacted, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + OperatorResultPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields OperatorResultInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -177,6 +201,38 @@ def fetch( ) end + ## + # Fetch the OperatorResultInstanceMetadata + # @param [Boolean] redacted Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + # @return [OperatorResultInstance] Fetched OperatorResultInstance + def fetch_with_metadata( + redacted: :unset + ) + + params = Twilio::Values.of({ + 'Redacted' => redacted, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + operatorResult_instance = OperatorResultInstance.new( + @version, + response.body, + transcript_sid: @solution[:transcript_sid], + operator_sid: @solution[:operator_sid], + ) + OperatorResultInstanceMetadata.new( + @version, + operatorResult_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -193,6 +249,45 @@ def inspect end end + class OperatorResultInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OperatorResultInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OperatorResultInstance] operator_result_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OperatorResultInstanceMetadata] The initialized instance with metadata. + def initialize(version, operator_result_instance, headers, status_code) + super(version, headers, status_code) + @operator_result_instance = operator_result_instance + end + + def operator_result + @operator_result_instance + end + + def to_s + "" + end + end + + class OperatorResultListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_result_instance = payload.body[key].map do |data| + OperatorResultInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_result_instance + @instance + end + end + class OperatorResultPage < Page ## # Initialize the OperatorResultPage @@ -221,6 +316,54 @@ def to_s '' end end + + class OperatorResultPageMetadata < PageMetadata + attr_reader :operator_result_page + + def initialize(version, response, solution, limit) + super(version, response) + @operator_result_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @operator_result_page << OperatorResultListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @operator_result_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OperatorResultListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @operator_result = payload.body[key].map do |data| + OperatorResultInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def operator_result + @operator_result + end + end + class OperatorResultInstance < InstanceResource ## # Initialize the OperatorResultInstance diff --git a/lib/twilio-ruby/rest/intelligence/v2/transcript/sentence.rb b/lib/twilio-ruby/rest/intelligence/v2/transcript/sentence.rb index d8d228fcb..1bc34bbf7 100644 --- a/lib/twilio-ruby/rest/intelligence/v2/transcript/sentence.rb +++ b/lib/twilio-ruby/rest/intelligence/v2/transcript/sentence.rb @@ -79,6 +79,32 @@ def stream(redacted: :unset, word_timestamps: :unset, limit: nil, page_size: nil @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SentencePageMetadata records from the API as a list. + # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences. + # @param [Boolean] word_timestamps Returns word level timestamps information, if word_timestamps is enabled. The default is `false`. + # @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_with_metadata(redacted: :unset, word_timestamps: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Redacted' => redacted, + 'WordTimestamps' => word_timestamps, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SentencePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SentenceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +194,54 @@ def to_s '' end end + + class SentencePageMetadata < PageMetadata + attr_reader :sentence_page + + def initialize(version, response, solution, limit) + super(version, response) + @sentence_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sentence_page << SentenceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sentence_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SentenceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sentence = payload.body[key].map do |data| + SentenceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sentence + @sentence + end + end + class SentenceInstance < InstanceResource ## # Initialize the SentenceInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/credential.rb b/lib/twilio-ruby/rest/ip_messaging/v1/credential.rb index a2c248926..c458fe9d9 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/credential.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/credential.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CredentialInstanceMetadata + # @param [PushService] type + # @param [String] friendly_name + # @param [String] certificate + # @param [String] private_key + # @param [Boolean] sandbox + # @param [String] api_key + # @param [String] secret + # @return [CredentialInstance] Created CredentialInstance + def create_with_metadata( + type: nil, + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialInstance records from the API as a list. @@ -112,6 +161,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code) end ## @@ -216,6 +306,31 @@ def fetch ) end + ## + # Fetch the CredentialInstanceMetadata + # @return [CredentialInstance] Fetched CredentialInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialInstance # @param [String] friendly_name @@ -257,6 +372,53 @@ def update( ) end + ## + # Update the CredentialInstanceMetadata + # @param [String] friendly_name + # @param [String] certificate + # @param [String] private_key + # @param [Boolean] sandbox + # @param [String] api_key + # @param [String] secret + # @return [CredentialInstance] Updated CredentialInstance + def update_with_metadata( + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -273,6 +435,45 @@ def inspect end end + class CredentialInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialInstance] credential_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_instance, headers, status_code) + super(version, headers, status_code) + @credential_instance = credential_instance + end + + def credential + @credential_instance + end + + def to_s + "" + end + end + + class CredentialListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_instance = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_instance + @instance + end + end + class CredentialPage < Page ## # Initialize the CredentialPage @@ -301,6 +502,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service.rb index 735e99834..6d2f61891 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -94,6 +125,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -179,7 +232,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -201,6 +273,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] friendly_name @@ -386,6 +483,197 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] friendly_name + # @param [String] default_service_role_sid + # @param [String] default_channel_role_sid + # @param [String] default_channel_creator_role_sid + # @param [Boolean] read_status_enabled + # @param [Boolean] reachability_enabled + # @param [String] typing_indicator_timeout + # @param [String] consumption_report_interval + # @param [Boolean] notifications_new_message_enabled + # @param [String] notifications_new_message_template + # @param [Boolean] notifications_added_to_channel_enabled + # @param [String] notifications_added_to_channel_template + # @param [Boolean] notifications_removed_from_channel_enabled + # @param [String] notifications_removed_from_channel_template + # @param [Boolean] notifications_invited_to_channel_enabled + # @param [String] notifications_invited_to_channel_template + # @param [String] pre_webhook_url + # @param [String] post_webhook_url + # @param [String] webhook_method + # @param [Array[String]] webhook_filters + # @param [String] webhooks_on_message_send_url + # @param [String] webhooks_on_message_send_method + # @param [String] webhooks_on_message_update_url + # @param [String] webhooks_on_message_update_method + # @param [String] webhooks_on_message_remove_url + # @param [String] webhooks_on_message_remove_method + # @param [String] webhooks_on_channel_add_url + # @param [String] webhooks_on_channel_add_method + # @param [String] webhooks_on_channel_destroy_url + # @param [String] webhooks_on_channel_destroy_method + # @param [String] webhooks_on_channel_update_url + # @param [String] webhooks_on_channel_update_method + # @param [String] webhooks_on_member_add_url + # @param [String] webhooks_on_member_add_method + # @param [String] webhooks_on_member_remove_url + # @param [String] webhooks_on_member_remove_method + # @param [String] webhooks_on_message_sent_url + # @param [String] webhooks_on_message_sent_method + # @param [String] webhooks_on_message_updated_url + # @param [String] webhooks_on_message_updated_method + # @param [String] webhooks_on_message_removed_url + # @param [String] webhooks_on_message_removed_method + # @param [String] webhooks_on_channel_added_url + # @param [String] webhooks_on_channel_added_method + # @param [String] webhooks_on_channel_destroyed_url + # @param [String] webhooks_on_channel_destroyed_method + # @param [String] webhooks_on_channel_updated_url + # @param [String] webhooks_on_channel_updated_method + # @param [String] webhooks_on_member_added_url + # @param [String] webhooks_on_member_added_method + # @param [String] webhooks_on_member_removed_url + # @param [String] webhooks_on_member_removed_method + # @param [String] limits_channel_members + # @param [String] limits_user_channels + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + friendly_name: :unset, + default_service_role_sid: :unset, + default_channel_role_sid: :unset, + default_channel_creator_role_sid: :unset, + read_status_enabled: :unset, + reachability_enabled: :unset, + typing_indicator_timeout: :unset, + consumption_report_interval: :unset, + notifications_new_message_enabled: :unset, + notifications_new_message_template: :unset, + notifications_added_to_channel_enabled: :unset, + notifications_added_to_channel_template: :unset, + notifications_removed_from_channel_enabled: :unset, + notifications_removed_from_channel_template: :unset, + notifications_invited_to_channel_enabled: :unset, + notifications_invited_to_channel_template: :unset, + pre_webhook_url: :unset, + post_webhook_url: :unset, + webhook_method: :unset, + webhook_filters: :unset, + webhooks_on_message_send_url: :unset, + webhooks_on_message_send_method: :unset, + webhooks_on_message_update_url: :unset, + webhooks_on_message_update_method: :unset, + webhooks_on_message_remove_url: :unset, + webhooks_on_message_remove_method: :unset, + webhooks_on_channel_add_url: :unset, + webhooks_on_channel_add_method: :unset, + webhooks_on_channel_destroy_url: :unset, + webhooks_on_channel_destroy_method: :unset, + webhooks_on_channel_update_url: :unset, + webhooks_on_channel_update_method: :unset, + webhooks_on_member_add_url: :unset, + webhooks_on_member_add_method: :unset, + webhooks_on_member_remove_url: :unset, + webhooks_on_member_remove_method: :unset, + webhooks_on_message_sent_url: :unset, + webhooks_on_message_sent_method: :unset, + webhooks_on_message_updated_url: :unset, + webhooks_on_message_updated_method: :unset, + webhooks_on_message_removed_url: :unset, + webhooks_on_message_removed_method: :unset, + webhooks_on_channel_added_url: :unset, + webhooks_on_channel_added_method: :unset, + webhooks_on_channel_destroyed_url: :unset, + webhooks_on_channel_destroyed_method: :unset, + webhooks_on_channel_updated_url: :unset, + webhooks_on_channel_updated_method: :unset, + webhooks_on_member_added_url: :unset, + webhooks_on_member_added_method: :unset, + webhooks_on_member_removed_url: :unset, + webhooks_on_member_removed_method: :unset, + limits_channel_members: :unset, + limits_user_channels: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DefaultServiceRoleSid' => default_service_role_sid, + 'DefaultChannelRoleSid' => default_channel_role_sid, + 'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid, + 'ReadStatusEnabled' => read_status_enabled, + 'ReachabilityEnabled' => reachability_enabled, + 'TypingIndicatorTimeout' => typing_indicator_timeout, + 'ConsumptionReportInterval' => consumption_report_interval, + 'Notifications.NewMessage.Enabled' => notifications_new_message_enabled, + 'Notifications.NewMessage.Template' => notifications_new_message_template, + 'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled, + 'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template, + 'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled, + 'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template, + 'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled, + 'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template, + 'PreWebhookUrl' => pre_webhook_url, + 'PostWebhookUrl' => post_webhook_url, + 'WebhookMethod' => webhook_method, + 'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e }, + 'Webhooks.OnMessageSend.Url' => webhooks_on_message_send_url, + 'Webhooks.OnMessageSend.Method' => webhooks_on_message_send_method, + 'Webhooks.OnMessageUpdate.Url' => webhooks_on_message_update_url, + 'Webhooks.OnMessageUpdate.Method' => webhooks_on_message_update_method, + 'Webhooks.OnMessageRemove.Url' => webhooks_on_message_remove_url, + 'Webhooks.OnMessageRemove.Method' => webhooks_on_message_remove_method, + 'Webhooks.OnChannelAdd.Url' => webhooks_on_channel_add_url, + 'Webhooks.OnChannelAdd.Method' => webhooks_on_channel_add_method, + 'Webhooks.OnChannelDestroy.Url' => webhooks_on_channel_destroy_url, + 'Webhooks.OnChannelDestroy.Method' => webhooks_on_channel_destroy_method, + 'Webhooks.OnChannelUpdate.Url' => webhooks_on_channel_update_url, + 'Webhooks.OnChannelUpdate.Method' => webhooks_on_channel_update_method, + 'Webhooks.OnMemberAdd.Url' => webhooks_on_member_add_url, + 'Webhooks.OnMemberAdd.Method' => webhooks_on_member_add_method, + 'Webhooks.OnMemberRemove.Url' => webhooks_on_member_remove_url, + 'Webhooks.OnMemberRemove.Method' => webhooks_on_member_remove_method, + 'Webhooks.OnMessageSent.Url' => webhooks_on_message_sent_url, + 'Webhooks.OnMessageSent.Method' => webhooks_on_message_sent_method, + 'Webhooks.OnMessageUpdated.Url' => webhooks_on_message_updated_url, + 'Webhooks.OnMessageUpdated.Method' => webhooks_on_message_updated_method, + 'Webhooks.OnMessageRemoved.Url' => webhooks_on_message_removed_url, + 'Webhooks.OnMessageRemoved.Method' => webhooks_on_message_removed_method, + 'Webhooks.OnChannelAdded.Url' => webhooks_on_channel_added_url, + 'Webhooks.OnChannelAdded.Method' => webhooks_on_channel_added_method, + 'Webhooks.OnChannelDestroyed.Url' => webhooks_on_channel_destroyed_url, + 'Webhooks.OnChannelDestroyed.Method' => webhooks_on_channel_destroyed_method, + 'Webhooks.OnChannelUpdated.Url' => webhooks_on_channel_updated_url, + 'Webhooks.OnChannelUpdated.Method' => webhooks_on_channel_updated_method, + 'Webhooks.OnMemberAdded.Url' => webhooks_on_member_added_url, + 'Webhooks.OnMemberAdded.Method' => webhooks_on_member_added_method, + 'Webhooks.OnMemberRemoved.Url' => webhooks_on_member_removed_url, + 'Webhooks.OnMemberRemoved.Method' => webhooks_on_member_removed_method, + 'Limits.ChannelMembers' => limits_channel_members, + 'Limits.UserChannels' => limits_user_channels, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the channels # @return [ChannelList] @@ -459,6 +747,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -487,6 +814,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb index 009ce0e44..4b42e006c 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb @@ -67,6 +67,47 @@ def create( ) end + ## + # Create the ChannelInstanceMetadata + # @param [String] friendly_name + # @param [String] unique_name + # @param [String] attributes + # @param [ChannelType] type + # @return [ChannelInstance] Created ChannelInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset, + type: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + 'Type' => type, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChannelInstance records from the API as a list. @@ -110,6 +151,31 @@ def stream(type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChannelPageMetadata records from the API as a list. + # @param [Array[ChannelType]] type + # @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_with_metadata(type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Type' => Twilio.serialize_list(type) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -199,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ChannelInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new(@version, channel_instance, response.headers, response.status_code) end ## @@ -222,6 +307,32 @@ def fetch ) end + ## + # Fetch the ChannelInstanceMetadata + # @return [ChannelInstance] Fetched ChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Update the ChannelInstance # @param [String] friendly_name @@ -255,6 +366,45 @@ def update( ) end + ## + # Update the ChannelInstanceMetadata + # @param [String] friendly_name + # @param [String] unique_name + # @param [String] attributes + # @return [ChannelInstance] Updated ChannelInstance + def update_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Access the members # @return [MemberList] @@ -328,6 +478,45 @@ def inspect end end + class ChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelInstance] channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, channel_instance, headers, status_code) + super(version, headers, status_code) + @channel_instance = channel_instance + end + + def channel + @channel_instance + end + + def to_s + "" + end + end + + class ChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_instance = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_instance + @instance + end + end + class ChannelPage < Page ## # Initialize the ChannelPage @@ -356,6 +545,54 @@ def to_s '' end end + + class ChannelPageMetadata < PageMetadata + attr_reader :channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channel_page << ChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel + @channel + end + end + class ChannelInstance < InstanceResource ## # Initialize the ChannelInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/invite.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/invite.rb index 311964bb5..742a22d62 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/invite.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/invite.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the InviteInstanceMetadata + # @param [String] identity + # @param [String] role_sid + # @return [InviteInstance] Created InviteInstance + def create_with_metadata( + identity: nil, + role_sid: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Lists InviteInstance records from the API as a list. @@ -106,6 +142,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InvitePageMetadata records from the API as a list. + # @param [Array[String]] identity + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InvitePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InviteInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +254,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InviteInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new(@version, invite_instance, response.headers, response.status_code) end ## @@ -217,6 +297,33 @@ def fetch ) end + ## + # Fetch the InviteInstanceMetadata + # @return [InviteInstance] Fetched InviteInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -233,6 +340,45 @@ def inspect end end + class InviteInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InviteInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InviteInstance] invite_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InviteInstanceMetadata] The initialized instance with metadata. + def initialize(version, invite_instance, headers, status_code) + super(version, headers, status_code) + @invite_instance = invite_instance + end + + def invite + @invite_instance + end + + def to_s + "" + end + end + + class InviteListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite_instance = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite_instance + @instance + end + end + class InvitePage < Page ## # Initialize the InvitePage @@ -261,6 +407,54 @@ def to_s '' end end + + class InvitePageMetadata < PageMetadata + attr_reader :invite_page + + def initialize(version, response, solution, limit) + super(version, response) + @invite_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @invite_page << InviteListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @invite_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InviteListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite + @invite + end + end + class InviteInstance < InstanceResource ## # Initialize the InviteInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb index 7625fa6ba..0402fbd59 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the MemberInstanceMetadata + # @param [String] identity + # @param [String] role_sid + # @return [MemberInstance] Created MemberInstance + def create_with_metadata( + identity: nil, + role_sid: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Lists MemberInstance records from the API as a list. @@ -106,6 +142,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MemberPageMetadata records from the API as a list. + # @param [Array[String]] identity + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MemberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MemberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +254,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MemberInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new(@version, member_instance, response.headers, response.status_code) end ## @@ -217,6 +297,33 @@ def fetch ) end + ## + # Fetch the MemberInstanceMetadata + # @return [MemberInstance] Fetched MemberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Update the MemberInstance # @param [String] role_sid @@ -248,6 +355,43 @@ def update( ) end + ## + # Update the MemberInstanceMetadata + # @param [String] role_sid + # @param [String] last_consumed_message_index + # @return [MemberInstance] Updated MemberInstance + def update_with_metadata( + role_sid: :unset, + last_consumed_message_index: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'LastConsumedMessageIndex' => last_consumed_message_index, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -264,6 +408,45 @@ def inspect end end + class MemberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MemberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MemberInstance] member_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MemberInstanceMetadata] The initialized instance with metadata. + def initialize(version, member_instance, headers, status_code) + super(version, headers, status_code) + @member_instance = member_instance + end + + def member + @member_instance + end + + def to_s + "" + end + end + + class MemberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member_instance = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member_instance + @instance + end + end + class MemberPage < Page ## # Initialize the MemberPage @@ -292,6 +475,54 @@ def to_s '' end end + + class MemberPageMetadata < PageMetadata + attr_reader :member_page + + def initialize(version, response, solution, limit) + super(version, response) + @member_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @member_page << MemberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @member_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MemberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member + @member + end + end + class MemberInstance < InstanceResource ## # Initialize the MemberInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb index abc701c61..3d1e9d57a 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb @@ -66,6 +66,45 @@ def create( ) end + ## + # Create the MessageInstanceMetadata + # @param [String] body + # @param [String] from + # @param [String] attributes + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + body: nil, + from: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'From' => from, + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInstance records from the API as a list. @@ -109,6 +148,30 @@ def stream(order: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @param [OrderType] order + # @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_with_metadata(order: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -195,7 +258,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MessageInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code) end ## @@ -219,6 +301,33 @@ def fetch ) end + ## + # Fetch the MessageInstanceMetadata + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessageInstance # @param [String] body @@ -250,6 +359,43 @@ def update( ) end + ## + # Update the MessageInstanceMetadata + # @param [String] body + # @param [String] attributes + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + body: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -266,6 +412,45 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInstance] message_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def message + @message_instance + end + + def to_s + "" + end + end + + class MessageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_instance = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_instance + @instance + end + end + class MessagePage < Page ## # Initialize the MessagePage @@ -294,6 +479,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb index cc65bff52..df0acd392 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the RoleInstanceMetadata + # @param [String] friendly_name + # @param [RoleType] type + # @param [Array[String]] permission + # @return [RoleInstance] Created RoleInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + permission: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoleInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RolePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RolePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoleInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +246,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoleInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new(@version, role_instance, response.headers, response.status_code) end ## @@ -209,6 +288,32 @@ def fetch ) end + ## + # Fetch the RoleInstanceMetadata + # @return [RoleInstance] Fetched RoleInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Update the RoleInstance # @param [Array[String]] permission @@ -236,6 +341,39 @@ def update( ) end + ## + # Update the RoleInstanceMetadata + # @param [Array[String]] permission + # @return [RoleInstance] Updated RoleInstance + def update_with_metadata( + permission: nil + ) + + data = Twilio::Values.of({ + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -252,6 +390,45 @@ def inspect end end + class RoleInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoleInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoleInstance] role_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoleInstanceMetadata] The initialized instance with metadata. + def initialize(version, role_instance, headers, status_code) + super(version, headers, status_code) + @role_instance = role_instance + end + + def role + @role_instance + end + + def to_s + "" + end + end + + class RoleListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_instance = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_instance + @instance + end + end + class RolePage < Page ## # Initialize the RolePage @@ -280,6 +457,54 @@ def to_s '' end end + + class RolePageMetadata < PageMetadata + attr_reader :role_page + + def initialize(version, response, solution, limit) + super(version, response) + @role_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @role_page << RoleListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @role_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoleListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role + @role + end + end + class RoleInstance < InstanceResource ## # Initialize the RoleInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb index 9c34e7247..96b3be17e 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb @@ -67,6 +67,47 @@ def create( ) end + ## + # Create the UserInstanceMetadata + # @param [String] identity + # @param [String] role_sid + # @param [String] attributes + # @param [String] friendly_name + # @return [UserInstance] Created UserInstance + def create_with_metadata( + identity: nil, + role_sid: :unset, + attributes: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Lists UserInstance records from the API as a list. @@ -106,6 +147,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -190,7 +253,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code) end ## @@ -213,6 +295,32 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] role_sid @@ -246,6 +354,45 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] role_sid + # @param [String] attributes + # @param [String] friendly_name + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + role_sid: :unset, + attributes: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Access the user_channels # @return [UserChannelList] @@ -273,6 +420,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -301,6 +487,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb b/lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb index 11bb2003e..562929caa 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -157,6 +179,54 @@ def to_s '' end end + + class UserChannelPageMetadata < PageMetadata + attr_reader :user_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_channel_page << UserChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_channel = payload.body[key].map do |data| + UserChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_channel + @user_channel + end + end + class UserChannelInstance < InstanceResource ## # Initialize the UserChannelInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/credential.rb b/lib/twilio-ruby/rest/ip_messaging/v2/credential.rb index da37ac58d..672ec7336 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/credential.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/credential.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CredentialInstanceMetadata + # @param [PushService] type + # @param [String] friendly_name + # @param [String] certificate + # @param [String] private_key + # @param [Boolean] sandbox + # @param [String] api_key + # @param [String] secret + # @return [CredentialInstance] Created CredentialInstance + def create_with_metadata( + type: nil, + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialInstance records from the API as a list. @@ -112,6 +161,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code) end ## @@ -216,6 +306,31 @@ def fetch ) end + ## + # Fetch the CredentialInstanceMetadata + # @return [CredentialInstance] Fetched CredentialInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialInstance # @param [String] friendly_name @@ -257,6 +372,53 @@ def update( ) end + ## + # Update the CredentialInstanceMetadata + # @param [String] friendly_name + # @param [String] certificate + # @param [String] private_key + # @param [Boolean] sandbox + # @param [String] api_key + # @param [String] secret + # @return [CredentialInstance] Updated CredentialInstance + def update_with_metadata( + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -273,6 +435,45 @@ def inspect end end + class CredentialInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialInstance] credential_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_instance, headers, status_code) + super(version, headers, status_code) + @credential_instance = credential_instance + end + + def credential + @credential_instance + end + + def to_s + "" + end + end + + class CredentialListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_instance = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_instance + @instance + end + end + class CredentialPage < Page ## # Initialize the CredentialPage @@ -301,6 +502,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service.rb index 19ea98205..93da13f3e 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -94,6 +125,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +233,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -202,6 +274,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] friendly_name @@ -318,6 +415,128 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] friendly_name + # @param [String] default_service_role_sid + # @param [String] default_channel_role_sid + # @param [String] default_channel_creator_role_sid + # @param [Boolean] read_status_enabled + # @param [Boolean] reachability_enabled + # @param [String] typing_indicator_timeout + # @param [String] consumption_report_interval + # @param [Boolean] notifications_new_message_enabled + # @param [String] notifications_new_message_template + # @param [String] notifications_new_message_sound + # @param [Boolean] notifications_new_message_badge_count_enabled + # @param [Boolean] notifications_added_to_channel_enabled + # @param [String] notifications_added_to_channel_template + # @param [String] notifications_added_to_channel_sound + # @param [Boolean] notifications_removed_from_channel_enabled + # @param [String] notifications_removed_from_channel_template + # @param [String] notifications_removed_from_channel_sound + # @param [Boolean] notifications_invited_to_channel_enabled + # @param [String] notifications_invited_to_channel_template + # @param [String] notifications_invited_to_channel_sound + # @param [String] pre_webhook_url + # @param [String] post_webhook_url + # @param [String] webhook_method + # @param [Array[String]] webhook_filters + # @param [String] limits_channel_members + # @param [String] limits_user_channels + # @param [String] media_compatibility_message + # @param [String] pre_webhook_retry_count + # @param [String] post_webhook_retry_count + # @param [Boolean] notifications_log_enabled + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + friendly_name: :unset, + default_service_role_sid: :unset, + default_channel_role_sid: :unset, + default_channel_creator_role_sid: :unset, + read_status_enabled: :unset, + reachability_enabled: :unset, + typing_indicator_timeout: :unset, + consumption_report_interval: :unset, + notifications_new_message_enabled: :unset, + notifications_new_message_template: :unset, + notifications_new_message_sound: :unset, + notifications_new_message_badge_count_enabled: :unset, + notifications_added_to_channel_enabled: :unset, + notifications_added_to_channel_template: :unset, + notifications_added_to_channel_sound: :unset, + notifications_removed_from_channel_enabled: :unset, + notifications_removed_from_channel_template: :unset, + notifications_removed_from_channel_sound: :unset, + notifications_invited_to_channel_enabled: :unset, + notifications_invited_to_channel_template: :unset, + notifications_invited_to_channel_sound: :unset, + pre_webhook_url: :unset, + post_webhook_url: :unset, + webhook_method: :unset, + webhook_filters: :unset, + limits_channel_members: :unset, + limits_user_channels: :unset, + media_compatibility_message: :unset, + pre_webhook_retry_count: :unset, + post_webhook_retry_count: :unset, + notifications_log_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DefaultServiceRoleSid' => default_service_role_sid, + 'DefaultChannelRoleSid' => default_channel_role_sid, + 'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid, + 'ReadStatusEnabled' => read_status_enabled, + 'ReachabilityEnabled' => reachability_enabled, + 'TypingIndicatorTimeout' => typing_indicator_timeout, + 'ConsumptionReportInterval' => consumption_report_interval, + 'Notifications.NewMessage.Enabled' => notifications_new_message_enabled, + 'Notifications.NewMessage.Template' => notifications_new_message_template, + 'Notifications.NewMessage.Sound' => notifications_new_message_sound, + 'Notifications.NewMessage.BadgeCountEnabled' => notifications_new_message_badge_count_enabled, + 'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled, + 'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template, + 'Notifications.AddedToChannel.Sound' => notifications_added_to_channel_sound, + 'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled, + 'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template, + 'Notifications.RemovedFromChannel.Sound' => notifications_removed_from_channel_sound, + 'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled, + 'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template, + 'Notifications.InvitedToChannel.Sound' => notifications_invited_to_channel_sound, + 'PreWebhookUrl' => pre_webhook_url, + 'PostWebhookUrl' => post_webhook_url, + 'WebhookMethod' => webhook_method, + 'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e }, + 'Limits.ChannelMembers' => limits_channel_members, + 'Limits.UserChannels' => limits_user_channels, + 'Media.CompatibilityMessage' => media_compatibility_message, + 'PreWebhookRetryCount' => pre_webhook_retry_count, + 'PostWebhookRetryCount' => post_webhook_retry_count, + 'Notifications.LogEnabled' => notifications_log_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the bindings # @return [BindingList] @@ -410,6 +629,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -438,6 +696,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/binding.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/binding.rb index 87dab868f..12ebfd96c 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/binding.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/binding.rb @@ -79,6 +79,34 @@ def stream(binding_type: :unset, identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BindingPageMetadata records from the API as a list. + # @param [Array[BindingType]] binding_type + # @param [Array[String]] identity + # @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_with_metadata(binding_type: :unset, identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'BindingType' => Twilio.serialize_list(binding_type) { |e| e }, + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BindingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BindingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,7 +196,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BindingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new(@version, binding_instance, response.headers, response.status_code) end ## @@ -191,6 +238,32 @@ def fetch ) end + ## + # Fetch the BindingInstanceMetadata + # @return [BindingInstance] Fetched BindingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new( + @version, + binding_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -207,6 +280,45 @@ def inspect end end + class BindingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BindingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BindingInstance] binding_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BindingInstanceMetadata] The initialized instance with metadata. + def initialize(version, binding_instance, headers, status_code) + super(version, headers, status_code) + @binding_instance = binding_instance + end + + def binding + @binding_instance + end + + def to_s + "" + end + end + + class BindingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding_instance = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding_instance + @instance + end + end + class BindingPage < Page ## # Initialize the BindingPage @@ -235,6 +347,54 @@ def to_s '' end end + + class BindingPageMetadata < PageMetadata + attr_reader :binding_page + + def initialize(version, response, solution, limit) + super(version, response) + @binding_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @binding_page << BindingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @binding_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BindingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding + @binding + end + end + class BindingInstance < InstanceResource ## # Initialize the BindingInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb index be409654e..c547bc48e 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb @@ -78,6 +78,58 @@ def create( ) end + ## + # Create the ChannelInstanceMetadata + # @param [String] friendly_name + # @param [String] unique_name + # @param [String] attributes + # @param [ChannelType] type + # @param [Time] date_created + # @param [Time] date_updated + # @param [String] created_by + # @param [ChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ChannelInstance] Created ChannelInstance + def create_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset, + type: :unset, + date_created: :unset, + date_updated: :unset, + created_by: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + 'Type' => type, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'CreatedBy' => created_by, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChannelInstance records from the API as a list. @@ -121,6 +173,31 @@ def stream(type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChannelPageMetadata records from the API as a list. + # @param [Array[ChannelType]] type + # @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_with_metadata(type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Type' => Twilio.serialize_list(type) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -214,7 +291,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ChannelInstanceMetadata + # @param [ChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new(@version, channel_instance, response.headers, response.status_code) end ## @@ -237,6 +336,32 @@ def fetch ) end + ## + # Fetch the ChannelInstanceMetadata + # @return [ChannelInstance] Fetched ChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Update the ChannelInstance # @param [String] friendly_name @@ -281,6 +406,56 @@ def update( ) end + ## + # Update the ChannelInstanceMetadata + # @param [String] friendly_name + # @param [String] unique_name + # @param [String] attributes + # @param [Time] date_created + # @param [Time] date_updated + # @param [String] created_by + # @param [ChannelEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [ChannelInstance] Updated ChannelInstance + def update_with_metadata( + friendly_name: :unset, + unique_name: :unset, + attributes: :unset, + date_created: :unset, + date_updated: :unset, + created_by: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Attributes' => attributes, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'CreatedBy' => created_by, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + channel_instance = ChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ChannelInstanceMetadata.new( + @version, + channel_instance, + response.headers, + response.status_code + ) + end + ## # Access the webhooks # @return [WebhookList] @@ -373,6 +548,45 @@ def inspect end end + class ChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelInstance] channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, channel_instance, headers, status_code) + super(version, headers, status_code) + @channel_instance = channel_instance + end + + def channel + @channel_instance + end + + def to_s + "" + end + end + + class ChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_instance = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_instance + @instance + end + end + class ChannelPage < Page ## # Initialize the ChannelPage @@ -401,6 +615,54 @@ def to_s '' end end + + class ChannelPageMetadata < PageMetadata + attr_reader :channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channel_page << ChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel = payload.body[key].map do |data| + ChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel + @channel + end + end + class ChannelInstance < InstanceResource ## # Initialize the ChannelInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb index f29af4b01..7b82cff01 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the InviteInstanceMetadata + # @param [String] identity + # @param [String] role_sid + # @return [InviteInstance] Created InviteInstance + def create_with_metadata( + identity: nil, + role_sid: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Lists InviteInstance records from the API as a list. @@ -106,6 +142,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InvitePageMetadata records from the API as a list. + # @param [Array[String]] identity + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InvitePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InviteInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +254,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InviteInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new(@version, invite_instance, response.headers, response.status_code) end ## @@ -217,6 +297,33 @@ def fetch ) end + ## + # Fetch the InviteInstanceMetadata + # @return [InviteInstance] Fetched InviteInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + invite_instance = InviteInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + InviteInstanceMetadata.new( + @version, + invite_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -233,6 +340,45 @@ def inspect end end + class InviteInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InviteInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InviteInstance] invite_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InviteInstanceMetadata] The initialized instance with metadata. + def initialize(version, invite_instance, headers, status_code) + super(version, headers, status_code) + @invite_instance = invite_instance + end + + def invite + @invite_instance + end + + def to_s + "" + end + end + + class InviteListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite_instance = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite_instance + @instance + end + end + class InvitePage < Page ## # Initialize the InvitePage @@ -261,6 +407,54 @@ def to_s '' end end + + class InvitePageMetadata < PageMetadata + attr_reader :invite_page + + def initialize(version, response, solution, limit) + super(version, response) + @invite_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @invite_page << InviteListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @invite_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InviteListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @invite = payload.body[key].map do |data| + InviteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def invite + @invite + end + end + class InviteInstance < InstanceResource ## # Initialize the InviteInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb index 72cd22cc6..36a22c4b3 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb @@ -80,6 +80,59 @@ def create( ) end + ## + # Create the MemberInstanceMetadata + # @param [String] identity + # @param [String] role_sid + # @param [String] last_consumed_message_index + # @param [Time] last_consumption_timestamp + # @param [Time] date_created + # @param [Time] date_updated + # @param [String] attributes + # @param [MemberEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MemberInstance] Created MemberInstance + def create_with_metadata( + identity: nil, + role_sid: :unset, + last_consumed_message_index: :unset, + last_consumption_timestamp: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + 'LastConsumedMessageIndex' => last_consumed_message_index, + 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Lists MemberInstance records from the API as a list. @@ -123,6 +176,31 @@ def stream(identity: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MemberPageMetadata records from the API as a list. + # @param [Array[String]] identity + # @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_with_metadata(identity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MemberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MemberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -213,7 +291,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MemberInstanceMetadata + # @param [MemberEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new(@version, member_instance, response.headers, response.status_code) end ## @@ -237,6 +337,33 @@ def fetch ) end + ## + # Fetch the MemberInstanceMetadata + # @return [MemberInstance] Fetched MemberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Update the MemberInstance # @param [String] role_sid @@ -282,6 +409,57 @@ def update( ) end + ## + # Update the MemberInstanceMetadata + # @param [String] role_sid + # @param [String] last_consumed_message_index + # @param [Time] last_consumption_timestamp + # @param [Time] date_created + # @param [Time] date_updated + # @param [String] attributes + # @param [MemberEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MemberInstance] Updated MemberInstance + def update_with_metadata( + role_sid: :unset, + last_consumed_message_index: :unset, + last_consumption_timestamp: :unset, + date_created: :unset, + date_updated: :unset, + attributes: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'LastConsumedMessageIndex' => last_consumed_message_index, + 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + member_instance = MemberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MemberInstanceMetadata.new( + @version, + member_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -298,6 +476,45 @@ def inspect end end + class MemberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MemberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MemberInstance] member_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MemberInstanceMetadata] The initialized instance with metadata. + def initialize(version, member_instance, headers, status_code) + super(version, headers, status_code) + @member_instance = member_instance + end + + def member + @member_instance + end + + def to_s + "" + end + end + + class MemberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member_instance = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member_instance + @instance + end + end + class MemberPage < Page ## # Initialize the MemberPage @@ -326,6 +543,54 @@ def to_s '' end end + + class MemberPageMetadata < PageMetadata + attr_reader :member_page + + def initialize(version, response, solution, limit) + super(version, response) + @member_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @member_page << MemberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @member_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MemberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @member = payload.body[key].map do |data| + MemberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def member + @member + end + end + class MemberInstance < InstanceResource ## # Initialize the MemberInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb index 5448a83fc..74d73d6da 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb @@ -80,6 +80,59 @@ def create( ) end + ## + # Create the MessageInstanceMetadata + # @param [String] from + # @param [String] attributes + # @param [Time] date_created + # @param [Time] date_updated + # @param [String] last_updated_by + # @param [String] body + # @param [String] media_sid + # @param [MessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Created MessageInstance + def create_with_metadata( + from: :unset, + attributes: :unset, + date_created: :unset, + date_updated: :unset, + last_updated_by: :unset, + body: :unset, + media_sid: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'From' => from, + 'Attributes' => attributes, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'LastUpdatedBy' => last_updated_by, + 'Body' => body, + 'MediaSid' => media_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInstance records from the API as a list. @@ -123,6 +176,30 @@ def stream(order: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagePageMetadata records from the API as a list. + # @param [OrderType] order + # @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_with_metadata(order: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -212,7 +289,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MessageInstanceMetadata + # @param [MessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + x_twilio_webhook_enabled: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code) end ## @@ -236,6 +335,33 @@ def fetch ) end + ## + # Fetch the MessageInstanceMetadata + # @return [MessageInstance] Fetched MessageInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessageInstance # @param [String] body @@ -281,6 +407,57 @@ def update( ) end + ## + # Update the MessageInstanceMetadata + # @param [String] body + # @param [String] attributes + # @param [Time] date_created + # @param [Time] date_updated + # @param [String] last_updated_by + # @param [String] from + # @param [MessageEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [MessageInstance] Updated MessageInstance + def update_with_metadata( + body: :unset, + attributes: :unset, + date_created: :unset, + date_updated: :unset, + last_updated_by: :unset, + from: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'Attributes' => attributes, + 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), + 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), + 'LastUpdatedBy' => last_updated_by, + 'From' => from, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + message_instance = MessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + MessageInstanceMetadata.new( + @version, + message_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -297,6 +474,45 @@ def inspect end end + class MessageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInstance] message_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_instance, headers, status_code) + super(version, headers, status_code) + @message_instance = message_instance + end + + def message + @message_instance + end + + def to_s + "" + end + end + + class MessageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_instance = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_instance + @instance + end + end + class MessagePage < Page ## # Initialize the MessagePage @@ -325,6 +541,54 @@ def to_s '' end end + + class MessagePageMetadata < PageMetadata + attr_reader :message_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_page << MessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message = payload.body[key].map do |data| + MessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message + @message + end + end + class MessageInstance < InstanceResource ## # Initialize the MessageInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb index ad938eaba..4208b4f22 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb @@ -78,6 +78,57 @@ def create( ) end + ## + # Create the WebhookInstanceMetadata + # @param [Type] type + # @param [String] configuration_url + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters + # @param [Array[String]] configuration_triggers + # @param [String] configuration_flow_sid + # @param [String] configuration_retry_count + # @return [WebhookInstance] Created WebhookInstance + def create_with_metadata( + type: nil, + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset, + configuration_retry_count: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + 'Configuration.RetryCount' => configuration_retry_count, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Lists WebhookInstance records from the API as a list. @@ -117,6 +168,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WebhookPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WebhookPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WebhookInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -201,7 +274,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WebhookInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new(@version, webhook_instance, response.headers, response.status_code) end ## @@ -225,6 +317,33 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebhookInstance # @param [String] configuration_url @@ -268,6 +387,55 @@ def update( ) end + ## + # Update the WebhookInstanceMetadata + # @param [String] configuration_url + # @param [Method] configuration_method + # @param [Array[String]] configuration_filters + # @param [Array[String]] configuration_triggers + # @param [String] configuration_flow_sid + # @param [String] configuration_retry_count + # @return [WebhookInstance] Updated WebhookInstance + def update_with_metadata( + configuration_url: :unset, + configuration_method: :unset, + configuration_filters: :unset, + configuration_triggers: :unset, + configuration_flow_sid: :unset, + configuration_retry_count: :unset + ) + + data = Twilio::Values.of({ + 'Configuration.Url' => configuration_url, + 'Configuration.Method' => configuration_method, + 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, + 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, + 'Configuration.FlowSid' => configuration_flow_sid, + 'Configuration.RetryCount' => configuration_retry_count, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + channel_sid: @solution[:channel_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -284,6 +452,45 @@ def inspect end end + class WebhookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebhookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebhookInstance] webhook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebhookInstanceMetadata] The initialized instance with metadata. + def initialize(version, webhook_instance, headers, status_code) + super(version, headers, status_code) + @webhook_instance = webhook_instance + end + + def webhook + @webhook_instance + end + + def to_s + "" + end + end + + class WebhookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook_instance = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook_instance + @instance + end + end + class WebhookPage < Page ## # Initialize the WebhookPage @@ -312,6 +519,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb index d27348f92..e97b2bf63 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the RoleInstanceMetadata + # @param [String] friendly_name + # @param [RoleType] type + # @param [Array[String]] permission + # @return [RoleInstance] Created RoleInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + permission: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoleInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RolePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RolePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoleInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +246,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoleInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new(@version, role_instance, response.headers, response.status_code) end ## @@ -209,6 +288,32 @@ def fetch ) end + ## + # Fetch the RoleInstanceMetadata + # @return [RoleInstance] Fetched RoleInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Update the RoleInstance # @param [Array[String]] permission @@ -236,6 +341,39 @@ def update( ) end + ## + # Update the RoleInstanceMetadata + # @param [Array[String]] permission + # @return [RoleInstance] Updated RoleInstance + def update_with_metadata( + permission: nil + ) + + data = Twilio::Values.of({ + 'Permission' => Twilio.serialize_list(permission) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + role_instance = RoleInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RoleInstanceMetadata.new( + @version, + role_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -252,6 +390,45 @@ def inspect end end + class RoleInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoleInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoleInstance] role_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoleInstanceMetadata] The initialized instance with metadata. + def initialize(version, role_instance, headers, status_code) + super(version, headers, status_code) + @role_instance = role_instance + end + + def role + @role_instance + end + + def to_s + "" + end + end + + class RoleListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_instance = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_instance + @instance + end + end + class RolePage < Page ## # Initialize the RolePage @@ -280,6 +457,54 @@ def to_s '' end end + + class RolePageMetadata < PageMetadata + attr_reader :role_page + + def initialize(version, response, solution, limit) + super(version, response) + @role_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @role_page << RoleListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @role_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoleListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role = payload.body[key].map do |data| + RoleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role + @role + end + end + class RoleInstance < InstanceResource ## # Initialize the RoleInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb index 24060a0ef..f1cb814bd 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb @@ -69,6 +69,49 @@ def create( ) end + ## + # Create the UserInstanceMetadata + # @param [String] identity + # @param [String] role_sid + # @param [String] attributes + # @param [String] friendly_name + # @param [UserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Created UserInstance + def create_with_metadata( + identity: nil, + role_sid: :unset, + attributes: :unset, + friendly_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Lists UserInstance records from the API as a list. @@ -108,6 +151,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +258,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code) end ## @@ -216,6 +300,32 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] role_sid @@ -251,6 +361,47 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] role_sid + # @param [String] attributes + # @param [String] friendly_name + # @param [UserEnumWebhookEnabledType] x_twilio_webhook_enabled The X-Twilio-Webhook-Enabled HTTP request header + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + role_sid: :unset, + attributes: :unset, + friendly_name: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'RoleSid' => role_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Access the user_channels # @return [UserChannelList] @@ -305,6 +456,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -333,6 +523,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb index be357ce2c..5414e7030 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb @@ -76,6 +76,31 @@ def stream(binding_type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserBindingPageMetadata records from the API as a list. + # @param [Array[BindingType]] binding_type + # @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_with_metadata(binding_type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'BindingType' => Twilio.serialize_list(binding_type) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserBindingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserBindingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,7 +188,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserBindingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + userBinding_instance = UserBindingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserBindingInstanceMetadata.new(@version, userBinding_instance, response.headers, response.status_code) end ## @@ -187,6 +231,33 @@ def fetch ) end + ## + # Fetch the UserBindingInstanceMetadata + # @return [UserBindingInstance] Fetched UserBindingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + userBinding_instance = UserBindingInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + user_sid: @solution[:user_sid], + sid: @solution[:sid], + ) + UserBindingInstanceMetadata.new( + @version, + userBinding_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -203,6 +274,45 @@ def inspect end end + class UserBindingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserBindingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserBindingInstance] user_binding_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserBindingInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_binding_instance, headers, status_code) + super(version, headers, status_code) + @user_binding_instance = user_binding_instance + end + + def user_binding + @user_binding_instance + end + + def to_s + "" + end + end + + class UserBindingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_binding_instance = payload.body[key].map do |data| + UserBindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_binding_instance + @instance + end + end + class UserBindingPage < Page ## # Initialize the UserBindingPage @@ -231,6 +341,54 @@ def to_s '' end end + + class UserBindingPageMetadata < PageMetadata + attr_reader :user_binding_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_binding_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_binding_page << UserBindingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_binding_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserBindingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_binding = payload.body[key].map do |data| + UserBindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_binding + @user_binding + end + end + class UserBindingInstance < InstanceResource ## # Initialize the UserBindingInstance diff --git a/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb b/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb index c9ddfbdef..35d013167 100644 --- a/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb +++ b/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserChannelInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + userChannel_instance = UserChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserChannelInstanceMetadata.new(@version, userChannel_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the UserChannelInstanceMetadata + # @return [UserChannelInstance] Fetched UserChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + userChannel_instance = UserChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + user_sid: @solution[:user_sid], + channel_sid: @solution[:channel_sid], + ) + UserChannelInstanceMetadata.new( + @version, + userChannel_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserChannelInstance # @param [NotificationLevel] notification_level @@ -214,6 +282,46 @@ def update( ) end + ## + # Update the UserChannelInstanceMetadata + # @param [NotificationLevel] notification_level + # @param [String] last_consumed_message_index + # @param [Time] last_consumption_timestamp + # @return [UserChannelInstance] Updated UserChannelInstance + def update_with_metadata( + notification_level: :unset, + last_consumed_message_index: :unset, + last_consumption_timestamp: :unset + ) + + data = Twilio::Values.of({ + 'NotificationLevel' => notification_level, + 'LastConsumedMessageIndex' => last_consumed_message_index, + 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + userChannel_instance = UserChannelInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + user_sid: @solution[:user_sid], + channel_sid: @solution[:channel_sid], + ) + UserChannelInstanceMetadata.new( + @version, + userChannel_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -230,6 +338,45 @@ def inspect end end + class UserChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserChannelInstance] user_channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_channel_instance, headers, status_code) + super(version, headers, status_code) + @user_channel_instance = user_channel_instance + end + + def user_channel + @user_channel_instance + end + + def to_s + "" + end + end + + class UserChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_channel_instance = payload.body[key].map do |data| + UserChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_channel_instance + @instance + end + end + class UserChannelPage < Page ## # Initialize the UserChannelPage @@ -258,6 +405,54 @@ def to_s '' end end + + class UserChannelPageMetadata < PageMetadata + attr_reader :user_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_channel_page << UserChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_channel = payload.body[key].map do |data| + UserChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_channel + @user_channel + end + end + class UserChannelInstance < InstanceResource ## # Initialize the UserChannelInstance diff --git a/lib/twilio-ruby/rest/knowledge/v1/knowledge.rb b/lib/twilio-ruby/rest/knowledge/v1/knowledge.rb index 04b10f914..1403b0502 100644 --- a/lib/twilio-ruby/rest/knowledge/v1/knowledge.rb +++ b/lib/twilio-ruby/rest/knowledge/v1/knowledge.rb @@ -214,6 +214,32 @@ def create(knowledge_v1_service_create_knowledge_request: nil ) end + ## + # Create the KnowledgeInstanceMetadata + # @param [KnowledgeV1ServiceCreateKnowledgeRequest] knowledge_v1_service_create_knowledge_request + # @return [KnowledgeInstance] Created KnowledgeInstance + def create_with_metadata(knowledge_v1_service_create_knowledge_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: knowledge_v1_service_create_knowledge_request.to_json) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + ) + KnowledgeInstanceMetadata.new( + @version, + knowledge_instance, + response.headers, + response.status_code + ) + end + ## # Lists KnowledgeInstance records from the API as a list. @@ -257,6 +283,30 @@ def stream(tags: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists KnowledgePageMetadata records from the API as a list. + # @param [String] tags Json array of tag and value pairs for tag filtering. + # @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_with_metadata(tags: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Tags' => tags, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + KnowledgePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields KnowledgeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -343,7 +393,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the KnowledgeInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + KnowledgeInstanceMetadata.new(@version, knowledge_instance, response.headers, response.status_code) end ## @@ -365,6 +434,31 @@ def fetch ) end + ## + # Fetch the KnowledgeInstanceMetadata + # @return [KnowledgeInstance] Fetched KnowledgeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + id: @solution[:id], + ) + KnowledgeInstanceMetadata.new( + @version, + knowledge_instance, + response.headers, + response.status_code + ) + end + ## # Update the KnowledgeInstance # @param [KnowledgeV1ServiceUpdateKnowledgeRequest] knowledge_v1_service_update_knowledge_request @@ -386,6 +480,33 @@ def update(knowledge_v1_service_update_knowledge_request: :unset ) end + ## + # Update the KnowledgeInstanceMetadata + # @param [KnowledgeV1ServiceUpdateKnowledgeRequest] knowledge_v1_service_update_knowledge_request + # @return [KnowledgeInstance] Updated KnowledgeInstance + def update_with_metadata(knowledge_v1_service_update_knowledge_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: knowledge_v1_service_update_knowledge_request.to_json) + knowledge_instance = KnowledgeInstance.new( + @version, + response.body, + id: @solution[:id], + ) + KnowledgeInstanceMetadata.new( + @version, + knowledge_instance, + response.headers, + response.status_code + ) + end + ## # Access the chunks # @return [ChunkList] @@ -423,6 +544,45 @@ def inspect end end + class KnowledgeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new KnowledgeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}KnowledgeInstance] knowledge_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [KnowledgeInstanceMetadata] The initialized instance with metadata. + def initialize(version, knowledge_instance, headers, status_code) + super(version, headers, status_code) + @knowledge_instance = knowledge_instance + end + + def knowledge + @knowledge_instance + end + + def to_s + "" + end + end + + class KnowledgeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge_instance = payload.body[key].map do |data| + KnowledgeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge_instance + @instance + end + end + class KnowledgePage < Page ## # Initialize the KnowledgePage @@ -451,6 +611,54 @@ def to_s '' end end + + class KnowledgePageMetadata < PageMetadata + attr_reader :knowledge_page + + def initialize(version, response, solution, limit) + super(version, response) + @knowledge_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @knowledge_page << KnowledgeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @knowledge_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class KnowledgeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge = payload.body[key].map do |data| + KnowledgeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge + @knowledge + end + end + class KnowledgeInstance < InstanceResource ## # Initialize the KnowledgeInstance diff --git a/lib/twilio-ruby/rest/knowledge/v1/knowledge/chunk.rb b/lib/twilio-ruby/rest/knowledge/v1/knowledge/chunk.rb index 7c7c5da64..f49efb565 100644 --- a/lib/twilio-ruby/rest/knowledge/v1/knowledge/chunk.rb +++ b/lib/twilio-ruby/rest/knowledge/v1/knowledge/chunk.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChunkPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChunkPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChunkInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,6 +178,54 @@ def to_s '' end end + + class ChunkPageMetadata < PageMetadata + attr_reader :chunk_page + + def initialize(version, response, solution, limit) + super(version, response) + @chunk_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @chunk_page << ChunkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @chunk_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChunkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @chunk = payload.body[key].map do |data| + ChunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def chunk + @chunk + end + end + class ChunkInstance < InstanceResource ## # Initialize the ChunkInstance diff --git a/lib/twilio-ruby/rest/knowledge/v1/knowledge/knowledge_status.rb b/lib/twilio-ruby/rest/knowledge/v1/knowledge/knowledge_status.rb index 82aed0e94..ff7dff387 100644 --- a/lib/twilio-ruby/rest/knowledge/v1/knowledge/knowledge_status.rb +++ b/lib/twilio-ruby/rest/knowledge/v1/knowledge/knowledge_status.rb @@ -76,6 +76,31 @@ def fetch ) end + ## + # Fetch the KnowledgeStatusInstanceMetadata + # @return [KnowledgeStatusInstance] Fetched KnowledgeStatusInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + knowledgeStatus_instance = KnowledgeStatusInstance.new( + @version, + response.body, + id: @solution[:id], + ) + KnowledgeStatusInstanceMetadata.new( + @version, + knowledgeStatus_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -92,6 +117,45 @@ def inspect end end + class KnowledgeStatusInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new KnowledgeStatusInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}KnowledgeStatusInstance] knowledge_status_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [KnowledgeStatusInstanceMetadata] The initialized instance with metadata. + def initialize(version, knowledge_status_instance, headers, status_code) + super(version, headers, status_code) + @knowledge_status_instance = knowledge_status_instance + end + + def knowledge_status + @knowledge_status_instance + end + + def to_s + "" + end + end + + class KnowledgeStatusListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge_status_instance = payload.body[key].map do |data| + KnowledgeStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge_status_instance + @instance + end + end + class KnowledgeStatusPage < Page ## # Initialize the KnowledgeStatusPage @@ -120,6 +184,54 @@ def to_s '' end end + + class KnowledgeStatusPageMetadata < PageMetadata + attr_reader :knowledge_status_page + + def initialize(version, response, solution, limit) + super(version, response) + @knowledge_status_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @knowledge_status_page << KnowledgeStatusListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @knowledge_status_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class KnowledgeStatusListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @knowledge_status = payload.body[key].map do |data| + KnowledgeStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def knowledge_status + @knowledge_status + end + end + class KnowledgeStatusInstance < InstanceResource ## # Initialize the KnowledgeStatusInstance diff --git a/lib/twilio-ruby/rest/lookups/v1/phone_number.rb b/lib/twilio-ruby/rest/lookups/v1/phone_number.rb index f0e1dd56e..930a2b88e 100644 --- a/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +++ b/lib/twilio-ruby/rest/lookups/v1/phone_number.rb @@ -89,6 +89,46 @@ def fetch( ) end + ## + # Fetch the PhoneNumberInstanceMetadata + # @param [String] country_code The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. + # @param [Array[String]] type The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + # @param [Array[String]] add_ons The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). + # @param [Hash] add_ons_data Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. + # @return [PhoneNumberInstance] Fetched PhoneNumberInstance + def fetch_with_metadata( + country_code: :unset, + type: :unset, + add_ons: :unset, + add_ons_data: :unset + ) + + params = Twilio::Values.of({ + 'CountryCode' => country_code, + 'Type' => Twilio.serialize_list(type) { |e| e }, + 'AddOns' => Twilio.serialize_list(add_ons) { |e| e }, + }) + params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns')) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + phone_number: @solution[:phone_number], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -105,6 +145,45 @@ def inspect end end + class PhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PhoneNumberInstance] phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, phone_number_instance, headers, status_code) + super(version, headers, status_code) + @phone_number_instance = phone_number_instance + end + + def phone_number + @phone_number_instance + end + + def to_s + "" + end + end + + class PhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number_instance = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number_instance + @instance + end + end + class PhoneNumberPage < Page ## # Initialize the PhoneNumberPage @@ -133,6 +212,54 @@ def to_s '' end end + + class PhoneNumberPageMetadata < PageMetadata + attr_reader :phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @phone_number_page << PhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number + @phone_number + end + end + class PhoneNumberInstance < InstanceResource ## # Initialize the PhoneNumberInstance diff --git a/lib/twilio-ruby/rest/lookups/v2/bucket.rb b/lib/twilio-ruby/rest/lookups/v2/bucket.rb index ff608a1eb..0300cc3d7 100644 --- a/lib/twilio-ruby/rest/lookups/v2/bucket.rb +++ b/lib/twilio-ruby/rest/lookups/v2/bucket.rb @@ -82,7 +82,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BucketInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + bucket_instance = BucketInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BucketInstanceMetadata.new(@version, bucket_instance, response.headers, response.status_code) end ## @@ -105,6 +124,32 @@ def fetch ) end + ## + # Fetch the BucketInstanceMetadata + # @return [BucketInstance] Fetched BucketInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + bucket_instance = BucketInstance.new( + @version, + response.body, + field: @solution[:field], + bucket: @solution[:bucket], + ) + BucketInstanceMetadata.new( + @version, + bucket_instance, + response.headers, + response.status_code + ) + end + ## # Update the BucketInstance # @param [RateLimitRequest] rate_limit_request @@ -127,6 +172,34 @@ def update(rate_limit_request: :unset ) end + ## + # Update the BucketInstanceMetadata + # @param [RateLimitRequest] rate_limit_request + # @return [BucketInstance] Updated BucketInstance + def update_with_metadata(rate_limit_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: rate_limit_request.to_json) + bucket_instance = BucketInstance.new( + @version, + response.body, + field: @solution[:field], + bucket: @solution[:bucket], + ) + BucketInstanceMetadata.new( + @version, + bucket_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -143,6 +216,45 @@ def inspect end end + class BucketInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BucketInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BucketInstance] bucket_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BucketInstanceMetadata] The initialized instance with metadata. + def initialize(version, bucket_instance, headers, status_code) + super(version, headers, status_code) + @bucket_instance = bucket_instance + end + + def bucket + @bucket_instance + end + + def to_s + "" + end + end + + class BucketListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bucket_instance = payload.body[key].map do |data| + BucketInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bucket_instance + @instance + end + end + class BucketPage < Page ## # Initialize the BucketPage @@ -171,6 +283,54 @@ def to_s '' end end + + class BucketPageMetadata < PageMetadata + attr_reader :bucket_page + + def initialize(version, response, solution, limit) + super(version, response) + @bucket_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bucket_page << BucketListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bucket_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BucketListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bucket = payload.body[key].map do |data| + BucketInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bucket + @bucket + end + end + class BucketInstance < InstanceResource ## # Initialize the BucketInstance diff --git a/lib/twilio-ruby/rest/lookups/v2/lookup_override.rb b/lib/twilio-ruby/rest/lookups/v2/lookup_override.rb index 1c5052aac..d1f7b6909 100644 --- a/lib/twilio-ruby/rest/lookups/v2/lookup_override.rb +++ b/lib/twilio-ruby/rest/lookups/v2/lookup_override.rb @@ -95,6 +95,34 @@ def create(overrides_request: :unset ) end + ## + # Create the LookupOverrideInstanceMetadata + # @param [OverridesRequest] overrides_request + # @return [LookupOverrideInstance] Created LookupOverrideInstance + def create_with_metadata(overrides_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: overrides_request.to_json) + lookupOverride_instance = LookupOverrideInstance.new( + @version, + response.body, + field: @solution[:field], + phone_number: @solution[:phone_number], + ) + LookupOverrideInstanceMetadata.new( + @version, + lookupOverride_instance, + response.headers, + response.status_code + ) + end + ## # Delete the LookupOverrideInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -104,7 +132,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the LookupOverrideInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + lookupOverride_instance = LookupOverrideInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + LookupOverrideInstanceMetadata.new(@version, lookupOverride_instance, response.headers, response.status_code) end ## @@ -127,6 +174,32 @@ def fetch ) end + ## + # Fetch the LookupOverrideInstanceMetadata + # @return [LookupOverrideInstance] Fetched LookupOverrideInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + lookupOverride_instance = LookupOverrideInstance.new( + @version, + response.body, + field: @solution[:field], + phone_number: @solution[:phone_number], + ) + LookupOverrideInstanceMetadata.new( + @version, + lookupOverride_instance, + response.headers, + response.status_code + ) + end + ## # Update the LookupOverrideInstance # @param [OverridesRequest] overrides_request @@ -149,6 +222,34 @@ def update(overrides_request: :unset ) end + ## + # Update the LookupOverrideInstanceMetadata + # @param [OverridesRequest] overrides_request + # @return [LookupOverrideInstance] Updated LookupOverrideInstance + def update_with_metadata(overrides_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: overrides_request.to_json) + lookupOverride_instance = LookupOverrideInstance.new( + @version, + response.body, + field: @solution[:field], + phone_number: @solution[:phone_number], + ) + LookupOverrideInstanceMetadata.new( + @version, + lookupOverride_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -165,6 +266,45 @@ def inspect end end + class LookupOverrideInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new LookupOverrideInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}LookupOverrideInstance] lookup_override_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [LookupOverrideInstanceMetadata] The initialized instance with metadata. + def initialize(version, lookup_override_instance, headers, status_code) + super(version, headers, status_code) + @lookup_override_instance = lookup_override_instance + end + + def lookup_override + @lookup_override_instance + end + + def to_s + "" + end + end + + class LookupOverrideListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @lookup_override_instance = payload.body[key].map do |data| + LookupOverrideInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def lookup_override_instance + @instance + end + end + class LookupOverridePage < Page ## # Initialize the LookupOverridePage @@ -193,6 +333,54 @@ def to_s '' end end + + class LookupOverridePageMetadata < PageMetadata + attr_reader :lookup_override_page + + def initialize(version, response, solution, limit) + super(version, response) + @lookup_override_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @lookup_override_page << LookupOverrideListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @lookup_override_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LookupOverrideListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @lookup_override = payload.body[key].map do |data| + LookupOverrideInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def lookup_override + @lookup_override + end + end + class LookupOverrideInstance < InstanceResource ## # Initialize the LookupOverrideInstance diff --git a/lib/twilio-ruby/rest/lookups/v2/phone_number.rb b/lib/twilio-ruby/rest/lookups/v2/phone_number.rb index 0bfdcddfa..17abb600a 100644 --- a/lib/twilio-ruby/rest/lookups/v2/phone_number.rb +++ b/lib/twilio-ruby/rest/lookups/v2/phone_number.rb @@ -122,6 +122,79 @@ def fetch( ) end + ## + # Fetch the PhoneNumberInstanceMetadata + # @param [String] fields A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score, pre_fill. + # @param [String] country_code The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format. + # @param [String] first_name User’s first name. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] last_name User’s last name. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] address_line1 User’s first address line. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] address_line2 User’s second address line. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] city User’s city. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] state User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] postal_code User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] address_country_code User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] national_id User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] date_of_birth User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. + # @param [String] last_verified_date The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. + # @param [String] verification_sid The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. + # @param [String] partner_sub_id The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. + # @return [PhoneNumberInstance] Fetched PhoneNumberInstance + def fetch_with_metadata( + fields: :unset, + country_code: :unset, + first_name: :unset, + last_name: :unset, + address_line1: :unset, + address_line2: :unset, + city: :unset, + state: :unset, + postal_code: :unset, + address_country_code: :unset, + national_id: :unset, + date_of_birth: :unset, + last_verified_date: :unset, + verification_sid: :unset, + partner_sub_id: :unset + ) + + params = Twilio::Values.of({ + 'Fields' => fields, + 'CountryCode' => country_code, + 'FirstName' => first_name, + 'LastName' => last_name, + 'AddressLine1' => address_line1, + 'AddressLine2' => address_line2, + 'City' => city, + 'State' => state, + 'PostalCode' => postal_code, + 'AddressCountryCode' => address_country_code, + 'NationalId' => national_id, + 'DateOfBirth' => date_of_birth, + 'LastVerifiedDate' => last_verified_date, + 'VerificationSid' => verification_sid, + 'PartnerSubId' => partner_sub_id, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + phone_number: @solution[:phone_number], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -138,6 +211,45 @@ def inspect end end + class PhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PhoneNumberInstance] phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, phone_number_instance, headers, status_code) + super(version, headers, status_code) + @phone_number_instance = phone_number_instance + end + + def phone_number + @phone_number_instance + end + + def to_s + "" + end + end + + class PhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number_instance = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number_instance + @instance + end + end + class PhoneNumberPage < Page ## # Initialize the PhoneNumberPage @@ -166,6 +278,54 @@ def to_s '' end end + + class PhoneNumberPageMetadata < PageMetadata + attr_reader :phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @phone_number_page << PhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number + @phone_number + end + end + class PhoneNumberInstance < InstanceResource ## # Initialize the PhoneNumberInstance diff --git a/lib/twilio-ruby/rest/lookups/v2/query.rb b/lib/twilio-ruby/rest/lookups/v2/query.rb index 280a76c21..496dc2abc 100644 --- a/lib/twilio-ruby/rest/lookups/v2/query.rb +++ b/lib/twilio-ruby/rest/lookups/v2/query.rb @@ -180,6 +180,32 @@ def create(lookup_request: :unset ) end + ## + # Create the QueryInstanceMetadata + # @param [LookupRequest] lookup_request + # @return [QueryInstance] Created QueryInstance + def create_with_metadata(lookup_request: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: lookup_request.to_json) + query_instance = QueryInstance.new( + @version, + response.body, + ) + QueryInstanceMetadata.new( + @version, + query_instance, + response.headers, + response.status_code + ) + end + @@ -217,6 +243,54 @@ def to_s '' end end + + class QueryPageMetadata < PageMetadata + attr_reader :query_page + + def initialize(version, response, solution, limit) + super(version, response) + @query_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @query_page << QueryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @query_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class QueryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @query = payload.body[key].map do |data| + QueryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def query + @query + end + end + class QueryInstance < InstanceResource ## # Initialize the QueryInstance diff --git a/lib/twilio-ruby/rest/lookups/v2/rate_limit.rb b/lib/twilio-ruby/rest/lookups/v2/rate_limit.rb index 00b2067fa..d35624aba 100644 --- a/lib/twilio-ruby/rest/lookups/v2/rate_limit.rb +++ b/lib/twilio-ruby/rest/lookups/v2/rate_limit.rb @@ -54,6 +54,36 @@ def fetch( ) end + ## + # Fetch the RateLimitInstanceMetadata + # @param [Array[String]] fields + # @return [RateLimitInstance] Fetched RateLimitInstance + def fetch_with_metadata( + fields: :unset + ) + + params = Twilio::Values.of({ + 'Fields' => Twilio.serialize_list(fields) { |e| e }, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + rateLimit_instance = RateLimitInstance.new( + @version, + response.body, + ) + RateLimitInstanceMetadata.new( + @version, + rateLimit_instance, + response.headers, + response.status_code + ) + end + @@ -91,6 +121,54 @@ def to_s '' end end + + class RateLimitPageMetadata < PageMetadata + attr_reader :rate_limit_page + + def initialize(version, response, solution, limit) + super(version, response) + @rate_limit_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @rate_limit_page << RateLimitListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @rate_limit_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RateLimitListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @rate_limit = payload.body[key].map do |data| + RateLimitInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def rate_limit + @rate_limit + end + end + class RateLimitInstance < InstanceResource ## # Initialize the RateLimitInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/available_add_on.rb b/lib/twilio-ruby/rest/marketplace/v1/available_add_on.rb index ce86935f8..de29fa716 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/available_add_on.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/available_add_on.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AvailableAddOnPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AvailableAddOnPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AvailableAddOnInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -162,6 +184,31 @@ def fetch ) end + ## + # Fetch the AvailableAddOnInstanceMetadata + # @return [AvailableAddOnInstance] Fetched AvailableAddOnInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + availableAddOn_instance = AvailableAddOnInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AvailableAddOnInstanceMetadata.new( + @version, + availableAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Access the extensions # @return [AvailableAddOnExtensionList] @@ -197,6 +244,45 @@ def inspect end end + class AvailableAddOnInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AvailableAddOnInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AvailableAddOnInstance] available_add_on_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AvailableAddOnInstanceMetadata] The initialized instance with metadata. + def initialize(version, available_add_on_instance, headers, status_code) + super(version, headers, status_code) + @available_add_on_instance = available_add_on_instance + end + + def available_add_on + @available_add_on_instance + end + + def to_s + "" + end + end + + class AvailableAddOnListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on_instance = payload.body[key].map do |data| + AvailableAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on_instance + @instance + end + end + class AvailableAddOnPage < Page ## # Initialize the AvailableAddOnPage @@ -225,6 +311,54 @@ def to_s '' end end + + class AvailableAddOnPageMetadata < PageMetadata + attr_reader :available_add_on_page + + def initialize(version, response, solution, limit) + super(version, response) + @available_add_on_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @available_add_on_page << AvailableAddOnListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @available_add_on_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AvailableAddOnListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on = payload.body[key].map do |data| + AvailableAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on + @available_add_on + end + end + class AvailableAddOnInstance < InstanceResource ## # Initialize the AvailableAddOnInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/available_add_on/available_add_on_extension.rb b/lib/twilio-ruby/rest/marketplace/v1/available_add_on/available_add_on_extension.rb index e47fe11d7..7cad38ff4 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/available_add_on/available_add_on_extension.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/available_add_on/available_add_on_extension.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AvailableAddOnExtensionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AvailableAddOnExtensionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AvailableAddOnExtensionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the AvailableAddOnExtensionInstanceMetadata + # @return [AvailableAddOnExtensionInstance] Fetched AvailableAddOnExtensionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + availableAddOnExtension_instance = AvailableAddOnExtensionInstance.new( + @version, + response.body, + available_add_on_sid: @solution[:available_add_on_sid], + sid: @solution[:sid], + ) + AvailableAddOnExtensionInstanceMetadata.new( + @version, + availableAddOnExtension_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class AvailableAddOnExtensionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AvailableAddOnExtensionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AvailableAddOnExtensionInstance] available_add_on_extension_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AvailableAddOnExtensionInstanceMetadata] The initialized instance with metadata. + def initialize(version, available_add_on_extension_instance, headers, status_code) + super(version, headers, status_code) + @available_add_on_extension_instance = available_add_on_extension_instance + end + + def available_add_on_extension + @available_add_on_extension_instance + end + + def to_s + "" + end + end + + class AvailableAddOnExtensionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on_extension_instance = payload.body[key].map do |data| + AvailableAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on_extension_instance + @instance + end + end + class AvailableAddOnExtensionPage < Page ## # Initialize the AvailableAddOnExtensionPage @@ -209,6 +296,54 @@ def to_s '' end end + + class AvailableAddOnExtensionPageMetadata < PageMetadata + attr_reader :available_add_on_extension_page + + def initialize(version, response, solution, limit) + super(version, response) + @available_add_on_extension_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @available_add_on_extension_page << AvailableAddOnExtensionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @available_add_on_extension_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AvailableAddOnExtensionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on_extension = payload.body[key].map do |data| + AvailableAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on_extension + @available_add_on_extension + end + end + class AvailableAddOnExtensionInstance < InstanceResource ## # Initialize the AvailableAddOnExtensionInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/installed_add_on.rb b/lib/twilio-ruby/rest/marketplace/v1/installed_add_on.rb index 30ce6d930..6ad119436 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/installed_add_on.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/installed_add_on.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the InstalledAddOnInstanceMetadata + # @param [String] available_add_on_sid The SID of the AvaliableAddOn to install. + # @param [Boolean] accept_terms_of_service Whether the Terms of Service were accepted. + # @param [Object] configuration The JSON object that represents the configuration of the new Add-on being installed. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + # @return [InstalledAddOnInstance] Created InstalledAddOnInstance + def create_with_metadata( + available_add_on_sid: nil, + accept_terms_of_service: nil, + configuration: :unset, + unique_name: :unset + ) + + data = Twilio::Values.of({ + 'AvailableAddOnSid' => available_add_on_sid, + 'AcceptTermsOfService' => accept_terms_of_service, + 'Configuration' => Twilio.serialize_object(configuration), + 'UniqueName' => unique_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + ) + InstalledAddOnInstanceMetadata.new( + @version, + installedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Lists InstalledAddOnInstance records from the API as a list. @@ -103,6 +143,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InstalledAddOnPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InstalledAddOnPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InstalledAddOnInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -187,7 +249,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InstalledAddOnInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InstalledAddOnInstanceMetadata.new(@version, installedAddOn_instance, response.headers, response.status_code) end ## @@ -209,6 +290,31 @@ def fetch ) end + ## + # Fetch the InstalledAddOnInstanceMetadata + # @return [InstalledAddOnInstance] Fetched InstalledAddOnInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + InstalledAddOnInstanceMetadata.new( + @version, + installedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Update the InstalledAddOnInstance # @param [Object] configuration Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured @@ -238,6 +344,41 @@ def update( ) end + ## + # Update the InstalledAddOnInstanceMetadata + # @param [Object] configuration Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + # @return [InstalledAddOnInstance] Updated InstalledAddOnInstance + def update_with_metadata( + configuration: :unset, + unique_name: :unset + ) + + data = Twilio::Values.of({ + 'Configuration' => Twilio.serialize_object(configuration), + 'UniqueName' => unique_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + InstalledAddOnInstanceMetadata.new( + @version, + installedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Access the usage # @return [InstalledAddOnUsageList] @@ -284,6 +425,45 @@ def inspect end end + class InstalledAddOnInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InstalledAddOnInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InstalledAddOnInstance] installed_add_on_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InstalledAddOnInstanceMetadata] The initialized instance with metadata. + def initialize(version, installed_add_on_instance, headers, status_code) + super(version, headers, status_code) + @installed_add_on_instance = installed_add_on_instance + end + + def installed_add_on + @installed_add_on_instance + end + + def to_s + "" + end + end + + class InstalledAddOnListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on_instance = payload.body[key].map do |data| + InstalledAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on_instance + @instance + end + end + class InstalledAddOnPage < Page ## # Initialize the InstalledAddOnPage @@ -312,6 +492,54 @@ def to_s '' end end + + class InstalledAddOnPageMetadata < PageMetadata + attr_reader :installed_add_on_page + + def initialize(version, response, solution, limit) + super(version, response) + @installed_add_on_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @installed_add_on_page << InstalledAddOnListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @installed_add_on_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InstalledAddOnListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on = payload.body[key].map do |data| + InstalledAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on + @installed_add_on + end + end + class InstalledAddOnInstance < InstanceResource ## # Initialize the InstalledAddOnInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_extension.rb b/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_extension.rb index 34f97768e..06554e5cf 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_extension.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_extension.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InstalledAddOnExtensionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InstalledAddOnExtensionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InstalledAddOnExtensionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the InstalledAddOnExtensionInstanceMetadata + # @return [InstalledAddOnExtensionInstance] Fetched InstalledAddOnExtensionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + installedAddOnExtension_instance = InstalledAddOnExtensionInstance.new( + @version, + response.body, + installed_add_on_sid: @solution[:installed_add_on_sid], + sid: @solution[:sid], + ) + InstalledAddOnExtensionInstanceMetadata.new( + @version, + installedAddOnExtension_instance, + response.headers, + response.status_code + ) + end + ## # Update the InstalledAddOnExtensionInstance # @param [Boolean] enabled Whether the Extension should be invoked. @@ -192,6 +240,39 @@ def update( ) end + ## + # Update the InstalledAddOnExtensionInstanceMetadata + # @param [Boolean] enabled Whether the Extension should be invoked. + # @return [InstalledAddOnExtensionInstance] Updated InstalledAddOnExtensionInstance + def update_with_metadata( + enabled: nil + ) + + data = Twilio::Values.of({ + 'Enabled' => enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + installedAddOnExtension_instance = InstalledAddOnExtensionInstance.new( + @version, + response.body, + installed_add_on_sid: @solution[:installed_add_on_sid], + sid: @solution[:sid], + ) + InstalledAddOnExtensionInstanceMetadata.new( + @version, + installedAddOnExtension_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -208,6 +289,45 @@ def inspect end end + class InstalledAddOnExtensionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InstalledAddOnExtensionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InstalledAddOnExtensionInstance] installed_add_on_extension_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InstalledAddOnExtensionInstanceMetadata] The initialized instance with metadata. + def initialize(version, installed_add_on_extension_instance, headers, status_code) + super(version, headers, status_code) + @installed_add_on_extension_instance = installed_add_on_extension_instance + end + + def installed_add_on_extension + @installed_add_on_extension_instance + end + + def to_s + "" + end + end + + class InstalledAddOnExtensionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on_extension_instance = payload.body[key].map do |data| + InstalledAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on_extension_instance + @instance + end + end + class InstalledAddOnExtensionPage < Page ## # Initialize the InstalledAddOnExtensionPage @@ -236,6 +356,54 @@ def to_s '' end end + + class InstalledAddOnExtensionPageMetadata < PageMetadata + attr_reader :installed_add_on_extension_page + + def initialize(version, response, solution, limit) + super(version, response) + @installed_add_on_extension_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @installed_add_on_extension_page << InstalledAddOnExtensionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @installed_add_on_extension_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InstalledAddOnExtensionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on_extension = payload.body[key].map do |data| + InstalledAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on_extension + @installed_add_on_extension + end + end + class InstalledAddOnExtensionInstance < InstanceResource ## # Initialize the InstalledAddOnExtensionInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_usage.rb b/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_usage.rb index c0bf952df..55e91fe55 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_usage.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/installed_add_on/installed_add_on_usage.rb @@ -70,6 +70,33 @@ def create(marketplace_v1_installed_add_on_installed_add_on_usage: nil ) end + ## + # Create the InstalledAddOnUsageInstanceMetadata + # @param [MarketplaceV1InstalledAddOnInstalledAddOnUsage] marketplace_v1_installed_add_on_installed_add_on_usage + # @return [InstalledAddOnUsageInstance] Created InstalledAddOnUsageInstance + def create_with_metadata(marketplace_v1_installed_add_on_installed_add_on_usage: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: marketplace_v1_installed_add_on_installed_add_on_usage.to_json) + installedAddOnUsage_instance = InstalledAddOnUsageInstance.new( + @version, + response.body, + installed_add_on_sid: @solution[:installed_add_on_sid], + ) + InstalledAddOnUsageInstanceMetadata.new( + @version, + installedAddOnUsage_instance, + response.headers, + response.status_code + ) + end + @@ -107,6 +134,54 @@ def to_s '' end end + + class InstalledAddOnUsagePageMetadata < PageMetadata + attr_reader :installed_add_on_usage_page + + def initialize(version, response, solution, limit) + super(version, response) + @installed_add_on_usage_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @installed_add_on_usage_page << InstalledAddOnUsageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @installed_add_on_usage_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InstalledAddOnUsageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on_usage = payload.body[key].map do |data| + InstalledAddOnUsageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on_usage + @installed_add_on_usage + end + end + class InstalledAddOnUsageInstance < InstanceResource ## # Initialize the InstalledAddOnUsageInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/module_data.rb b/lib/twilio-ruby/rest/marketplace/v1/module_data.rb index d8aa173a2..73a9c66d3 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/module_data.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/module_data.rb @@ -58,6 +58,40 @@ def create( ) end + ## + # Create the ModuleDataInstanceMetadata + # @param [String] module_info A JSON object containing essential attributes that define a Listing. + # @param [String] configuration A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + # @return [ModuleDataInstance] Created ModuleDataInstance + def create_with_metadata( + module_info: :unset, + configuration: :unset + ) + + data = Twilio::Values.of({ + 'ModuleInfo' => module_info, + 'Configuration' => configuration, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + moduleData_instance = ModuleDataInstance.new( + @version, + response.body, + ) + ModuleDataInstanceMetadata.new( + @version, + moduleData_instance, + response.headers, + response.status_code + ) + end + ## # Fetch the ModuleDataInstance # @return [ModuleDataInstance] Fetched ModuleDataInstance @@ -76,6 +110,30 @@ def fetch ) end + ## + # Fetch the ModuleDataInstanceMetadata + # @return [ModuleDataInstance] Fetched ModuleDataInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + moduleData_instance = ModuleDataInstance.new( + @version, + response.body, + ) + ModuleDataInstanceMetadata.new( + @version, + moduleData_instance, + response.headers, + response.status_code + ) + end + @@ -113,6 +171,54 @@ def to_s '' end end + + class ModuleDataPageMetadata < PageMetadata + attr_reader :module_data_page + + def initialize(version, response, solution, limit) + super(version, response) + @module_data_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @module_data_page << ModuleDataListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @module_data_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ModuleDataListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @module_data = payload.body[key].map do |data| + ModuleDataInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def module_data + @module_data + end + end + class ModuleDataInstance < InstanceResource ## # Initialize the ModuleDataInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/module_data_management.rb b/lib/twilio-ruby/rest/marketplace/v1/module_data_management.rb index c0a6a4b13..b31a03d9a 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/module_data_management.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/module_data_management.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the ModuleDataManagementInstanceMetadata + # @return [ModuleDataManagementInstance] Fetched ModuleDataManagementInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + moduleDataManagement_instance = ModuleDataManagementInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ModuleDataManagementInstanceMetadata.new( + @version, + moduleDataManagement_instance, + response.headers, + response.status_code + ) + end + ## # Update the ModuleDataManagementInstance # @param [String] module_info A JSON object containing essential attributes that define a Listing. @@ -118,6 +143,56 @@ def update( ) end + ## + # Update the ModuleDataManagementInstanceMetadata + # @param [String] module_info A JSON object containing essential attributes that define a Listing. + # @param [String] description A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. + # @param [String] documentation A JSON object for providing comprehensive information, instructions, and resources related to the Listing. + # @param [String] policies A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. + # @param [String] support A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. + # @param [String] configuration A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + # @param [String] pricing A JSON object for providing Listing's purchase options. + # @return [ModuleDataManagementInstance] Updated ModuleDataManagementInstance + def update_with_metadata( + module_info: :unset, + description: :unset, + documentation: :unset, + policies: :unset, + support: :unset, + configuration: :unset, + pricing: :unset + ) + + data = Twilio::Values.of({ + 'ModuleInfo' => module_info, + 'Description' => description, + 'Documentation' => documentation, + 'Policies' => policies, + 'Support' => support, + 'Configuration' => configuration, + 'Pricing' => pricing, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + moduleDataManagement_instance = ModuleDataManagementInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ModuleDataManagementInstanceMetadata.new( + @version, + moduleDataManagement_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -134,6 +209,45 @@ def inspect end end + class ModuleDataManagementInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ModuleDataManagementInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ModuleDataManagementInstance] module_data_management_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ModuleDataManagementInstanceMetadata] The initialized instance with metadata. + def initialize(version, module_data_management_instance, headers, status_code) + super(version, headers, status_code) + @module_data_management_instance = module_data_management_instance + end + + def module_data_management + @module_data_management_instance + end + + def to_s + "" + end + end + + class ModuleDataManagementListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @module_data_management_instance = payload.body[key].map do |data| + ModuleDataManagementInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def module_data_management_instance + @instance + end + end + class ModuleDataManagementPage < Page ## # Initialize the ModuleDataManagementPage @@ -162,6 +276,54 @@ def to_s '' end end + + class ModuleDataManagementPageMetadata < PageMetadata + attr_reader :module_data_management_page + + def initialize(version, response, solution, limit) + super(version, response) + @module_data_management_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @module_data_management_page << ModuleDataManagementListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @module_data_management_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ModuleDataManagementListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @module_data_management = payload.body[key].map do |data| + ModuleDataManagementInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def module_data_management + @module_data_management + end + end + class ModuleDataManagementInstance < InstanceResource ## # Initialize the ModuleDataManagementInstance diff --git a/lib/twilio-ruby/rest/marketplace/v1/referral_conversion.rb b/lib/twilio-ruby/rest/marketplace/v1/referral_conversion.rb index 64d60ca76..d113604ac 100644 --- a/lib/twilio-ruby/rest/marketplace/v1/referral_conversion.rb +++ b/lib/twilio-ruby/rest/marketplace/v1/referral_conversion.rb @@ -64,6 +64,32 @@ def create(create_referral_conversion_request: nil ) end + ## + # Create the ReferralConversionInstanceMetadata + # @param [CreateReferralConversionRequest] create_referral_conversion_request + # @return [ReferralConversionInstance] Created ReferralConversionInstance + def create_with_metadata(create_referral_conversion_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: create_referral_conversion_request.to_json) + referralConversion_instance = ReferralConversionInstance.new( + @version, + response.body, + ) + ReferralConversionInstanceMetadata.new( + @version, + referralConversion_instance, + response.headers, + response.status_code + ) + end + @@ -101,6 +127,54 @@ def to_s '' end end + + class ReferralConversionPageMetadata < PageMetadata + attr_reader :referral_conversion_page + + def initialize(version, response, solution, limit) + super(version, response) + @referral_conversion_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @referral_conversion_page << ReferralConversionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @referral_conversion_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ReferralConversionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @referral_conversion = payload.body[key].map do |data| + ReferralConversionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def referral_conversion + @referral_conversion + end + end + class ReferralConversionInstance < InstanceResource ## # Initialize the ReferralConversionInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb b/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb index 7bd5812f8..8f390fa00 100644 --- a/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb +++ b/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb @@ -67,6 +67,49 @@ def create( ) end + ## + # Create the BrandRegistrationInstanceMetadata + # @param [String] customer_profile_bundle_sid Customer Profile Bundle Sid. + # @param [String] a2p_profile_bundle_sid A2P Messaging Profile Bundle Sid. + # @param [String] brand_type Type of brand being created. One of: \\\"STANDARD\\\", \\\"SOLE_PROPRIETOR\\\". SOLE_PROPRIETOR is for low volume, SOLE_PROPRIETOR use cases. STANDARD is for all other use cases. + # @param [Boolean] mock A boolean that specifies whether brand should be a mock or not. If true, brand will be registered as a mock brand. Defaults to false if no value is provided. + # @param [Boolean] skip_automatic_sec_vet A flag to disable automatic secondary vetting for brands which it would otherwise be done. + # @return [BrandRegistrationInstance] Created BrandRegistrationInstance + def create_with_metadata( + customer_profile_bundle_sid: nil, + a2p_profile_bundle_sid: nil, + brand_type: :unset, + mock: :unset, + skip_automatic_sec_vet: :unset + ) + + data = Twilio::Values.of({ + 'CustomerProfileBundleSid' => customer_profile_bundle_sid, + 'A2PProfileBundleSid' => a2p_profile_bundle_sid, + 'BrandType' => brand_type, + 'Mock' => mock, + 'SkipAutomaticSecVet' => skip_automatic_sec_vet, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + brandRegistration_instance = BrandRegistrationInstance.new( + @version, + response.body, + ) + BrandRegistrationInstanceMetadata.new( + @version, + brandRegistration_instance, + response.headers, + response.status_code + ) + end + ## # Lists BrandRegistrationInstance records from the API as a list. @@ -106,6 +149,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BrandRegistrationPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BrandRegistrationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BrandRegistrationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -201,6 +266,31 @@ def fetch ) end + ## + # Fetch the BrandRegistrationInstanceMetadata + # @return [BrandRegistrationInstance] Fetched BrandRegistrationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + brandRegistration_instance = BrandRegistrationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + BrandRegistrationInstanceMetadata.new( + @version, + brandRegistration_instance, + response.headers, + response.status_code + ) + end + ## # Update the BrandRegistrationInstance # @return [BrandRegistrationInstance] Updated BrandRegistrationInstance @@ -220,6 +310,31 @@ def update ) end + ## + # Update the BrandRegistrationInstanceMetadata + # @return [BrandRegistrationInstance] Updated BrandRegistrationInstance + def update_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers) + brandRegistration_instance = BrandRegistrationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + BrandRegistrationInstanceMetadata.new( + @version, + brandRegistration_instance, + response.headers, + response.status_code + ) + end + ## # Access the brand_registration_otps # @return [BrandRegistrationOtpList] @@ -276,6 +391,45 @@ def inspect end end + class BrandRegistrationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BrandRegistrationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BrandRegistrationInstance] brand_registration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BrandRegistrationInstanceMetadata] The initialized instance with metadata. + def initialize(version, brand_registration_instance, headers, status_code) + super(version, headers, status_code) + @brand_registration_instance = brand_registration_instance + end + + def brand_registration + @brand_registration_instance + end + + def to_s + "" + end + end + + class BrandRegistrationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @brand_registration_instance = payload.body[key].map do |data| + BrandRegistrationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def brand_registration_instance + @instance + end + end + class BrandRegistrationPage < Page ## # Initialize the BrandRegistrationPage @@ -304,6 +458,54 @@ def to_s '' end end + + class BrandRegistrationPageMetadata < PageMetadata + attr_reader :brand_registration_page + + def initialize(version, response, solution, limit) + super(version, response) + @brand_registration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @brand_registration_page << BrandRegistrationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @brand_registration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BrandRegistrationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @brand_registration = payload.body[key].map do |data| + BrandRegistrationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def brand_registration + @brand_registration + end + end + class BrandRegistrationInstance < InstanceResource ## # Initialize the BrandRegistrationInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_registration_otp.rb b/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_registration_otp.rb index 0d6f015e7..fbd2fae31 100644 --- a/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_registration_otp.rb +++ b/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_registration_otp.rb @@ -51,6 +51,31 @@ def create ) end + ## + # Create the BrandRegistrationOtpInstanceMetadata + # @return [BrandRegistrationOtpInstance] Created BrandRegistrationOtpInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + brandRegistrationOtp_instance = BrandRegistrationOtpInstance.new( + @version, + response.body, + brand_registration_sid: @solution[:brand_registration_sid], + ) + BrandRegistrationOtpInstanceMetadata.new( + @version, + brandRegistrationOtp_instance, + response.headers, + response.status_code + ) + end + @@ -88,6 +113,54 @@ def to_s '' end end + + class BrandRegistrationOtpPageMetadata < PageMetadata + attr_reader :brand_registration_otp_page + + def initialize(version, response, solution, limit) + super(version, response) + @brand_registration_otp_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @brand_registration_otp_page << BrandRegistrationOtpListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @brand_registration_otp_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BrandRegistrationOtpListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @brand_registration_otp = payload.body[key].map do |data| + BrandRegistrationOtpInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def brand_registration_otp + @brand_registration_otp + end + end + class BrandRegistrationOtpInstance < InstanceResource ## # Initialize the BrandRegistrationOtpInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_vetting.rb b/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_vetting.rb index 7ac798ee0..6700975df 100644 --- a/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_vetting.rb +++ b/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_vetting.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the BrandVettingInstanceMetadata + # @param [VettingProvider] vetting_provider + # @param [String] vetting_id The unique ID of the vetting + # @return [BrandVettingInstance] Created BrandVettingInstance + def create_with_metadata( + vetting_provider: nil, + vetting_id: :unset + ) + + data = Twilio::Values.of({ + 'VettingProvider' => vetting_provider, + 'VettingId' => vetting_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + brandVetting_instance = BrandVettingInstance.new( + @version, + response.body, + brand_sid: @solution[:brand_sid], + ) + BrandVettingInstanceMetadata.new( + @version, + brandVetting_instance, + response.headers, + response.status_code + ) + end + ## # Lists BrandVettingInstance records from the API as a list. @@ -104,6 +139,30 @@ def stream(vetting_provider: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BrandVettingPageMetadata records from the API as a list. + # @param [VettingProvider] vetting_provider The third-party provider of the vettings to read + # @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_with_metadata(vetting_provider: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'VettingProvider' => vetting_provider, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BrandVettingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BrandVettingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -200,6 +259,32 @@ def fetch ) end + ## + # Fetch the BrandVettingInstanceMetadata + # @return [BrandVettingInstance] Fetched BrandVettingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + brandVetting_instance = BrandVettingInstance.new( + @version, + response.body, + brand_sid: @solution[:brand_sid], + brand_vetting_sid: @solution[:brand_vetting_sid], + ) + BrandVettingInstanceMetadata.new( + @version, + brandVetting_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -216,6 +301,45 @@ def inspect end end + class BrandVettingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BrandVettingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BrandVettingInstance] brand_vetting_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BrandVettingInstanceMetadata] The initialized instance with metadata. + def initialize(version, brand_vetting_instance, headers, status_code) + super(version, headers, status_code) + @brand_vetting_instance = brand_vetting_instance + end + + def brand_vetting + @brand_vetting_instance + end + + def to_s + "" + end + end + + class BrandVettingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @brand_vetting_instance = payload.body[key].map do |data| + BrandVettingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def brand_vetting_instance + @instance + end + end + class BrandVettingPage < Page ## # Initialize the BrandVettingPage @@ -244,6 +368,54 @@ def to_s '' end end + + class BrandVettingPageMetadata < PageMetadata + attr_reader :brand_vetting_page + + def initialize(version, response, solution, limit) + super(version, response) + @brand_vetting_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @brand_vetting_page << BrandVettingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @brand_vetting_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BrandVettingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @brand_vetting = payload.body[key].map do |data| + BrandVettingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def brand_vetting + @brand_vetting + end + end + class BrandVettingInstance < InstanceResource ## # Initialize the BrandVettingInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/deactivations.rb b/lib/twilio-ruby/rest/messaging/v1/deactivations.rb index e2a13b3be..0f3029962 100644 --- a/lib/twilio-ruby/rest/messaging/v1/deactivations.rb +++ b/lib/twilio-ruby/rest/messaging/v1/deactivations.rb @@ -78,6 +78,36 @@ def fetch( ) end + ## + # Fetch the DeactivationsInstanceMetadata + # @param [Date] date The request will return a list of all United States Phone Numbers that were deactivated on the day specified by this parameter. This date should be specified in YYYY-MM-DD format. + # @return [DeactivationsInstance] Fetched DeactivationsInstance + def fetch_with_metadata( + date: :unset + ) + + params = Twilio::Values.of({ + 'Date' => Twilio.serialize_iso8601_date(date), + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + deactivations_instance = DeactivationsInstance.new( + @version, + response.body, + ) + DeactivationsInstanceMetadata.new( + @version, + deactivations_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -94,6 +124,45 @@ def inspect end end + class DeactivationsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DeactivationsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DeactivationsInstance] deactivations_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DeactivationsInstanceMetadata] The initialized instance with metadata. + def initialize(version, deactivations_instance, headers, status_code) + super(version, headers, status_code) + @deactivations_instance = deactivations_instance + end + + def deactivations + @deactivations_instance + end + + def to_s + "" + end + end + + class DeactivationsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @deactivations_instance = payload.body[key].map do |data| + DeactivationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def deactivations_instance + @instance + end + end + class DeactivationsPage < Page ## # Initialize the DeactivationsPage @@ -122,6 +191,54 @@ def to_s '' end end + + class DeactivationsPageMetadata < PageMetadata + attr_reader :deactivations_page + + def initialize(version, response, solution, limit) + super(version, response) + @deactivations_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @deactivations_page << DeactivationsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @deactivations_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DeactivationsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @deactivations = payload.body[key].map do |data| + DeactivationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def deactivations + @deactivations + end + end + class DeactivationsInstance < InstanceResource ## # Initialize the DeactivationsInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/domain_certs.rb b/lib/twilio-ruby/rest/messaging/v1/domain_certs.rb index a17214308..514eb580a 100644 --- a/lib/twilio-ruby/rest/messaging/v1/domain_certs.rb +++ b/lib/twilio-ruby/rest/messaging/v1/domain_certs.rb @@ -64,7 +64,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the DomainCertsInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + domainCerts_instance = DomainCertsInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + DomainCertsInstanceMetadata.new(@version, domainCerts_instance, response.headers, response.status_code) end ## @@ -86,6 +105,31 @@ def fetch ) end + ## + # Fetch the DomainCertsInstanceMetadata + # @return [DomainCertsInstance] Fetched DomainCertsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + domainCerts_instance = DomainCertsInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + ) + DomainCertsInstanceMetadata.new( + @version, + domainCerts_instance, + response.headers, + response.status_code + ) + end + ## # Update the DomainCertsInstance # @param [String] tls_cert Contains the full TLS certificate and private for this domain in PEM format: https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail. Twilio uses this information to process HTTPS traffic sent to your domain. @@ -112,6 +156,38 @@ def update( ) end + ## + # Update the DomainCertsInstanceMetadata + # @param [String] tls_cert Contains the full TLS certificate and private for this domain in PEM format: https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail. Twilio uses this information to process HTTPS traffic sent to your domain. + # @return [DomainCertsInstance] Updated DomainCertsInstance + def update_with_metadata( + tls_cert: nil + ) + + data = Twilio::Values.of({ + 'TlsCert' => tls_cert, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + domainCerts_instance = DomainCertsInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + ) + DomainCertsInstanceMetadata.new( + @version, + domainCerts_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -128,6 +204,45 @@ def inspect end end + class DomainCertsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DomainCertsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DomainCertsInstance] domain_certs_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DomainCertsInstanceMetadata] The initialized instance with metadata. + def initialize(version, domain_certs_instance, headers, status_code) + super(version, headers, status_code) + @domain_certs_instance = domain_certs_instance + end + + def domain_certs + @domain_certs_instance + end + + def to_s + "" + end + end + + class DomainCertsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_certs_instance = payload.body[key].map do |data| + DomainCertsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_certs_instance + @instance + end + end + class DomainCertsPage < Page ## # Initialize the DomainCertsPage @@ -156,6 +271,54 @@ def to_s '' end end + + class DomainCertsPageMetadata < PageMetadata + attr_reader :domain_certs_page + + def initialize(version, response, solution, limit) + super(version, response) + @domain_certs_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @domain_certs_page << DomainCertsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @domain_certs_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DomainCertsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_certs = payload.body[key].map do |data| + DomainCertsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_certs + @domain_certs + end + end + class DomainCertsInstance < InstanceResource ## # Initialize the DomainCertsInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/domain_config.rb b/lib/twilio-ruby/rest/messaging/v1/domain_config.rb index aa18ddd22..dd341781d 100644 --- a/lib/twilio-ruby/rest/messaging/v1/domain_config.rb +++ b/lib/twilio-ruby/rest/messaging/v1/domain_config.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the DomainConfigInstanceMetadata + # @return [DomainConfigInstance] Fetched DomainConfigInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + domainConfig_instance = DomainConfigInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + ) + DomainConfigInstanceMetadata.new( + @version, + domainConfig_instance, + response.headers, + response.status_code + ) + end + ## # Update the DomainConfigInstance # @param [String] fallback_url Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. @@ -109,6 +134,47 @@ def update( ) end + ## + # Update the DomainConfigInstanceMetadata + # @param [String] fallback_url Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. + # @param [String] callback_url URL to receive click events to your webhook whenever the recipients click on the shortened links + # @param [Boolean] continue_on_failure Boolean field to set customer delivery preference when there is a failure in linkShortening service + # @param [Boolean] disable_https Customer's choice to send links with/without \\\"https://\\\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified. + # @return [DomainConfigInstance] Updated DomainConfigInstance + def update_with_metadata( + fallback_url: :unset, + callback_url: :unset, + continue_on_failure: :unset, + disable_https: :unset + ) + + data = Twilio::Values.of({ + 'FallbackUrl' => fallback_url, + 'CallbackUrl' => callback_url, + 'ContinueOnFailure' => continue_on_failure, + 'DisableHttps' => disable_https, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + domainConfig_instance = DomainConfigInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + ) + DomainConfigInstanceMetadata.new( + @version, + domainConfig_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -125,6 +191,45 @@ def inspect end end + class DomainConfigInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DomainConfigInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DomainConfigInstance] domain_config_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DomainConfigInstanceMetadata] The initialized instance with metadata. + def initialize(version, domain_config_instance, headers, status_code) + super(version, headers, status_code) + @domain_config_instance = domain_config_instance + end + + def domain_config + @domain_config_instance + end + + def to_s + "" + end + end + + class DomainConfigListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_config_instance = payload.body[key].map do |data| + DomainConfigInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_config_instance + @instance + end + end + class DomainConfigPage < Page ## # Initialize the DomainConfigPage @@ -153,6 +258,54 @@ def to_s '' end end + + class DomainConfigPageMetadata < PageMetadata + attr_reader :domain_config_page + + def initialize(version, response, solution, limit) + super(version, response) + @domain_config_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @domain_config_page << DomainConfigListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @domain_config_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DomainConfigListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_config = payload.body[key].map do |data| + DomainConfigInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_config + @domain_config + end + end + class DomainConfigInstance < InstanceResource ## # Initialize the DomainConfigInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/domain_config_messaging_service.rb b/lib/twilio-ruby/rest/messaging/v1/domain_config_messaging_service.rb index 27b732b18..610ea686c 100644 --- a/lib/twilio-ruby/rest/messaging/v1/domain_config_messaging_service.rb +++ b/lib/twilio-ruby/rest/messaging/v1/domain_config_messaging_service.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the DomainConfigMessagingServiceInstanceMetadata + # @return [DomainConfigMessagingServiceInstance] Fetched DomainConfigMessagingServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + domainConfigMessagingService_instance = DomainConfigMessagingServiceInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + ) + DomainConfigMessagingServiceInstanceMetadata.new( + @version, + domainConfigMessagingService_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -90,6 +115,45 @@ def inspect end end + class DomainConfigMessagingServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DomainConfigMessagingServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DomainConfigMessagingServiceInstance] domain_config_messaging_service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DomainConfigMessagingServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, domain_config_messaging_service_instance, headers, status_code) + super(version, headers, status_code) + @domain_config_messaging_service_instance = domain_config_messaging_service_instance + end + + def domain_config_messaging_service + @domain_config_messaging_service_instance + end + + def to_s + "" + end + end + + class DomainConfigMessagingServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_config_messaging_service_instance = payload.body[key].map do |data| + DomainConfigMessagingServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_config_messaging_service_instance + @instance + end + end + class DomainConfigMessagingServicePage < Page ## # Initialize the DomainConfigMessagingServicePage @@ -118,6 +182,54 @@ def to_s '' end end + + class DomainConfigMessagingServicePageMetadata < PageMetadata + attr_reader :domain_config_messaging_service_page + + def initialize(version, response, solution, limit) + super(version, response) + @domain_config_messaging_service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @domain_config_messaging_service_page << DomainConfigMessagingServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @domain_config_messaging_service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DomainConfigMessagingServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_config_messaging_service = payload.body[key].map do |data| + DomainConfigMessagingServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_config_messaging_service + @domain_config_messaging_service + end + end + class DomainConfigMessagingServiceInstance < InstanceResource ## # Initialize the DomainConfigMessagingServiceInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/domain_validate_dn.rb b/lib/twilio-ruby/rest/messaging/v1/domain_validate_dn.rb index 37dfb5bbd..022616a83 100644 --- a/lib/twilio-ruby/rest/messaging/v1/domain_validate_dn.rb +++ b/lib/twilio-ruby/rest/messaging/v1/domain_validate_dn.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the DomainValidateDnInstanceMetadata + # @return [DomainValidateDnInstance] Fetched DomainValidateDnInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + domainValidateDn_instance = DomainValidateDnInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + ) + DomainValidateDnInstanceMetadata.new( + @version, + domainValidateDn_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -90,6 +115,45 @@ def inspect end end + class DomainValidateDnInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DomainValidateDnInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DomainValidateDnInstance] domain_validate_dn_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DomainValidateDnInstanceMetadata] The initialized instance with metadata. + def initialize(version, domain_validate_dn_instance, headers, status_code) + super(version, headers, status_code) + @domain_validate_dn_instance = domain_validate_dn_instance + end + + def domain_validate_dn + @domain_validate_dn_instance + end + + def to_s + "" + end + end + + class DomainValidateDnListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_validate_dn_instance = payload.body[key].map do |data| + DomainValidateDnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_validate_dn_instance + @instance + end + end + class DomainValidateDnPage < Page ## # Initialize the DomainValidateDnPage @@ -118,6 +182,54 @@ def to_s '' end end + + class DomainValidateDnPageMetadata < PageMetadata + attr_reader :domain_validate_dn_page + + def initialize(version, response, solution, limit) + super(version, response) + @domain_validate_dn_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @domain_validate_dn_page << DomainValidateDnListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @domain_validate_dn_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DomainValidateDnListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_validate_dn = payload.body[key].map do |data| + DomainValidateDnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_validate_dn + @domain_validate_dn + end + end + class DomainValidateDnInstance < InstanceResource ## # Initialize the DomainValidateDnInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/external_campaign.rb b/lib/twilio-ruby/rest/messaging/v1/external_campaign.rb index 6f9e75c09..369f886c0 100644 --- a/lib/twilio-ruby/rest/messaging/v1/external_campaign.rb +++ b/lib/twilio-ruby/rest/messaging/v1/external_campaign.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the ExternalCampaignInstanceMetadata + # @param [String] campaign_id ID of the preregistered campaign. + # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that the resource is associated with. + # @param [Boolean] cnp_migration Customers should use this flag during the ERC registration process to indicate to Twilio that the campaign being registered is undergoing CNP migration. It is important for the user to first trigger the CNP migration process for said campaign in their CSP portal and have Twilio accept the sharing request, before making this api call. + # @return [ExternalCampaignInstance] Created ExternalCampaignInstance + def create_with_metadata( + campaign_id: nil, + messaging_service_sid: nil, + cnp_migration: :unset + ) + + data = Twilio::Values.of({ + 'CampaignId' => campaign_id, + 'MessagingServiceSid' => messaging_service_sid, + 'CnpMigration' => cnp_migration, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + externalCampaign_instance = ExternalCampaignInstance.new( + @version, + response.body, + ) + ExternalCampaignInstanceMetadata.new( + @version, + externalCampaign_instance, + response.headers, + response.status_code + ) + end + @@ -98,6 +135,54 @@ def to_s '' end end + + class ExternalCampaignPageMetadata < PageMetadata + attr_reader :external_campaign_page + + def initialize(version, response, solution, limit) + super(version, response) + @external_campaign_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @external_campaign_page << ExternalCampaignListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @external_campaign_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExternalCampaignListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @external_campaign = payload.body[key].map do |data| + ExternalCampaignInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def external_campaign + @external_campaign + end + end + class ExternalCampaignInstance < InstanceResource ## # Initialize the ExternalCampaignInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service.rb b/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service.rb index bfb3d25ab..4b47fe943 100644 --- a/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service.rb +++ b/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service.rb @@ -76,6 +76,32 @@ def create ) end + ## + # Create the LinkshorteningMessagingServiceInstanceMetadata + # @return [LinkshorteningMessagingServiceInstance] Created LinkshorteningMessagingServiceInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + linkshorteningMessagingService_instance = LinkshorteningMessagingServiceInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + messaging_service_sid: @solution[:messaging_service_sid], + ) + LinkshorteningMessagingServiceInstanceMetadata.new( + @version, + linkshorteningMessagingService_instance, + response.headers, + response.status_code + ) + end + ## # Delete the LinkshorteningMessagingServiceInstance # @return [Boolean] True if delete succeeds, false otherwise @@ -85,7 +111,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the LinkshorteningMessagingServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + linkshorteningMessagingService_instance = LinkshorteningMessagingServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + LinkshorteningMessagingServiceInstanceMetadata.new(@version, linkshorteningMessagingService_instance, response.headers, response.status_code) end @@ -104,6 +149,45 @@ def inspect end end + class LinkshorteningMessagingServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new LinkshorteningMessagingServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}LinkshorteningMessagingServiceInstance] linkshortening_messaging_service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [LinkshorteningMessagingServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, linkshortening_messaging_service_instance, headers, status_code) + super(version, headers, status_code) + @linkshortening_messaging_service_instance = linkshortening_messaging_service_instance + end + + def linkshortening_messaging_service + @linkshortening_messaging_service_instance + end + + def to_s + "" + end + end + + class LinkshorteningMessagingServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @linkshortening_messaging_service_instance = payload.body[key].map do |data| + LinkshorteningMessagingServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def linkshortening_messaging_service_instance + @instance + end + end + class LinkshorteningMessagingServicePage < Page ## # Initialize the LinkshorteningMessagingServicePage @@ -132,6 +216,54 @@ def to_s '' end end + + class LinkshorteningMessagingServicePageMetadata < PageMetadata + attr_reader :linkshortening_messaging_service_page + + def initialize(version, response, solution, limit) + super(version, response) + @linkshortening_messaging_service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @linkshortening_messaging_service_page << LinkshorteningMessagingServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @linkshortening_messaging_service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LinkshorteningMessagingServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @linkshortening_messaging_service = payload.body[key].map do |data| + LinkshorteningMessagingServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def linkshortening_messaging_service + @linkshortening_messaging_service + end + end + class LinkshorteningMessagingServiceInstance < InstanceResource ## # Initialize the LinkshorteningMessagingServiceInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service_domain_association.rb b/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service_domain_association.rb index be3f859f7..33803faf3 100644 --- a/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service_domain_association.rb +++ b/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service_domain_association.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the LinkshorteningMessagingServiceDomainAssociationInstanceMetadata + # @return [LinkshorteningMessagingServiceDomainAssociationInstance] Fetched LinkshorteningMessagingServiceDomainAssociationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + linkshorteningMessagingServiceDomainAssociation_instance = LinkshorteningMessagingServiceDomainAssociationInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + ) + LinkshorteningMessagingServiceDomainAssociationInstanceMetadata.new( + @version, + linkshorteningMessagingServiceDomainAssociation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -90,6 +115,45 @@ def inspect end end + class LinkshorteningMessagingServiceDomainAssociationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new LinkshorteningMessagingServiceDomainAssociationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}LinkshorteningMessagingServiceDomainAssociationInstance] linkshortening_messaging_service_domain_association_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [LinkshorteningMessagingServiceDomainAssociationInstanceMetadata] The initialized instance with metadata. + def initialize(version, linkshortening_messaging_service_domain_association_instance, headers, status_code) + super(version, headers, status_code) + @linkshortening_messaging_service_domain_association_instance = linkshortening_messaging_service_domain_association_instance + end + + def linkshortening_messaging_service_domain_association + @linkshortening_messaging_service_domain_association_instance + end + + def to_s + "" + end + end + + class LinkshorteningMessagingServiceDomainAssociationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @linkshortening_messaging_service_domain_association_instance = payload.body[key].map do |data| + LinkshorteningMessagingServiceDomainAssociationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def linkshortening_messaging_service_domain_association_instance + @instance + end + end + class LinkshorteningMessagingServiceDomainAssociationPage < Page ## # Initialize the LinkshorteningMessagingServiceDomainAssociationPage @@ -118,6 +182,54 @@ def to_s '' end end + + class LinkshorteningMessagingServiceDomainAssociationPageMetadata < PageMetadata + attr_reader :linkshortening_messaging_service_domain_association_page + + def initialize(version, response, solution, limit) + super(version, response) + @linkshortening_messaging_service_domain_association_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @linkshortening_messaging_service_domain_association_page << LinkshorteningMessagingServiceDomainAssociationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @linkshortening_messaging_service_domain_association_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LinkshorteningMessagingServiceDomainAssociationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @linkshortening_messaging_service_domain_association = payload.body[key].map do |data| + LinkshorteningMessagingServiceDomainAssociationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def linkshortening_messaging_service_domain_association + @linkshortening_messaging_service_domain_association + end + end + class LinkshorteningMessagingServiceDomainAssociationInstance < InstanceResource ## # Initialize the LinkshorteningMessagingServiceDomainAssociationInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/request_managed_cert.rb b/lib/twilio-ruby/rest/messaging/v1/request_managed_cert.rb index b32d9a004..21a1dbfdb 100644 --- a/lib/twilio-ruby/rest/messaging/v1/request_managed_cert.rb +++ b/lib/twilio-ruby/rest/messaging/v1/request_managed_cert.rb @@ -74,6 +74,31 @@ def update ) end + ## + # Update the RequestManagedCertInstanceMetadata + # @return [RequestManagedCertInstance] Updated RequestManagedCertInstance + def update_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers) + requestManagedCert_instance = RequestManagedCertInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + ) + RequestManagedCertInstanceMetadata.new( + @version, + requestManagedCert_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -90,6 +115,45 @@ def inspect end end + class RequestManagedCertInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RequestManagedCertInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RequestManagedCertInstance] request_managed_cert_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RequestManagedCertInstanceMetadata] The initialized instance with metadata. + def initialize(version, request_managed_cert_instance, headers, status_code) + super(version, headers, status_code) + @request_managed_cert_instance = request_managed_cert_instance + end + + def request_managed_cert + @request_managed_cert_instance + end + + def to_s + "" + end + end + + class RequestManagedCertListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @request_managed_cert_instance = payload.body[key].map do |data| + RequestManagedCertInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def request_managed_cert_instance + @instance + end + end + class RequestManagedCertPage < Page ## # Initialize the RequestManagedCertPage @@ -118,6 +182,54 @@ def to_s '' end end + + class RequestManagedCertPageMetadata < PageMetadata + attr_reader :request_managed_cert_page + + def initialize(version, response, solution, limit) + super(version, response) + @request_managed_cert_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @request_managed_cert_page << RequestManagedCertListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @request_managed_cert_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RequestManagedCertListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @request_managed_cert = payload.body[key].map do |data| + RequestManagedCertInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def request_managed_cert + @request_managed_cert + end + end + class RequestManagedCertInstance < InstanceResource ## # Initialize the RequestManagedCertInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service.rb b/lib/twilio-ruby/rest/messaging/v1/service.rb index f37275981..d44a11de1 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service.rb @@ -100,6 +100,82 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] inbound_request_url The URL we call using `inbound_method` when a message is received by any phone number or short code in the Service. When this property is `null`, receiving inbound messages is disabled. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `inbound_request_url` defined for the Messaging Service. + # @param [String] inbound_method The HTTP method we should use to call `inbound_request_url`. Can be `GET` or `POST` and the default is `POST`. + # @param [String] fallback_url The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. + # @param [String] fallback_method The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. + # @param [String] status_callback The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. + # @param [Boolean] sticky_sender Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + # @param [Boolean] mms_converter Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + # @param [Boolean] smart_encoding Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. + # @param [ScanMessageContent] scan_message_content + # @param [Boolean] fallback_to_long_code [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. + # @param [Boolean] area_code_geomatch Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. + # @param [String] validity_period How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `36,000`. Default value is `36,000`. + # @param [Boolean] synchronous_validation Reserved. + # @param [String] usecase A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. + # @param [Boolean] use_inbound_webhook_on_number A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: nil, + inbound_request_url: :unset, + inbound_method: :unset, + fallback_url: :unset, + fallback_method: :unset, + status_callback: :unset, + sticky_sender: :unset, + mms_converter: :unset, + smart_encoding: :unset, + scan_message_content: :unset, + fallback_to_long_code: :unset, + area_code_geomatch: :unset, + validity_period: :unset, + synchronous_validation: :unset, + usecase: :unset, + use_inbound_webhook_on_number: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'InboundRequestUrl' => inbound_request_url, + 'InboundMethod' => inbound_method, + 'FallbackUrl' => fallback_url, + 'FallbackMethod' => fallback_method, + 'StatusCallback' => status_callback, + 'StickySender' => sticky_sender, + 'MmsConverter' => mms_converter, + 'SmartEncoding' => smart_encoding, + 'ScanMessageContent' => scan_message_content, + 'FallbackToLongCode' => fallback_to_long_code, + 'AreaCodeGeomatch' => area_code_geomatch, + 'ValidityPeriod' => validity_period, + 'SynchronousValidation' => synchronous_validation, + 'Usecase' => usecase, + 'UseInboundWebhookOnNumber' => use_inbound_webhook_on_number, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -139,6 +215,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -228,7 +326,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -250,6 +367,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -321,6 +463,83 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] inbound_request_url The URL we call using `inbound_method` when a message is received by any phone number or short code in the Service. When this property is `null`, receiving inbound messages is disabled. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `inbound_request_url` defined for the Messaging Service. + # @param [String] inbound_method The HTTP method we should use to call `inbound_request_url`. Can be `GET` or `POST` and the default is `POST`. + # @param [String] fallback_url The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. + # @param [String] fallback_method The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. + # @param [String] status_callback The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. + # @param [Boolean] sticky_sender Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + # @param [Boolean] mms_converter Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + # @param [Boolean] smart_encoding Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. + # @param [ScanMessageContent] scan_message_content + # @param [Boolean] fallback_to_long_code [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. + # @param [Boolean] area_code_geomatch Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. + # @param [String] validity_period How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `36,000`. Default value is `36,000`. + # @param [Boolean] synchronous_validation Reserved. + # @param [String] usecase A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. + # @param [Boolean] use_inbound_webhook_on_number A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + friendly_name: :unset, + inbound_request_url: :unset, + inbound_method: :unset, + fallback_url: :unset, + fallback_method: :unset, + status_callback: :unset, + sticky_sender: :unset, + mms_converter: :unset, + smart_encoding: :unset, + scan_message_content: :unset, + fallback_to_long_code: :unset, + area_code_geomatch: :unset, + validity_period: :unset, + synchronous_validation: :unset, + usecase: :unset, + use_inbound_webhook_on_number: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'InboundRequestUrl' => inbound_request_url, + 'InboundMethod' => inbound_method, + 'FallbackUrl' => fallback_url, + 'FallbackMethod' => fallback_method, + 'StatusCallback' => status_callback, + 'StickySender' => sticky_sender, + 'MmsConverter' => mms_converter, + 'SmartEncoding' => smart_encoding, + 'ScanMessageContent' => scan_message_content, + 'FallbackToLongCode' => fallback_to_long_code, + 'AreaCodeGeomatch' => area_code_geomatch, + 'ValidityPeriod' => validity_period, + 'SynchronousValidation' => synchronous_validation, + 'Usecase' => usecase, + 'UseInboundWebhookOnNumber' => use_inbound_webhook_on_number, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the us_app_to_person_usecases # @return [UsAppToPersonUsecaseList] @@ -462,6 +681,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -490,6 +748,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb b/lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb index 4dd867386..5abd4141b 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the AlphaSenderInstanceMetadata + # @param [String] alpha_sender The Alphanumeric Sender ID string. Can be up to 11 characters long. Valid characters are A-Z, a-z, 0-9, space, hyphen `-`, plus `+`, underscore `_` and ampersand `&`. This value cannot contain only numbers. + # @return [AlphaSenderInstance] Created AlphaSenderInstance + def create_with_metadata( + alpha_sender: nil + ) + + data = Twilio::Values.of({ + 'AlphaSender' => alpha_sender, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + alphaSender_instance = AlphaSenderInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + AlphaSenderInstanceMetadata.new( + @version, + alphaSender_instance, + response.headers, + response.status_code + ) + end + ## # Lists AlphaSenderInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AlphaSenderPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AlphaSenderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AlphaSenderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AlphaSenderInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + alphaSender_instance = AlphaSenderInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AlphaSenderInstanceMetadata.new(@version, alphaSender_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the AlphaSenderInstanceMetadata + # @return [AlphaSenderInstance] Fetched AlphaSenderInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + alphaSender_instance = AlphaSenderInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + AlphaSenderInstanceMetadata.new( + @version, + alphaSender_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class AlphaSenderInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AlphaSenderInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AlphaSenderInstance] alpha_sender_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AlphaSenderInstanceMetadata] The initialized instance with metadata. + def initialize(version, alpha_sender_instance, headers, status_code) + super(version, headers, status_code) + @alpha_sender_instance = alpha_sender_instance + end + + def alpha_sender + @alpha_sender_instance + end + + def to_s + "" + end + end + + class AlphaSenderListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @alpha_sender_instance = payload.body[key].map do |data| + AlphaSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def alpha_sender_instance + @instance + end + end + class AlphaSenderPage < Page ## # Initialize the AlphaSenderPage @@ -247,6 +385,54 @@ def to_s '' end end + + class AlphaSenderPageMetadata < PageMetadata + attr_reader :alpha_sender_page + + def initialize(version, response, solution, limit) + super(version, response) + @alpha_sender_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @alpha_sender_page << AlphaSenderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @alpha_sender_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AlphaSenderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @alpha_sender = payload.body[key].map do |data| + AlphaSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def alpha_sender + @alpha_sender + end + end + class AlphaSenderInstance < InstanceResource ## # Initialize the AlphaSenderInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service/channel_sender.rb b/lib/twilio-ruby/rest/messaging/v1/service/channel_sender.rb index 7ba3fffcc..767af5273 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service/channel_sender.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service/channel_sender.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the ChannelSenderInstanceMetadata + # @param [String] sid The SID of the Channel Sender being added to the Service. + # @return [ChannelSenderInstance] Created ChannelSenderInstance + def create_with_metadata( + sid: nil + ) + + data = Twilio::Values.of({ + 'Sid' => sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + channelSender_instance = ChannelSenderInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + ) + ChannelSenderInstanceMetadata.new( + @version, + channelSender_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChannelSenderInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChannelSenderPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChannelSenderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChannelSenderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ChannelSenderInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + channelSender_instance = ChannelSenderInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ChannelSenderInstanceMetadata.new(@version, channelSender_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the ChannelSenderInstanceMetadata + # @return [ChannelSenderInstance] Fetched ChannelSenderInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + channelSender_instance = ChannelSenderInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + sid: @solution[:sid], + ) + ChannelSenderInstanceMetadata.new( + @version, + channelSender_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class ChannelSenderInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelSenderInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelSenderInstance] channel_sender_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelSenderInstanceMetadata] The initialized instance with metadata. + def initialize(version, channel_sender_instance, headers, status_code) + super(version, headers, status_code) + @channel_sender_instance = channel_sender_instance + end + + def channel_sender + @channel_sender_instance + end + + def to_s + "" + end + end + + class ChannelSenderListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_sender_instance = payload.body[key].map do |data| + ChannelSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_sender_instance + @instance + end + end + class ChannelSenderPage < Page ## # Initialize the ChannelSenderPage @@ -247,6 +385,54 @@ def to_s '' end end + + class ChannelSenderPageMetadata < PageMetadata + attr_reader :channel_sender_page + + def initialize(version, response, solution, limit) + super(version, response) + @channel_sender_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channel_sender_page << ChannelSenderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channel_sender_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelSenderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channel_sender = payload.body[key].map do |data| + ChannelSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channel_sender + @channel_sender + end + end + class ChannelSenderInstance < InstanceResource ## # Initialize the ChannelSenderInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service/destination_alpha_sender.rb b/lib/twilio-ruby/rest/messaging/v1/service/destination_alpha_sender.rb index b56ad2334..11ed77837 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service/destination_alpha_sender.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service/destination_alpha_sender.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the DestinationAlphaSenderInstanceMetadata + # @param [String] alpha_sender The Alphanumeric Sender ID string. Can be up to 11 characters long. Valid characters are A-Z, a-z, 0-9, space, hyphen `-`, plus `+`, underscore `_` and ampersand `&`. This value cannot contain only numbers. + # @param [String] iso_country_code The Optional Two Character ISO Country Code the Alphanumeric Sender ID will be used for. If the IsoCountryCode is not provided, a default Alpha Sender will be created that can be used across all countries. + # @return [DestinationAlphaSenderInstance] Created DestinationAlphaSenderInstance + def create_with_metadata( + alpha_sender: nil, + iso_country_code: :unset + ) + + data = Twilio::Values.of({ + 'AlphaSender' => alpha_sender, + 'IsoCountryCode' => iso_country_code, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + destinationAlphaSender_instance = DestinationAlphaSenderInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + DestinationAlphaSenderInstanceMetadata.new( + @version, + destinationAlphaSender_instance, + response.headers, + response.status_code + ) + end + ## # Lists DestinationAlphaSenderInstance records from the API as a list. @@ -104,6 +139,30 @@ def stream(iso_country_code: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DestinationAlphaSenderPageMetadata records from the API as a list. + # @param [String] iso_country_code Optional filter to return only alphanumeric sender IDs associated with the specified two-character ISO country code. + # @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_with_metadata(iso_country_code: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'IsoCountryCode' => iso_country_code, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DestinationAlphaSenderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DestinationAlphaSenderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -189,7 +248,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the DestinationAlphaSenderInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + destinationAlphaSender_instance = DestinationAlphaSenderInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + DestinationAlphaSenderInstanceMetadata.new(@version, destinationAlphaSender_instance, response.headers, response.status_code) end ## @@ -212,6 +290,32 @@ def fetch ) end + ## + # Fetch the DestinationAlphaSenderInstanceMetadata + # @return [DestinationAlphaSenderInstance] Fetched DestinationAlphaSenderInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + destinationAlphaSender_instance = DestinationAlphaSenderInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + DestinationAlphaSenderInstanceMetadata.new( + @version, + destinationAlphaSender_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -228,6 +332,45 @@ def inspect end end + class DestinationAlphaSenderInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DestinationAlphaSenderInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DestinationAlphaSenderInstance] destination_alpha_sender_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DestinationAlphaSenderInstanceMetadata] The initialized instance with metadata. + def initialize(version, destination_alpha_sender_instance, headers, status_code) + super(version, headers, status_code) + @destination_alpha_sender_instance = destination_alpha_sender_instance + end + + def destination_alpha_sender + @destination_alpha_sender_instance + end + + def to_s + "" + end + end + + class DestinationAlphaSenderListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @destination_alpha_sender_instance = payload.body[key].map do |data| + DestinationAlphaSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def destination_alpha_sender_instance + @instance + end + end + class DestinationAlphaSenderPage < Page ## # Initialize the DestinationAlphaSenderPage @@ -256,6 +399,54 @@ def to_s '' end end + + class DestinationAlphaSenderPageMetadata < PageMetadata + attr_reader :destination_alpha_sender_page + + def initialize(version, response, solution, limit) + super(version, response) + @destination_alpha_sender_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @destination_alpha_sender_page << DestinationAlphaSenderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @destination_alpha_sender_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DestinationAlphaSenderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @destination_alpha_sender = payload.body[key].map do |data| + DestinationAlphaSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def destination_alpha_sender + @destination_alpha_sender + end + end + class DestinationAlphaSenderInstance < InstanceResource ## # Initialize the DestinationAlphaSenderInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb b/lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb index 05af628d0..a4b436754 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the PhoneNumberInstanceMetadata + # @param [String] phone_number_sid The SID of the Phone Number being added to the Service. + # @return [PhoneNumberInstance] Created PhoneNumberInstance + def create_with_metadata( + phone_number_sid: nil + ) + + data = Twilio::Values.of({ + 'PhoneNumberSid' => phone_number_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Lists PhoneNumberInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PhoneNumberPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PhoneNumberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PhoneNumberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PhoneNumberInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PhoneNumberInstanceMetadata.new(@version, phoneNumber_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the PhoneNumberInstanceMetadata + # @return [PhoneNumberInstance] Fetched PhoneNumberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class PhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PhoneNumberInstance] phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, phone_number_instance, headers, status_code) + super(version, headers, status_code) + @phone_number_instance = phone_number_instance + end + + def phone_number + @phone_number_instance + end + + def to_s + "" + end + end + + class PhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number_instance = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number_instance + @instance + end + end + class PhoneNumberPage < Page ## # Initialize the PhoneNumberPage @@ -247,6 +385,54 @@ def to_s '' end end + + class PhoneNumberPageMetadata < PageMetadata + attr_reader :phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @phone_number_page << PhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number + @phone_number + end + end + class PhoneNumberInstance < InstanceResource ## # Initialize the PhoneNumberInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service/short_code.rb b/lib/twilio-ruby/rest/messaging/v1/service/short_code.rb index f2236ae7e..4f0b505be 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service/short_code.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service/short_code.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the ShortCodeInstanceMetadata + # @param [String] short_code_sid The SID of the ShortCode resource being added to the Service. + # @return [ShortCodeInstance] Created ShortCodeInstance + def create_with_metadata( + short_code_sid: nil + ) + + data = Twilio::Values.of({ + 'ShortCodeSid' => short_code_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + shortCode_instance = ShortCodeInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + ShortCodeInstanceMetadata.new( + @version, + shortCode_instance, + response.headers, + response.status_code + ) + end + ## # Lists ShortCodeInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ShortCodePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ShortCodePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ShortCodeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ShortCodeInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + shortCode_instance = ShortCodeInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ShortCodeInstanceMetadata.new(@version, shortCode_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the ShortCodeInstanceMetadata + # @return [ShortCodeInstance] Fetched ShortCodeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + shortCode_instance = ShortCodeInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + ShortCodeInstanceMetadata.new( + @version, + shortCode_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class ShortCodeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ShortCodeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ShortCodeInstance] short_code_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ShortCodeInstanceMetadata] The initialized instance with metadata. + def initialize(version, short_code_instance, headers, status_code) + super(version, headers, status_code) + @short_code_instance = short_code_instance + end + + def short_code + @short_code_instance + end + + def to_s + "" + end + end + + class ShortCodeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @short_code_instance = payload.body[key].map do |data| + ShortCodeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def short_code_instance + @instance + end + end + class ShortCodePage < Page ## # Initialize the ShortCodePage @@ -247,6 +385,54 @@ def to_s '' end end + + class ShortCodePageMetadata < PageMetadata + attr_reader :short_code_page + + def initialize(version, response, solution, limit) + super(version, response) + @short_code_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @short_code_page << ShortCodeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @short_code_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ShortCodeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @short_code = payload.body[key].map do |data| + ShortCodeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def short_code + @short_code + end + end + class ShortCodeInstance < InstanceResource ## # Initialize the ShortCodeInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb b/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb index ebbc15609..320daca8d 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb @@ -103,6 +103,83 @@ def create( ) end + ## + # Create the UsAppToPersonInstanceMetadata + # @param [String] brand_registration_sid A2P Brand Registration SID + # @param [String] description A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. + # @param [String] message_flow Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. + # @param [Array[String]] message_samples An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. + # @param [String] us_app_to_person_usecase A2P Campaign Use Case. Examples: [ 2FA, EMERGENCY, MARKETING..] + # @param [Boolean] has_embedded_links Indicates that this SMS campaign will send messages that contain links. + # @param [Boolean] has_embedded_phone Indicates that this SMS campaign will send messages that contain phone numbers. + # @param [String] opt_in_message If end users can text in a keyword to start receiving messages from this campaign, the auto-reply messages sent to the end users must be provided. The opt-in response should include the Brand name, confirmation of opt-in enrollment to a recurring message campaign, how to get help, and clear description of how to opt-out. This field is required if end users can text in a keyword to start receiving messages from this campaign. 20 character minimum. 320 character maximum. + # @param [String] opt_out_message Upon receiving the opt-out keywords from the end users, Twilio customers are expected to send back an auto-generated response, which must provide acknowledgment of the opt-out request and confirmation that no further messages will be sent. It is also recommended that these opt-out messages include the brand name. This field is required if managing opt out keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). 20 character minimum. 320 character maximum. + # @param [String] help_message When customers receive the help keywords from their end users, Twilio customers are expected to send back an auto-generated response; this may include the brand name and additional support contact information. This field is required if managing help keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). 20 character minimum. 320 character maximum. + # @param [Array[String]] opt_in_keywords If end users can text in a keyword to start receiving messages from this campaign, those keywords must be provided. This field is required if end users can text in a keyword to start receiving messages from this campaign. Values must be alphanumeric. 255 character maximum. + # @param [Array[String]] opt_out_keywords End users should be able to text in a keyword to stop receiving messages from this campaign. Those keywords must be provided. This field is required if managing opt out keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). Values must be alphanumeric. 255 character maximum. + # @param [Array[String]] help_keywords End users should be able to text in a keyword to receive help. Those keywords must be provided as part of the campaign registration request. This field is required if managing help keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). Values must be alphanumeric. 255 character maximum. + # @param [Boolean] subscriber_opt_in A boolean that specifies whether campaign has Subscriber Optin or not. + # @param [Boolean] age_gated A boolean that specifies whether campaign is age gated or not. + # @param [Boolean] direct_lending A boolean that specifies whether campaign allows direct lending or not. + # @return [UsAppToPersonInstance] Created UsAppToPersonInstance + def create_with_metadata( + brand_registration_sid: nil, + description: nil, + message_flow: nil, + message_samples: nil, + us_app_to_person_usecase: nil, + has_embedded_links: nil, + has_embedded_phone: nil, + opt_in_message: :unset, + opt_out_message: :unset, + help_message: :unset, + opt_in_keywords: :unset, + opt_out_keywords: :unset, + help_keywords: :unset, + subscriber_opt_in: :unset, + age_gated: :unset, + direct_lending: :unset + ) + + data = Twilio::Values.of({ + 'BrandRegistrationSid' => brand_registration_sid, + 'Description' => description, + 'MessageFlow' => message_flow, + 'MessageSamples' => Twilio.serialize_list(message_samples) { |e| e }, + 'UsAppToPersonUsecase' => us_app_to_person_usecase, + 'HasEmbeddedLinks' => has_embedded_links, + 'HasEmbeddedPhone' => has_embedded_phone, + 'OptInMessage' => opt_in_message, + 'OptOutMessage' => opt_out_message, + 'HelpMessage' => help_message, + 'OptInKeywords' => Twilio.serialize_list(opt_in_keywords) { |e| e }, + 'OptOutKeywords' => Twilio.serialize_list(opt_out_keywords) { |e| e }, + 'HelpKeywords' => Twilio.serialize_list(help_keywords) { |e| e }, + 'SubscriberOptIn' => subscriber_opt_in, + 'AgeGated' => age_gated, + 'DirectLending' => direct_lending, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + usAppToPerson_instance = UsAppToPersonInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + ) + UsAppToPersonInstanceMetadata.new( + @version, + usAppToPerson_instance, + response.headers, + response.status_code + ) + end + ## # Lists UsAppToPersonInstance records from the API as a list. @@ -142,6 +219,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UsAppToPersonPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UsAppToPersonPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UsAppToPersonInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -225,7 +324,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UsAppToPersonInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + usAppToPerson_instance = UsAppToPersonInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UsAppToPersonInstanceMetadata.new(@version, usAppToPerson_instance, response.headers, response.status_code) end ## @@ -248,6 +366,32 @@ def fetch ) end + ## + # Fetch the UsAppToPersonInstanceMetadata + # @return [UsAppToPersonInstance] Fetched UsAppToPersonInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + usAppToPerson_instance = UsAppToPersonInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + sid: @solution[:sid], + ) + UsAppToPersonInstanceMetadata.new( + @version, + usAppToPerson_instance, + response.headers, + response.status_code + ) + end + ## # Update the UsAppToPersonInstance # @param [Boolean] has_embedded_links Indicates that this SMS campaign will send messages that contain links. @@ -293,6 +437,57 @@ def update( ) end + ## + # Update the UsAppToPersonInstanceMetadata + # @param [Boolean] has_embedded_links Indicates that this SMS campaign will send messages that contain links. + # @param [Boolean] has_embedded_phone Indicates that this SMS campaign will send messages that contain phone numbers. + # @param [Array[String]] message_samples An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. + # @param [String] message_flow Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. + # @param [String] description A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. + # @param [Boolean] age_gated A boolean that specifies whether campaign requires age gate for federally legal content. + # @param [Boolean] direct_lending A boolean that specifies whether campaign allows direct lending or not. + # @return [UsAppToPersonInstance] Updated UsAppToPersonInstance + def update_with_metadata( + has_embedded_links: nil, + has_embedded_phone: nil, + message_samples: nil, + message_flow: nil, + description: nil, + age_gated: nil, + direct_lending: nil + ) + + data = Twilio::Values.of({ + 'HasEmbeddedLinks' => has_embedded_links, + 'HasEmbeddedPhone' => has_embedded_phone, + 'MessageSamples' => Twilio.serialize_list(message_samples) { |e| e }, + 'MessageFlow' => message_flow, + 'Description' => description, + 'AgeGated' => age_gated, + 'DirectLending' => direct_lending, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + usAppToPerson_instance = UsAppToPersonInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + sid: @solution[:sid], + ) + UsAppToPersonInstanceMetadata.new( + @version, + usAppToPerson_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -309,6 +504,45 @@ def inspect end end + class UsAppToPersonInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UsAppToPersonInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UsAppToPersonInstance] us_app_to_person_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UsAppToPersonInstanceMetadata] The initialized instance with metadata. + def initialize(version, us_app_to_person_instance, headers, status_code) + super(version, headers, status_code) + @us_app_to_person_instance = us_app_to_person_instance + end + + def us_app_to_person + @us_app_to_person_instance + end + + def to_s + "" + end + end + + class UsAppToPersonListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @us_app_to_person_instance = payload.body[key].map do |data| + UsAppToPersonInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def us_app_to_person_instance + @instance + end + end + class UsAppToPersonPage < Page ## # Initialize the UsAppToPersonPage @@ -337,6 +571,54 @@ def to_s '' end end + + class UsAppToPersonPageMetadata < PageMetadata + attr_reader :us_app_to_person_page + + def initialize(version, response, solution, limit) + super(version, response) + @us_app_to_person_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @us_app_to_person_page << UsAppToPersonListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @us_app_to_person_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsAppToPersonListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @us_app_to_person = payload.body[key].map do |data| + UsAppToPersonInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def us_app_to_person + @us_app_to_person + end + end + class UsAppToPersonInstance < InstanceResource ## # Initialize the UsAppToPersonInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.rb b/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.rb index cbd03c47e..1be31f3db 100644 --- a/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.rb +++ b/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.rb @@ -57,6 +57,37 @@ def fetch( ) end + ## + # Fetch the UsAppToPersonUsecaseInstanceMetadata + # @param [String] brand_registration_sid The unique string to identify the A2P brand. + # @return [UsAppToPersonUsecaseInstance] Fetched UsAppToPersonUsecaseInstance + def fetch_with_metadata( + brand_registration_sid: :unset + ) + + params = Twilio::Values.of({ + 'BrandRegistrationSid' => brand_registration_sid, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + usAppToPersonUsecase_instance = UsAppToPersonUsecaseInstance.new( + @version, + response.body, + messaging_service_sid: @solution[:messaging_service_sid], + ) + UsAppToPersonUsecaseInstanceMetadata.new( + @version, + usAppToPersonUsecase_instance, + response.headers, + response.status_code + ) + end + @@ -94,6 +125,54 @@ def to_s '' end end + + class UsAppToPersonUsecasePageMetadata < PageMetadata + attr_reader :us_app_to_person_usecase_page + + def initialize(version, response, solution, limit) + super(version, response) + @us_app_to_person_usecase_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @us_app_to_person_usecase_page << UsAppToPersonUsecaseListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @us_app_to_person_usecase_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsAppToPersonUsecaseListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @us_app_to_person_usecase = payload.body[key].map do |data| + UsAppToPersonUsecaseInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def us_app_to_person_usecase + @us_app_to_person_usecase + end + end + class UsAppToPersonUsecaseInstance < InstanceResource ## # Initialize the UsAppToPersonUsecaseInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/tollfree_verification.rb b/lib/twilio-ruby/rest/messaging/v1/tollfree_verification.rb index 050cffb03..e84520faf 100644 --- a/lib/twilio-ruby/rest/messaging/v1/tollfree_verification.rb +++ b/lib/twilio-ruby/rest/messaging/v1/tollfree_verification.rb @@ -157,6 +157,139 @@ def create( ) end + ## + # Create the TollfreeVerificationInstanceMetadata + # @param [String] business_name The name of the business or organization using the Tollfree number. + # @param [String] business_website The website of the business or organization using the Tollfree number. + # @param [String] notification_email The email address to receive the notification about the verification result. . + # @param [Array[String]] use_case_categories The category of the use case for the Tollfree Number. List as many are applicable.. + # @param [String] use_case_summary Use this to further explain how messaging is used by the business or organization. + # @param [String] production_message_sample An example of message content, i.e. a sample message. + # @param [Array[String]] opt_in_image_urls Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL. + # @param [OptInType] opt_in_type + # @param [String] message_volume Estimate monthly volume of messages from the Tollfree Number. + # @param [String] tollfree_phone_number_sid The SID of the Phone Number associated with the Tollfree Verification. + # @param [String] customer_profile_sid Customer's Profile Bundle BundleSid. + # @param [String] business_street_address The address of the business or organization using the Tollfree number. + # @param [String] business_street_address2 The address of the business or organization using the Tollfree number. + # @param [String] business_city The city of the business or organization using the Tollfree number. + # @param [String] business_state_province_region The state/province/region of the business or organization using the Tollfree number. + # @param [String] business_postal_code The postal code of the business or organization using the Tollfree number. + # @param [String] business_country The country of the business or organization using the Tollfree number. + # @param [String] additional_information Additional information to be provided for verification. + # @param [String] business_contact_first_name The first name of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_last_name The last name of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_email The email address of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_phone The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. + # @param [String] external_reference_id An optional external reference ID supplied by customer and echoed back on status retrieval. + # @param [String] business_registration_number A legally recognized business registration number + # @param [String] business_registration_authority The organizational authority for business registrations + # @param [String] business_registration_country Country business is registered in + # @param [String] business_type The type of business, valid values are PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, SOLE_PROPRIETOR, GOVERNMENT + # @param [String] business_registration_phone_number The E.164 formatted number associated with the business. + # @param [String] doing_business_as Trade name, sub entity, or downstream business name of business being submitted for verification + # @param [String] opt_in_confirmation_message The confirmation message sent to users when they opt in to receive messages. + # @param [String] help_message_sample A sample help message provided to users. + # @param [String] privacy_policy_url The URL to the privacy policy for the business or organization. + # @param [String] terms_and_conditions_url The URL to the terms and conditions for the business or organization. + # @param [Boolean] age_gated_content Indicates if the content is age gated. + # @param [Array[String]] opt_in_keywords List of keywords that users can text in to opt in to receive messages. + # @return [TollfreeVerificationInstance] Created TollfreeVerificationInstance + def create_with_metadata( + business_name: nil, + business_website: nil, + notification_email: nil, + use_case_categories: nil, + use_case_summary: nil, + production_message_sample: nil, + opt_in_image_urls: nil, + opt_in_type: nil, + message_volume: nil, + tollfree_phone_number_sid: nil, + customer_profile_sid: :unset, + business_street_address: :unset, + business_street_address2: :unset, + business_city: :unset, + business_state_province_region: :unset, + business_postal_code: :unset, + business_country: :unset, + additional_information: :unset, + business_contact_first_name: :unset, + business_contact_last_name: :unset, + business_contact_email: :unset, + business_contact_phone: :unset, + external_reference_id: :unset, + business_registration_number: :unset, + business_registration_authority: :unset, + business_registration_country: :unset, + business_type: :unset, + business_registration_phone_number: :unset, + doing_business_as: :unset, + opt_in_confirmation_message: :unset, + help_message_sample: :unset, + privacy_policy_url: :unset, + terms_and_conditions_url: :unset, + age_gated_content: :unset, + opt_in_keywords: :unset + ) + + data = Twilio::Values.of({ + 'BusinessName' => business_name, + 'BusinessWebsite' => business_website, + 'NotificationEmail' => notification_email, + 'UseCaseCategories' => Twilio.serialize_list(use_case_categories) { |e| e }, + 'UseCaseSummary' => use_case_summary, + 'ProductionMessageSample' => production_message_sample, + 'OptInImageUrls' => Twilio.serialize_list(opt_in_image_urls) { |e| e }, + 'OptInType' => opt_in_type, + 'MessageVolume' => message_volume, + 'TollfreePhoneNumberSid' => tollfree_phone_number_sid, + 'CustomerProfileSid' => customer_profile_sid, + 'BusinessStreetAddress' => business_street_address, + 'BusinessStreetAddress2' => business_street_address2, + 'BusinessCity' => business_city, + 'BusinessStateProvinceRegion' => business_state_province_region, + 'BusinessPostalCode' => business_postal_code, + 'BusinessCountry' => business_country, + 'AdditionalInformation' => additional_information, + 'BusinessContactFirstName' => business_contact_first_name, + 'BusinessContactLastName' => business_contact_last_name, + 'BusinessContactEmail' => business_contact_email, + 'BusinessContactPhone' => business_contact_phone, + 'ExternalReferenceId' => external_reference_id, + 'BusinessRegistrationNumber' => business_registration_number, + 'BusinessRegistrationAuthority' => business_registration_authority, + 'BusinessRegistrationCountry' => business_registration_country, + 'BusinessType' => business_type, + 'BusinessRegistrationPhoneNumber' => business_registration_phone_number, + 'DoingBusinessAs' => doing_business_as, + 'OptInConfirmationMessage' => opt_in_confirmation_message, + 'HelpMessageSample' => help_message_sample, + 'PrivacyPolicyUrl' => privacy_policy_url, + 'TermsAndConditionsUrl' => terms_and_conditions_url, + 'AgeGatedContent' => age_gated_content, + 'OptInKeywords' => Twilio.serialize_list(opt_in_keywords) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + tollfreeVerification_instance = TollfreeVerificationInstance.new( + @version, + response.body, + ) + TollfreeVerificationInstanceMetadata.new( + @version, + tollfreeVerification_instance, + response.headers, + response.status_code + ) + end + ## # Lists TollfreeVerificationInstance records from the API as a list. @@ -216,6 +349,39 @@ def stream(tollfree_phone_number_sid: :unset, status: :unset, external_reference @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TollfreeVerificationPageMetadata records from the API as a list. + # @param [String] tollfree_phone_number_sid The SID of the Phone Number associated with the Tollfree Verification. + # @param [Status] status The compliance status of the Tollfree Verification record. + # @param [String] external_reference_id Customer supplied reference id for the Tollfree Verification record. + # @param [Boolean] include_sub_accounts Whether to include Tollfree Verifications from sub accounts in list response. + # @param [Array[String]] trust_product_sid The trust product sids / tollfree bundle sids of tollfree verifications + # @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_with_metadata(tollfree_phone_number_sid: :unset, status: :unset, external_reference_id: :unset, include_sub_accounts: :unset, trust_product_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'TollfreePhoneNumberSid' => tollfree_phone_number_sid, + 'Status' => status, + 'ExternalReferenceId' => external_reference_id, + 'IncludeSubAccounts' => include_sub_accounts, + + 'TrustProductSid' => Twilio.serialize_list(trust_product_sid) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TollfreeVerificationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TollfreeVerificationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -309,7 +475,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TollfreeVerificationInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + tollfreeVerification_instance = TollfreeVerificationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TollfreeVerificationInstanceMetadata.new(@version, tollfreeVerification_instance, response.headers, response.status_code) end ## @@ -331,6 +516,31 @@ def fetch ) end + ## + # Fetch the TollfreeVerificationInstanceMetadata + # @return [TollfreeVerificationInstance] Fetched TollfreeVerificationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + tollfreeVerification_instance = TollfreeVerificationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + TollfreeVerificationInstanceMetadata.new( + @version, + tollfreeVerification_instance, + response.headers, + response.status_code + ) + end + ## # Update the TollfreeVerificationInstance # @param [String] business_name The name of the business or organization using the Tollfree number. @@ -453,6 +663,134 @@ def update( ) end + ## + # Update the TollfreeVerificationInstanceMetadata + # @param [String] business_name The name of the business or organization using the Tollfree number. + # @param [String] business_website The website of the business or organization using the Tollfree number. + # @param [String] notification_email The email address to receive the notification about the verification result. . + # @param [Array[String]] use_case_categories The category of the use case for the Tollfree Number. List as many are applicable.. + # @param [String] use_case_summary Use this to further explain how messaging is used by the business or organization. + # @param [String] production_message_sample An example of message content, i.e. a sample message. + # @param [Array[String]] opt_in_image_urls Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL. + # @param [OptInType] opt_in_type + # @param [String] message_volume Estimate monthly volume of messages from the Tollfree Number. + # @param [String] business_street_address The address of the business or organization using the Tollfree number. + # @param [String] business_street_address2 The address of the business or organization using the Tollfree number. + # @param [String] business_city The city of the business or organization using the Tollfree number. + # @param [String] business_state_province_region The state/province/region of the business or organization using the Tollfree number. + # @param [String] business_postal_code The postal code of the business or organization using the Tollfree number. + # @param [String] business_country The country of the business or organization using the Tollfree number. + # @param [String] additional_information Additional information to be provided for verification. + # @param [String] business_contact_first_name The first name of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_last_name The last name of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_email The email address of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_phone The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. + # @param [String] edit_reason Describe why the verification is being edited. If the verification was rejected because of a technical issue, such as the website being down, and the issue has been resolved this parameter should be set to something similar to 'Website fixed'. + # @param [String] business_registration_number A legaly recognized business registration number + # @param [String] business_registration_authority The organizational authority for business registrations + # @param [String] business_registration_country Country business is registered in + # @param [String] business_type The type of business, valid values are PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, SOLE_PROPRIETOR, GOVERNMENT + # @param [String] business_registration_phone_number The E.164 formatted number associated with the business. + # @param [String] doing_business_as Trade name, sub entity, or downstream business name of business being submitted for verification + # @param [String] opt_in_confirmation_message The confirmation message sent to users when they opt in to receive messages. + # @param [String] help_message_sample A sample help message provided to users. + # @param [String] privacy_policy_url The URL to the privacy policy for the business or organization. + # @param [String] terms_and_conditions_url The URL to the terms and conditions for the business or organization. + # @param [Boolean] age_gated_content Indicates if the content is age gated. + # @param [Array[String]] opt_in_keywords List of keywords that users can text in to opt in to receive messages. + # @return [TollfreeVerificationInstance] Updated TollfreeVerificationInstance + def update_with_metadata( + business_name: :unset, + business_website: :unset, + notification_email: :unset, + use_case_categories: :unset, + use_case_summary: :unset, + production_message_sample: :unset, + opt_in_image_urls: :unset, + opt_in_type: :unset, + message_volume: :unset, + business_street_address: :unset, + business_street_address2: :unset, + business_city: :unset, + business_state_province_region: :unset, + business_postal_code: :unset, + business_country: :unset, + additional_information: :unset, + business_contact_first_name: :unset, + business_contact_last_name: :unset, + business_contact_email: :unset, + business_contact_phone: :unset, + edit_reason: :unset, + business_registration_number: :unset, + business_registration_authority: :unset, + business_registration_country: :unset, + business_type: :unset, + business_registration_phone_number: :unset, + doing_business_as: :unset, + opt_in_confirmation_message: :unset, + help_message_sample: :unset, + privacy_policy_url: :unset, + terms_and_conditions_url: :unset, + age_gated_content: :unset, + opt_in_keywords: :unset + ) + + data = Twilio::Values.of({ + 'BusinessName' => business_name, + 'BusinessWebsite' => business_website, + 'NotificationEmail' => notification_email, + 'UseCaseCategories' => Twilio.serialize_list(use_case_categories) { |e| e }, + 'UseCaseSummary' => use_case_summary, + 'ProductionMessageSample' => production_message_sample, + 'OptInImageUrls' => Twilio.serialize_list(opt_in_image_urls) { |e| e }, + 'OptInType' => opt_in_type, + 'MessageVolume' => message_volume, + 'BusinessStreetAddress' => business_street_address, + 'BusinessStreetAddress2' => business_street_address2, + 'BusinessCity' => business_city, + 'BusinessStateProvinceRegion' => business_state_province_region, + 'BusinessPostalCode' => business_postal_code, + 'BusinessCountry' => business_country, + 'AdditionalInformation' => additional_information, + 'BusinessContactFirstName' => business_contact_first_name, + 'BusinessContactLastName' => business_contact_last_name, + 'BusinessContactEmail' => business_contact_email, + 'BusinessContactPhone' => business_contact_phone, + 'EditReason' => edit_reason, + 'BusinessRegistrationNumber' => business_registration_number, + 'BusinessRegistrationAuthority' => business_registration_authority, + 'BusinessRegistrationCountry' => business_registration_country, + 'BusinessType' => business_type, + 'BusinessRegistrationPhoneNumber' => business_registration_phone_number, + 'DoingBusinessAs' => doing_business_as, + 'OptInConfirmationMessage' => opt_in_confirmation_message, + 'HelpMessageSample' => help_message_sample, + 'PrivacyPolicyUrl' => privacy_policy_url, + 'TermsAndConditionsUrl' => terms_and_conditions_url, + 'AgeGatedContent' => age_gated_content, + 'OptInKeywords' => Twilio.serialize_list(opt_in_keywords) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + tollfreeVerification_instance = TollfreeVerificationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + TollfreeVerificationInstanceMetadata.new( + @version, + tollfreeVerification_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -469,6 +807,45 @@ def inspect end end + class TollfreeVerificationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TollfreeVerificationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TollfreeVerificationInstance] tollfree_verification_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TollfreeVerificationInstanceMetadata] The initialized instance with metadata. + def initialize(version, tollfree_verification_instance, headers, status_code) + super(version, headers, status_code) + @tollfree_verification_instance = tollfree_verification_instance + end + + def tollfree_verification + @tollfree_verification_instance + end + + def to_s + "" + end + end + + class TollfreeVerificationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @tollfree_verification_instance = payload.body[key].map do |data| + TollfreeVerificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def tollfree_verification_instance + @instance + end + end + class TollfreeVerificationPage < Page ## # Initialize the TollfreeVerificationPage @@ -497,6 +874,54 @@ def to_s '' end end + + class TollfreeVerificationPageMetadata < PageMetadata + attr_reader :tollfree_verification_page + + def initialize(version, response, solution, limit) + super(version, response) + @tollfree_verification_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @tollfree_verification_page << TollfreeVerificationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @tollfree_verification_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TollfreeVerificationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @tollfree_verification = payload.body[key].map do |data| + TollfreeVerificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def tollfree_verification + @tollfree_verification + end + end + class TollfreeVerificationInstance < InstanceResource ## # Initialize the TollfreeVerificationInstance diff --git a/lib/twilio-ruby/rest/messaging/v1/usecase.rb b/lib/twilio-ruby/rest/messaging/v1/usecase.rb index 4cb15f01d..28e41dc3f 100644 --- a/lib/twilio-ruby/rest/messaging/v1/usecase.rb +++ b/lib/twilio-ruby/rest/messaging/v1/usecase.rb @@ -48,6 +48,30 @@ def fetch ) end + ## + # Fetch the UsecaseInstanceMetadata + # @return [UsecaseInstance] Fetched UsecaseInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + usecase_instance = UsecaseInstance.new( + @version, + response.body, + ) + UsecaseInstanceMetadata.new( + @version, + usecase_instance, + response.headers, + response.status_code + ) + end + @@ -85,6 +109,54 @@ def to_s '' end end + + class UsecasePageMetadata < PageMetadata + attr_reader :usecase_page + + def initialize(version, response, solution, limit) + super(version, response) + @usecase_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @usecase_page << UsecaseListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @usecase_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsecaseListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @usecase = payload.body[key].map do |data| + UsecaseInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def usecase + @usecase + end + end + class UsecaseInstance < InstanceResource ## # Initialize the UsecaseInstance diff --git a/lib/twilio-ruby/rest/messaging/v2/channels_sender.rb b/lib/twilio-ruby/rest/messaging/v2/channels_sender.rb index 371f4d84d..5d6f29675 100644 --- a/lib/twilio-ruby/rest/messaging/v2/channels_sender.rb +++ b/lib/twilio-ruby/rest/messaging/v2/channels_sender.rb @@ -404,6 +404,32 @@ def create(messaging_v2_channels_sender_requests_create: nil ) end + ## + # Create the ChannelsSenderInstanceMetadata + # @param [MessagingV2ChannelsSenderRequestsCreate] messaging_v2_channels_sender_requests_create + # @return [ChannelsSenderInstance] Created ChannelsSenderInstance + def create_with_metadata(messaging_v2_channels_sender_requests_create: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: messaging_v2_channels_sender_requests_create.to_json) + channelsSender_instance = ChannelsSenderInstance.new( + @version, + response.body, + ) + ChannelsSenderInstanceMetadata.new( + @version, + channelsSender_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChannelsSenderInstance records from the API as a list. @@ -447,6 +473,30 @@ def stream(channel: nil, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChannelsSenderPageMetadata records from the API as a list. + # @param [String] channel + # @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_with_metadata(channel: nil, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Channel' => channel, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChannelsSenderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChannelsSenderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -531,7 +581,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ChannelsSenderInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + channelsSender_instance = ChannelsSenderInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ChannelsSenderInstanceMetadata.new(@version, channelsSender_instance, response.headers, response.status_code) end ## @@ -553,6 +622,31 @@ def fetch ) end + ## + # Fetch the ChannelsSenderInstanceMetadata + # @return [ChannelsSenderInstance] Fetched ChannelsSenderInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + channelsSender_instance = ChannelsSenderInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ChannelsSenderInstanceMetadata.new( + @version, + channelsSender_instance, + response.headers, + response.status_code + ) + end + ## # Update the ChannelsSenderInstance # @param [MessagingV2ChannelsSenderRequestsUpdate] messaging_v2_channels_sender_requests_update @@ -574,6 +668,33 @@ def update(messaging_v2_channels_sender_requests_update: :unset ) end + ## + # Update the ChannelsSenderInstanceMetadata + # @param [MessagingV2ChannelsSenderRequestsUpdate] messaging_v2_channels_sender_requests_update + # @return [ChannelsSenderInstance] Updated ChannelsSenderInstance + def update_with_metadata(messaging_v2_channels_sender_requests_update: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers, data: messaging_v2_channels_sender_requests_update.to_json) + channelsSender_instance = ChannelsSenderInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ChannelsSenderInstanceMetadata.new( + @version, + channelsSender_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -590,6 +711,45 @@ def inspect end end + class ChannelsSenderInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChannelsSenderInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChannelsSenderInstance] channels_sender_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChannelsSenderInstanceMetadata] The initialized instance with metadata. + def initialize(version, channels_sender_instance, headers, status_code) + super(version, headers, status_code) + @channels_sender_instance = channels_sender_instance + end + + def channels_sender + @channels_sender_instance + end + + def to_s + "" + end + end + + class ChannelsSenderListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channels_sender_instance = payload.body[key].map do |data| + ChannelsSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channels_sender_instance + @instance + end + end + class ChannelsSenderPage < Page ## # Initialize the ChannelsSenderPage @@ -618,6 +778,54 @@ def to_s '' end end + + class ChannelsSenderPageMetadata < PageMetadata + attr_reader :channels_sender_page + + def initialize(version, response, solution, limit) + super(version, response) + @channels_sender_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @channels_sender_page << ChannelsSenderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @channels_sender_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChannelsSenderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @channels_sender = payload.body[key].map do |data| + ChannelsSenderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def channels_sender + @channels_sender + end + end + class ChannelsSenderInstance < InstanceResource ## # Initialize the ChannelsSenderInstance diff --git a/lib/twilio-ruby/rest/messaging/v2/domain_certs.rb b/lib/twilio-ruby/rest/messaging/v2/domain_certs.rb index 5464dde0c..07a9dca32 100644 --- a/lib/twilio-ruby/rest/messaging/v2/domain_certs.rb +++ b/lib/twilio-ruby/rest/messaging/v2/domain_certs.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the DomainCertsInstanceMetadata + # @return [DomainCertsInstance] Fetched DomainCertsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + domainCerts_instance = DomainCertsInstance.new( + @version, + response.body, + domain_sid: @solution[:domain_sid], + ) + DomainCertsInstanceMetadata.new( + @version, + domainCerts_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -90,6 +115,45 @@ def inspect end end + class DomainCertsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DomainCertsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DomainCertsInstance] domain_certs_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DomainCertsInstanceMetadata] The initialized instance with metadata. + def initialize(version, domain_certs_instance, headers, status_code) + super(version, headers, status_code) + @domain_certs_instance = domain_certs_instance + end + + def domain_certs + @domain_certs_instance + end + + def to_s + "" + end + end + + class DomainCertsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_certs_instance = payload.body[key].map do |data| + DomainCertsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_certs_instance + @instance + end + end + class DomainCertsPage < Page ## # Initialize the DomainCertsPage @@ -118,6 +182,54 @@ def to_s '' end end + + class DomainCertsPageMetadata < PageMetadata + attr_reader :domain_certs_page + + def initialize(version, response, solution, limit) + super(version, response) + @domain_certs_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @domain_certs_page << DomainCertsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @domain_certs_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DomainCertsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @domain_certs = payload.body[key].map do |data| + DomainCertsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def domain_certs + @domain_certs + end + end + class DomainCertsInstance < InstanceResource ## # Initialize the DomainCertsInstance diff --git a/lib/twilio-ruby/rest/messaging/v2/typing_indicator.rb b/lib/twilio-ruby/rest/messaging/v2/typing_indicator.rb index 830b57df8..66db6e254 100644 --- a/lib/twilio-ruby/rest/messaging/v2/typing_indicator.rb +++ b/lib/twilio-ruby/rest/messaging/v2/typing_indicator.rb @@ -58,6 +58,40 @@ def create( ) end + ## + # Create the TypingIndicatorInstanceMetadata + # @param [String] channel Shared channel identifier + # @param [String] message_id Message SID that identifies the conversation thread for the typing indicator. Must be a valid Twilio Message SID (SM*) or Media SID (MM*) from an existing WhatsApp conversation. + # @return [TypingIndicatorInstance] Created TypingIndicatorInstance + def create_with_metadata( + channel: nil, + message_id: nil + ) + + data = Twilio::Values.of({ + 'channel' => channel, + 'messageId' => message_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + typingIndicator_instance = TypingIndicatorInstance.new( + @version, + response.body, + ) + TypingIndicatorInstanceMetadata.new( + @version, + typingIndicator_instance, + response.headers, + response.status_code + ) + end + @@ -95,6 +129,54 @@ def to_s '' end end + + class TypingIndicatorPageMetadata < PageMetadata + attr_reader :typing_indicator_page + + def initialize(version, response, solution, limit) + super(version, response) + @typing_indicator_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @typing_indicator_page << TypingIndicatorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @typing_indicator_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TypingIndicatorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @typing_indicator = payload.body[key].map do |data| + TypingIndicatorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def typing_indicator + @typing_indicator + end + end + class TypingIndicatorInstance < InstanceResource ## # Initialize the TypingIndicatorInstance diff --git a/lib/twilio-ruby/rest/monitor/v1/alert.rb b/lib/twilio-ruby/rest/monitor/v1/alert.rb index 13a2440c6..6d346c017 100644 --- a/lib/twilio-ruby/rest/monitor/v1/alert.rb +++ b/lib/twilio-ruby/rest/monitor/v1/alert.rb @@ -81,6 +81,34 @@ def stream(log_level: :unset, start_date: :unset, end_date: :unset, limit: nil, @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AlertPageMetadata records from the API as a list. + # @param [String] log_level Only show alerts for this log-level. Can be: `error`, `warning`, `notice`, or `debug`. + # @param [Time] start_date Only include alerts that occurred on or after this date and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or `YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported. + # @param [Time] end_date Only include alerts that occurred on or before this date and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or `YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported. + # @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_with_metadata(log_level: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'LogLevel' => log_level, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AlertPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AlertInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -179,6 +207,31 @@ def fetch ) end + ## + # Fetch the AlertInstanceMetadata + # @return [AlertInstance] Fetched AlertInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + alert_instance = AlertInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AlertInstanceMetadata.new( + @version, + alert_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -195,6 +248,45 @@ def inspect end end + class AlertInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AlertInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AlertInstance] alert_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AlertInstanceMetadata] The initialized instance with metadata. + def initialize(version, alert_instance, headers, status_code) + super(version, headers, status_code) + @alert_instance = alert_instance + end + + def alert + @alert_instance + end + + def to_s + "" + end + end + + class AlertListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @alert_instance = payload.body[key].map do |data| + AlertInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def alert_instance + @instance + end + end + class AlertPage < Page ## # Initialize the AlertPage @@ -223,6 +315,54 @@ def to_s '' end end + + class AlertPageMetadata < PageMetadata + attr_reader :alert_page + + def initialize(version, response, solution, limit) + super(version, response) + @alert_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @alert_page << AlertListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @alert_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AlertListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @alert = payload.body[key].map do |data| + AlertInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def alert + @alert + end + end + class AlertInstance < InstanceResource ## # Initialize the AlertInstance diff --git a/lib/twilio-ruby/rest/monitor/v1/event.rb b/lib/twilio-ruby/rest/monitor/v1/event.rb index 3a98eeb10..edf6670ae 100644 --- a/lib/twilio-ruby/rest/monitor/v1/event.rb +++ b/lib/twilio-ruby/rest/monitor/v1/event.rb @@ -93,6 +93,40 @@ def stream(actor_sid: :unset, event_type: :unset, resource_sid: :unset, source_i @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EventPageMetadata records from the API as a list. + # @param [String] actor_sid Only include events initiated by this Actor. Useful for auditing actions taken by specific users or API credentials. + # @param [String] event_type Only include events of this [Event Type](https://www.twilio.com/docs/usage/monitor-events#event-types). + # @param [String] resource_sid Only include events that refer to this resource. Useful for discovering the history of a specific resource. + # @param [String] source_ip_address Only include events that originated from this IP address. Useful for tracking suspicious activity originating from the API or the Twilio Console. + # @param [Time] start_date Only include events that occurred on or after this date. Specify the date in GMT and [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [Time] end_date Only include events that occurred on or before this date. Specify the date in GMT and [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @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_with_metadata(actor_sid: :unset, event_type: :unset, resource_sid: :unset, source_ip_address: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ActorSid' => actor_sid, + 'EventType' => event_type, + 'ResourceSid' => resource_sid, + 'SourceIpAddress' => source_ip_address, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EventPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EventInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -197,6 +231,31 @@ def fetch ) end + ## + # Fetch the EventInstanceMetadata + # @return [EventInstance] Fetched EventInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + event_instance = EventInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EventInstanceMetadata.new( + @version, + event_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -213,6 +272,45 @@ def inspect end end + class EventInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EventInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EventInstance] event_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EventInstanceMetadata] The initialized instance with metadata. + def initialize(version, event_instance, headers, status_code) + super(version, headers, status_code) + @event_instance = event_instance + end + + def event + @event_instance + end + + def to_s + "" + end + end + + class EventListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event_instance = payload.body[key].map do |data| + EventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event_instance + @instance + end + end + class EventPage < Page ## # Initialize the EventPage @@ -241,6 +339,54 @@ def to_s '' end end + + class EventPageMetadata < PageMetadata + attr_reader :event_page + + def initialize(version, response, solution, limit) + super(version, response) + @event_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @event_page << EventListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @event_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EventListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event = payload.body[key].map do |data| + EventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event + @event + end + end + class EventInstance < InstanceResource ## # Initialize the EventInstance diff --git a/lib/twilio-ruby/rest/notify/v1/credential.rb b/lib/twilio-ruby/rest/notify/v1/credential.rb index 12cdfb85b..2d764216c 100644 --- a/lib/twilio-ruby/rest/notify/v1/credential.rb +++ b/lib/twilio-ruby/rest/notify/v1/credential.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CredentialInstanceMetadata + # @param [PushService] type + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----` + # @param [String] private_key [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----` + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging. + # @param [String] secret [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging. + # @return [CredentialInstance] Created CredentialInstance + def create_with_metadata( + type: nil, + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'Type' => type, + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialInstance records from the API as a list. @@ -112,6 +161,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -194,7 +265,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code) end ## @@ -216,6 +306,31 @@ def fetch ) end + ## + # Fetch the CredentialInstanceMetadata + # @return [CredentialInstance] Fetched CredentialInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Update the CredentialInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -257,6 +372,53 @@ def update( ) end + ## + # Update the CredentialInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] certificate [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----` + # @param [String] private_key [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----` + # @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. + # @param [String] api_key [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging. + # @param [String] secret [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging. + # @return [CredentialInstance] Updated CredentialInstance + def update_with_metadata( + friendly_name: :unset, + certificate: :unset, + private_key: :unset, + sandbox: :unset, + api_key: :unset, + secret: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Certificate' => certificate, + 'PrivateKey' => private_key, + 'Sandbox' => sandbox, + 'ApiKey' => api_key, + 'Secret' => secret, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + credential_instance = CredentialInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CredentialInstanceMetadata.new( + @version, + credential_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -273,6 +435,45 @@ def inspect end end + class CredentialInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialInstance] credential_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_instance, headers, status_code) + super(version, headers, status_code) + @credential_instance = credential_instance + end + + def credential + @credential_instance + end + + def to_s + "" + end + end + + class CredentialListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_instance = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_instance + @instance + end + end + class CredentialPage < Page ## # Initialize the CredentialPage @@ -301,6 +502,54 @@ def to_s '' end end + + class CredentialPageMetadata < PageMetadata + attr_reader :credential_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_page << CredentialListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential = payload.body[key].map do |data| + CredentialInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential + @credential + end + end + class CredentialInstance < InstanceResource ## # Initialize the CredentialInstance diff --git a/lib/twilio-ruby/rest/notify/v1/service.rb b/lib/twilio-ruby/rest/notify/v1/service.rb index d017720ef..efb90b845 100644 --- a/lib/twilio-ruby/rest/notify/v1/service.rb +++ b/lib/twilio-ruby/rest/notify/v1/service.rb @@ -94,6 +94,76 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] apn_credential_sid The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. + # @param [String] gcm_credential_sid The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. + # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + # @param [String] facebook_messenger_page_id Deprecated. + # @param [String] default_apn_notification_protocol_version The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. + # @param [String] default_gcm_notification_protocol_version The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. + # @param [String] fcm_credential_sid The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings. + # @param [String] default_fcm_notification_protocol_version The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. + # @param [Boolean] log_enabled Whether to log notifications. Can be: `true` or `false` and the default is `true`. + # @param [String] alexa_skill_id Deprecated. + # @param [String] default_alexa_notification_protocol_version Deprecated. + # @param [String] delivery_callback_url URL to send delivery status callback. + # @param [Boolean] delivery_callback_enabled Callback configuration that enables delivery callbacks, default false + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: :unset, + apn_credential_sid: :unset, + gcm_credential_sid: :unset, + messaging_service_sid: :unset, + facebook_messenger_page_id: :unset, + default_apn_notification_protocol_version: :unset, + default_gcm_notification_protocol_version: :unset, + fcm_credential_sid: :unset, + default_fcm_notification_protocol_version: :unset, + log_enabled: :unset, + alexa_skill_id: :unset, + default_alexa_notification_protocol_version: :unset, + delivery_callback_url: :unset, + delivery_callback_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'ApnCredentialSid' => apn_credential_sid, + 'GcmCredentialSid' => gcm_credential_sid, + 'MessagingServiceSid' => messaging_service_sid, + 'FacebookMessengerPageId' => facebook_messenger_page_id, + 'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version, + 'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version, + 'FcmCredentialSid' => fcm_credential_sid, + 'DefaultFcmNotificationProtocolVersion' => default_fcm_notification_protocol_version, + 'LogEnabled' => log_enabled, + 'AlexaSkillId' => alexa_skill_id, + 'DefaultAlexaNotificationProtocolVersion' => default_alexa_notification_protocol_version, + 'DeliveryCallbackUrl' => delivery_callback_url, + 'DeliveryCallbackEnabled' => delivery_callback_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -137,6 +207,30 @@ def stream(friendly_name: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @param [String] friendly_name The string that identifies the Service resources to read. + # @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_with_metadata(friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -223,7 +317,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -245,6 +358,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -310,6 +448,77 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] apn_credential_sid The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. + # @param [String] gcm_credential_sid The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. + # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + # @param [String] facebook_messenger_page_id Deprecated. + # @param [String] default_apn_notification_protocol_version The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. + # @param [String] default_gcm_notification_protocol_version The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. + # @param [String] fcm_credential_sid The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings. + # @param [String] default_fcm_notification_protocol_version The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. + # @param [Boolean] log_enabled Whether to log notifications. Can be: `true` or `false` and the default is `true`. + # @param [String] alexa_skill_id Deprecated. + # @param [String] default_alexa_notification_protocol_version Deprecated. + # @param [String] delivery_callback_url URL to send delivery status callback. + # @param [Boolean] delivery_callback_enabled Callback configuration that enables delivery callbacks, default false + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + friendly_name: :unset, + apn_credential_sid: :unset, + gcm_credential_sid: :unset, + messaging_service_sid: :unset, + facebook_messenger_page_id: :unset, + default_apn_notification_protocol_version: :unset, + default_gcm_notification_protocol_version: :unset, + fcm_credential_sid: :unset, + default_fcm_notification_protocol_version: :unset, + log_enabled: :unset, + alexa_skill_id: :unset, + default_alexa_notification_protocol_version: :unset, + delivery_callback_url: :unset, + delivery_callback_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'ApnCredentialSid' => apn_credential_sid, + 'GcmCredentialSid' => gcm_credential_sid, + 'MessagingServiceSid' => messaging_service_sid, + 'FacebookMessengerPageId' => facebook_messenger_page_id, + 'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version, + 'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version, + 'FcmCredentialSid' => fcm_credential_sid, + 'DefaultFcmNotificationProtocolVersion' => default_fcm_notification_protocol_version, + 'LogEnabled' => log_enabled, + 'AlexaSkillId' => alexa_skill_id, + 'DefaultAlexaNotificationProtocolVersion' => default_alexa_notification_protocol_version, + 'DeliveryCallbackUrl' => delivery_callback_url, + 'DeliveryCallbackEnabled' => delivery_callback_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the notifications # @return [NotificationList] @@ -356,6 +565,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -384,6 +632,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/notify/v1/service/binding.rb b/lib/twilio-ruby/rest/notify/v1/service/binding.rb index 7d8ac055b..dc63fce03 100644 --- a/lib/twilio-ruby/rest/notify/v1/service/binding.rb +++ b/lib/twilio-ruby/rest/notify/v1/service/binding.rb @@ -76,6 +76,56 @@ def create( ) end + ## + # Create the BindingInstanceMetadata + # @param [String] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Up to 20 Bindings can be created for the same Identity in a given Service. + # @param [BindingType] binding_type + # @param [String] address The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format. + # @param [Array[String]] tag A tag that can be used to select the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 20 tags. + # @param [String] notification_protocol_version The protocol version to use to send the notification. This defaults to the value of `default_xxxx_notification_protocol_version` for the protocol in the [Service](https://www.twilio.com/docs/notify/api/service-resource). The current version is `\\\"3\\\"` for `apn`, `fcm`, and `gcm` type Bindings. The parameter is not applicable to `sms` and `facebook-messenger` type Bindings as the data format is fixed. + # @param [String] credential_sid The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applies to only `apn`, `fcm`, and `gcm` type Bindings. + # @param [String] endpoint Deprecated. + # @return [BindingInstance] Created BindingInstance + def create_with_metadata( + identity: nil, + binding_type: nil, + address: nil, + tag: :unset, + notification_protocol_version: :unset, + credential_sid: :unset, + endpoint: :unset + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + 'BindingType' => binding_type, + 'Address' => address, + 'Tag' => Twilio.serialize_list(tag) { |e| e }, + 'NotificationProtocolVersion' => notification_protocol_version, + 'CredentialSid' => credential_sid, + 'Endpoint' => endpoint, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + BindingInstanceMetadata.new( + @version, + binding_instance, + response.headers, + response.status_code + ) + end + ## # Lists BindingInstance records from the API as a list. @@ -131,6 +181,38 @@ def stream(start_date: :unset, end_date: :unset, identity: :unset, tag: :unset, @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BindingPageMetadata records from the API as a list. + # @param [Date] start_date Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`. + # @param [Date] end_date Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`. + # @param [Array[String]] identity The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read. + # @param [Array[String]] tag Only list Bindings that have all of the specified Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed. + # @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_with_metadata(start_date: :unset, end_date: :unset, identity: :unset, tag: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + + 'Tag' => Twilio.serialize_list(tag) { |e| e }, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BindingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BindingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -224,7 +306,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BindingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new(@version, binding_instance, response.headers, response.status_code) end ## @@ -247,6 +348,32 @@ def fetch ) end + ## + # Fetch the BindingInstanceMetadata + # @return [BindingInstance] Fetched BindingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + binding_instance = BindingInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + BindingInstanceMetadata.new( + @version, + binding_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -263,6 +390,45 @@ def inspect end end + class BindingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BindingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BindingInstance] binding_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BindingInstanceMetadata] The initialized instance with metadata. + def initialize(version, binding_instance, headers, status_code) + super(version, headers, status_code) + @binding_instance = binding_instance + end + + def binding + @binding_instance + end + + def to_s + "" + end + end + + class BindingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding_instance = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding_instance + @instance + end + end + class BindingPage < Page ## # Initialize the BindingPage @@ -291,6 +457,54 @@ def to_s '' end end + + class BindingPageMetadata < PageMetadata + attr_reader :binding_page + + def initialize(version, response, solution, limit) + super(version, response) + @binding_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @binding_page << BindingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @binding_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BindingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @binding = payload.body[key].map do |data| + BindingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def binding + @binding + end + end + class BindingInstance < InstanceResource ## # Initialize the BindingInstance diff --git a/lib/twilio-ruby/rest/notify/v1/service/notification.rb b/lib/twilio-ruby/rest/notify/v1/service/notification.rb index 00d7bfa2d..88c4ed5c7 100644 --- a/lib/twilio-ruby/rest/notify/v1/service/notification.rb +++ b/lib/twilio-ruby/rest/notify/v1/service/notification.rb @@ -109,6 +109,89 @@ def create( ) end + ## + # Create the NotificationInstanceMetadata + # @param [String] body The notification text. For FCM and GCM, translates to `data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification. + # @param [Priority] priority + # @param [String] ttl How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property. + # @param [String] title The notification title. For FCM and GCM, this translates to the `data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices. + # @param [String] sound The name of the sound to be played for the notification. For FCM and GCM, this Translates to `data.twi_sound`. For APNS, this translates to `aps.sound`. SMS does not support this property. + # @param [String] action The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels. + # @param [Object] data The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels. + # @param [Object] apn The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. + # @param [Object] gcm The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. See the [GCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref) for more details. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. GCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref). + # @param [Object] sms The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/quickstart) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array. + # @param [Object] facebook_messenger Deprecated. + # @param [Object] fcm The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel. + # @param [Array[String]] segment The Segment resource is deprecated. Use the `tag` parameter, instead. + # @param [Object] alexa Deprecated. + # @param [Array[String]] to_binding The destination address specified as a JSON string. Multiple `to_binding` parameters can be included but the total size of the request entity should not exceed 1MB. This is typically sufficient for 10,000 phone numbers. + # @param [String] delivery_callback_url URL to send webhooks. + # @param [Array[String]] identity The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Delivery will be attempted only to Bindings with an Identity in this list. No more than 20 items are allowed in this list. + # @param [Array[String]] tag A tag that selects the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 5 tags. The implicit tag `all` is available to notify all Bindings in a Service instance. Similarly, the implicit tags `apn`, `fcm`, `gcm`, `sms` and `facebook-messenger` are available to notify all Bindings in a specific channel. + # @return [NotificationInstance] Created NotificationInstance + def create_with_metadata( + body: :unset, + priority: :unset, + ttl: :unset, + title: :unset, + sound: :unset, + action: :unset, + data: :unset, + apn: :unset, + gcm: :unset, + sms: :unset, + facebook_messenger: :unset, + fcm: :unset, + segment: :unset, + alexa: :unset, + to_binding: :unset, + delivery_callback_url: :unset, + identity: :unset, + tag: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'Priority' => priority, + 'Ttl' => ttl, + 'Title' => title, + 'Sound' => sound, + 'Action' => action, + 'Data' => Twilio.serialize_object(data), + 'Apn' => Twilio.serialize_object(apn), + 'Gcm' => Twilio.serialize_object(gcm), + 'Sms' => Twilio.serialize_object(sms), + 'FacebookMessenger' => Twilio.serialize_object(facebook_messenger), + 'Fcm' => Twilio.serialize_object(fcm), + 'Segment' => Twilio.serialize_list(segment) { |e| e }, + 'Alexa' => Twilio.serialize_object(alexa), + 'ToBinding' => Twilio.serialize_list(to_binding) { |e| e }, + 'DeliveryCallbackUrl' => delivery_callback_url, + 'Identity' => Twilio.serialize_list(identity) { |e| e }, + 'Tag' => Twilio.serialize_list(tag) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + notification_instance = NotificationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + NotificationInstanceMetadata.new( + @version, + notification_instance, + response.headers, + response.status_code + ) + end + @@ -146,6 +229,54 @@ def to_s '' end end + + class NotificationPageMetadata < PageMetadata + attr_reader :notification_page + + def initialize(version, response, solution, limit) + super(version, response) + @notification_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @notification_page << NotificationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @notification_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NotificationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification + @notification + end + end + class NotificationInstance < InstanceResource ## # Initialize the NotificationInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/bulk_eligibility.rb b/lib/twilio-ruby/rest/numbers/v1/bulk_eligibility.rb index c0a78014a..b441a9f7e 100644 --- a/lib/twilio-ruby/rest/numbers/v1/bulk_eligibility.rb +++ b/lib/twilio-ruby/rest/numbers/v1/bulk_eligibility.rb @@ -50,6 +50,32 @@ def create(body: :unset ) end + ## + # Create the BulkEligibilityInstanceMetadata + # @param [Object] body + # @return [BulkEligibilityInstance] Created BulkEligibilityInstance + def create_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: body.to_json) + bulkEligibility_instance = BulkEligibilityInstance.new( + @version, + response.body, + ) + BulkEligibilityInstanceMetadata.new( + @version, + bulkEligibility_instance, + response.headers, + response.status_code + ) + end + @@ -94,6 +120,31 @@ def fetch ) end + ## + # Fetch the BulkEligibilityInstanceMetadata + # @return [BulkEligibilityInstance] Fetched BulkEligibilityInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + bulkEligibility_instance = BulkEligibilityInstance.new( + @version, + response.body, + request_id: @solution[:request_id], + ) + BulkEligibilityInstanceMetadata.new( + @version, + bulkEligibility_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -110,6 +161,45 @@ def inspect end end + class BulkEligibilityInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BulkEligibilityInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BulkEligibilityInstance] bulk_eligibility_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BulkEligibilityInstanceMetadata] The initialized instance with metadata. + def initialize(version, bulk_eligibility_instance, headers, status_code) + super(version, headers, status_code) + @bulk_eligibility_instance = bulk_eligibility_instance + end + + def bulk_eligibility + @bulk_eligibility_instance + end + + def to_s + "" + end + end + + class BulkEligibilityListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bulk_eligibility_instance = payload.body[key].map do |data| + BulkEligibilityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bulk_eligibility_instance + @instance + end + end + class BulkEligibilityPage < Page ## # Initialize the BulkEligibilityPage @@ -138,6 +228,54 @@ def to_s '' end end + + class BulkEligibilityPageMetadata < PageMetadata + attr_reader :bulk_eligibility_page + + def initialize(version, response, solution, limit) + super(version, response) + @bulk_eligibility_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bulk_eligibility_page << BulkEligibilityListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bulk_eligibility_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BulkEligibilityListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bulk_eligibility = payload.body[key].map do |data| + BulkEligibilityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bulk_eligibility + @bulk_eligibility + end + end + class BulkEligibilityInstance < InstanceResource ## # Initialize the BulkEligibilityInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/eligibility.rb b/lib/twilio-ruby/rest/numbers/v1/eligibility.rb index 184574257..27d5eb6ef 100644 --- a/lib/twilio-ruby/rest/numbers/v1/eligibility.rb +++ b/lib/twilio-ruby/rest/numbers/v1/eligibility.rb @@ -50,6 +50,32 @@ def create(body: :unset ) end + ## + # Create the EligibilityInstanceMetadata + # @param [Object] body + # @return [EligibilityInstance] Created EligibilityInstance + def create_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: body.to_json) + eligibility_instance = EligibilityInstance.new( + @version, + response.body, + ) + EligibilityInstanceMetadata.new( + @version, + eligibility_instance, + response.headers, + response.status_code + ) + end + @@ -87,6 +113,54 @@ def to_s '' end end + + class EligibilityPageMetadata < PageMetadata + attr_reader :eligibility_page + + def initialize(version, response, solution, limit) + super(version, response) + @eligibility_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @eligibility_page << EligibilityListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @eligibility_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EligibilityListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @eligibility = payload.body[key].map do |data| + EligibilityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def eligibility + @eligibility + end + end + class EligibilityInstance < InstanceResource ## # Initialize the EligibilityInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/porting_all_port_in.rb b/lib/twilio-ruby/rest/numbers/v1/porting_all_port_in.rb index d310fd6e4..7e098055a 100644 --- a/lib/twilio-ruby/rest/numbers/v1/porting_all_port_in.rb +++ b/lib/twilio-ruby/rest/numbers/v1/porting_all_port_in.rb @@ -93,6 +93,40 @@ def stream(token: :unset, size: :unset, port_in_request_sid: :unset, port_in_req @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PortingAllPortInPageMetadata records from the API as a list. + # @param [String] token Page start token, if null then it will start from the beginning + # @param [String] size Number of items per page + # @param [String] port_in_request_sid Filter by Port in request SID, supports multiple values separated by comma + # @param [String] port_in_request_status Filter by Port In request status + # @param [String] created_before Find all created before a certain date + # @param [String] created_after Find all created after a certain date + # @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_with_metadata(token: :unset, size: :unset, port_in_request_sid: :unset, port_in_request_status: :unset, created_before: :unset, created_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Token' => token, + 'Size' => size, + 'PortInRequestSid' => port_in_request_sid, + 'PortInRequestStatus' => port_in_request_status, + 'CreatedBefore' => created_before, + 'CreatedAfter' => created_after, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PortingAllPortInPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PortingAllPortInInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -190,6 +224,54 @@ def to_s '' end end + + class PortingAllPortInPageMetadata < PageMetadata + attr_reader :porting_all_port_in_page + + def initialize(version, response, solution, limit) + super(version, response) + @porting_all_port_in_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @porting_all_port_in_page << PortingAllPortInListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @porting_all_port_in_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PortingAllPortInListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_all_port_in = payload.body[key].map do |data| + PortingAllPortInInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_all_port_in + @porting_all_port_in + end + end + class PortingAllPortInInstance < InstanceResource ## # Initialize the PortingAllPortInInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/porting_port_in.rb b/lib/twilio-ruby/rest/numbers/v1/porting_port_in.rb index ae39eb754..fb5262502 100644 --- a/lib/twilio-ruby/rest/numbers/v1/porting_port_in.rb +++ b/lib/twilio-ruby/rest/numbers/v1/porting_port_in.rb @@ -138,6 +138,32 @@ def create(numbers_v1_porting_port_in_create: nil ) end + ## + # Create the PortingPortInInstanceMetadata + # @param [NumbersV1PortingPortInCreate] numbers_v1_porting_port_in_create + # @return [PortingPortInInstance] Created PortingPortInInstance + def create_with_metadata(numbers_v1_porting_port_in_create: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: numbers_v1_porting_port_in_create.to_json) + portingPortIn_instance = PortingPortInInstance.new( + @version, + response.body, + ) + PortingPortInInstanceMetadata.new( + @version, + portingPortIn_instance, + response.headers, + response.status_code + ) + end + @@ -172,7 +198,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PortingPortInInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + portingPortIn_instance = PortingPortInInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PortingPortInInstanceMetadata.new(@version, portingPortIn_instance, response.headers, response.status_code) end ## @@ -194,6 +239,31 @@ def fetch ) end + ## + # Fetch the PortingPortInInstanceMetadata + # @return [PortingPortInInstance] Fetched PortingPortInInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + portingPortIn_instance = PortingPortInInstance.new( + @version, + response.body, + port_in_request_sid: @solution[:port_in_request_sid], + ) + PortingPortInInstanceMetadata.new( + @version, + portingPortIn_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -210,6 +280,45 @@ def inspect end end + class PortingPortInInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PortingPortInInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PortingPortInInstance] porting_port_in_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PortingPortInInstanceMetadata] The initialized instance with metadata. + def initialize(version, porting_port_in_instance, headers, status_code) + super(version, headers, status_code) + @porting_port_in_instance = porting_port_in_instance + end + + def porting_port_in + @porting_port_in_instance + end + + def to_s + "" + end + end + + class PortingPortInListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_port_in_instance = payload.body[key].map do |data| + PortingPortInInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_port_in_instance + @instance + end + end + class PortingPortInPage < Page ## # Initialize the PortingPortInPage @@ -238,6 +347,54 @@ def to_s '' end end + + class PortingPortInPageMetadata < PageMetadata + attr_reader :porting_port_in_page + + def initialize(version, response, solution, limit) + super(version, response) + @porting_port_in_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @porting_port_in_page << PortingPortInListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @porting_port_in_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PortingPortInListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_port_in = payload.body[key].map do |data| + PortingPortInInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_port_in + @porting_port_in + end + end + class PortingPortInInstance < InstanceResource ## # Initialize the PortingPortInInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/porting_port_in_phone_number.rb b/lib/twilio-ruby/rest/numbers/v1/porting_port_in_phone_number.rb index b36b20d56..0e0119cd4 100644 --- a/lib/twilio-ruby/rest/numbers/v1/porting_port_in_phone_number.rb +++ b/lib/twilio-ruby/rest/numbers/v1/porting_port_in_phone_number.rb @@ -65,7 +65,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PortingPortInPhoneNumberInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + portingPortInPhoneNumber_instance = PortingPortInPhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PortingPortInPhoneNumberInstanceMetadata.new(@version, portingPortInPhoneNumber_instance, response.headers, response.status_code) end ## @@ -88,6 +107,32 @@ def fetch ) end + ## + # Fetch the PortingPortInPhoneNumberInstanceMetadata + # @return [PortingPortInPhoneNumberInstance] Fetched PortingPortInPhoneNumberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + portingPortInPhoneNumber_instance = PortingPortInPhoneNumberInstance.new( + @version, + response.body, + port_in_request_sid: @solution[:port_in_request_sid], + phone_number_sid: @solution[:phone_number_sid], + ) + PortingPortInPhoneNumberInstanceMetadata.new( + @version, + portingPortInPhoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -104,6 +149,45 @@ def inspect end end + class PortingPortInPhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PortingPortInPhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PortingPortInPhoneNumberInstance] porting_port_in_phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PortingPortInPhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, porting_port_in_phone_number_instance, headers, status_code) + super(version, headers, status_code) + @porting_port_in_phone_number_instance = porting_port_in_phone_number_instance + end + + def porting_port_in_phone_number + @porting_port_in_phone_number_instance + end + + def to_s + "" + end + end + + class PortingPortInPhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_port_in_phone_number_instance = payload.body[key].map do |data| + PortingPortInPhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_port_in_phone_number_instance + @instance + end + end + class PortingPortInPhoneNumberPage < Page ## # Initialize the PortingPortInPhoneNumberPage @@ -132,6 +216,54 @@ def to_s '' end end + + class PortingPortInPhoneNumberPageMetadata < PageMetadata + attr_reader :porting_port_in_phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @porting_port_in_phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @porting_port_in_phone_number_page << PortingPortInPhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @porting_port_in_phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PortingPortInPhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_port_in_phone_number = payload.body[key].map do |data| + PortingPortInPhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_port_in_phone_number + @porting_port_in_phone_number + end + end + class PortingPortInPhoneNumberInstance < InstanceResource ## # Initialize the PortingPortInPhoneNumberInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/porting_portability.rb b/lib/twilio-ruby/rest/numbers/v1/porting_portability.rb index 6255b8163..71bbc4346 100644 --- a/lib/twilio-ruby/rest/numbers/v1/porting_portability.rb +++ b/lib/twilio-ruby/rest/numbers/v1/porting_portability.rb @@ -83,6 +83,40 @@ def fetch( ) end + ## + # Fetch the PortingPortabilityInstanceMetadata + # @param [String] target_account_sid Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + # @param [String] address_sid Address Sid of customer to which the number will be ported. + # @return [PortingPortabilityInstance] Fetched PortingPortabilityInstance + def fetch_with_metadata( + target_account_sid: :unset, + address_sid: :unset + ) + + params = Twilio::Values.of({ + 'TargetAccountSid' => target_account_sid, + 'AddressSid' => address_sid, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + portingPortability_instance = PortingPortabilityInstance.new( + @version, + response.body, + phone_number: @solution[:phone_number], + ) + PortingPortabilityInstanceMetadata.new( + @version, + portingPortability_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -99,6 +133,45 @@ def inspect end end + class PortingPortabilityInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PortingPortabilityInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PortingPortabilityInstance] porting_portability_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PortingPortabilityInstanceMetadata] The initialized instance with metadata. + def initialize(version, porting_portability_instance, headers, status_code) + super(version, headers, status_code) + @porting_portability_instance = porting_portability_instance + end + + def porting_portability + @porting_portability_instance + end + + def to_s + "" + end + end + + class PortingPortabilityListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_portability_instance = payload.body[key].map do |data| + PortingPortabilityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_portability_instance + @instance + end + end + class PortingPortabilityPage < Page ## # Initialize the PortingPortabilityPage @@ -127,6 +200,54 @@ def to_s '' end end + + class PortingPortabilityPageMetadata < PageMetadata + attr_reader :porting_portability_page + + def initialize(version, response, solution, limit) + super(version, response) + @porting_portability_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @porting_portability_page << PortingPortabilityListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @porting_portability_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PortingPortabilityListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_portability = payload.body[key].map do |data| + PortingPortabilityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_portability + @porting_portability + end + end + class PortingPortabilityInstance < InstanceResource ## # Initialize the PortingPortabilityInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration.rb b/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration.rb index 94df5d1bb..827444e94 100644 --- a/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration.rb +++ b/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration.rb @@ -50,6 +50,32 @@ def create(body: :unset ) end + ## + # Create the PortingWebhookConfigurationInstanceMetadata + # @param [Object] body + # @return [PortingWebhookConfigurationInstance] Created PortingWebhookConfigurationInstance + def create_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: body.to_json) + portingWebhookConfiguration_instance = PortingWebhookConfigurationInstance.new( + @version, + response.body, + ) + PortingWebhookConfigurationInstanceMetadata.new( + @version, + portingWebhookConfiguration_instance, + response.headers, + response.status_code + ) + end + @@ -87,6 +113,54 @@ def to_s '' end end + + class PortingWebhookConfigurationPageMetadata < PageMetadata + attr_reader :porting_webhook_configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @porting_webhook_configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @porting_webhook_configuration_page << PortingWebhookConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @porting_webhook_configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PortingWebhookConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_webhook_configuration = payload.body[key].map do |data| + PortingWebhookConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_webhook_configuration + @porting_webhook_configuration + end + end + class PortingWebhookConfigurationInstance < InstanceResource ## # Initialize the PortingWebhookConfigurationInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration_delete.rb b/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration_delete.rb index 30fd27836..05d42bd3d 100644 --- a/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration_delete.rb +++ b/lib/twilio-ruby/rest/numbers/v1/porting_webhook_configuration_delete.rb @@ -64,7 +64,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PortingWebhookConfigurationDeleteInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + portingWebhookConfigurationDelete_instance = PortingWebhookConfigurationDeleteInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PortingWebhookConfigurationDeleteInstanceMetadata.new(@version, portingWebhookConfigurationDelete_instance, response.headers, response.status_code) end @@ -83,6 +102,45 @@ def inspect end end + class PortingWebhookConfigurationDeleteInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PortingWebhookConfigurationDeleteInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PortingWebhookConfigurationDeleteInstance] porting_webhook_configuration_delete_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PortingWebhookConfigurationDeleteInstanceMetadata] The initialized instance with metadata. + def initialize(version, porting_webhook_configuration_delete_instance, headers, status_code) + super(version, headers, status_code) + @porting_webhook_configuration_delete_instance = porting_webhook_configuration_delete_instance + end + + def porting_webhook_configuration_delete + @porting_webhook_configuration_delete_instance + end + + def to_s + "" + end + end + + class PortingWebhookConfigurationDeleteListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_webhook_configuration_delete_instance = payload.body[key].map do |data| + PortingWebhookConfigurationDeleteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_webhook_configuration_delete_instance + @instance + end + end + class PortingWebhookConfigurationDeletePage < Page ## # Initialize the PortingWebhookConfigurationDeletePage @@ -111,6 +169,54 @@ def to_s '' end end + + class PortingWebhookConfigurationDeletePageMetadata < PageMetadata + attr_reader :porting_webhook_configuration_delete_page + + def initialize(version, response, solution, limit) + super(version, response) + @porting_webhook_configuration_delete_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @porting_webhook_configuration_delete_page << PortingWebhookConfigurationDeleteListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @porting_webhook_configuration_delete_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PortingWebhookConfigurationDeleteListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @porting_webhook_configuration_delete = payload.body[key].map do |data| + PortingWebhookConfigurationDeleteInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def porting_webhook_configuration_delete + @porting_webhook_configuration_delete + end + end + class PortingWebhookConfigurationDeleteInstance < InstanceResource ## # Initialize the PortingWebhookConfigurationDeleteInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/signing_request_configuration.rb b/lib/twilio-ruby/rest/numbers/v1/signing_request_configuration.rb index ee33d7dd7..4eb162f4d 100644 --- a/lib/twilio-ruby/rest/numbers/v1/signing_request_configuration.rb +++ b/lib/twilio-ruby/rest/numbers/v1/signing_request_configuration.rb @@ -50,6 +50,32 @@ def create(body: :unset ) end + ## + # Create the SigningRequestConfigurationInstanceMetadata + # @param [Object] body + # @return [SigningRequestConfigurationInstance] Created SigningRequestConfigurationInstance + def create_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: body.to_json) + signingRequestConfiguration_instance = SigningRequestConfigurationInstance.new( + @version, + response.body, + ) + SigningRequestConfigurationInstanceMetadata.new( + @version, + signingRequestConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Lists SigningRequestConfigurationInstance records from the API as a list. @@ -97,6 +123,32 @@ def stream(country: :unset, product: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SigningRequestConfigurationPageMetadata records from the API as a list. + # @param [String] country The country ISO code to apply this configuration, this is an optional field, Example: US, MX + # @param [String] product The product or service for which is requesting the signature, this is an optional field, Example: Porting, Hosting + # @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_with_metadata(country: :unset, product: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Country' => country, + 'Product' => product, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SigningRequestConfigurationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SigningRequestConfigurationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,6 +238,54 @@ def to_s '' end end + + class SigningRequestConfigurationPageMetadata < PageMetadata + attr_reader :signing_request_configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @signing_request_configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @signing_request_configuration_page << SigningRequestConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @signing_request_configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SigningRequestConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @signing_request_configuration = payload.body[key].map do |data| + SigningRequestConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def signing_request_configuration + @signing_request_configuration + end + end + class SigningRequestConfigurationInstance < InstanceResource ## # Initialize the SigningRequestConfigurationInstance diff --git a/lib/twilio-ruby/rest/numbers/v1/webhook.rb b/lib/twilio-ruby/rest/numbers/v1/webhook.rb index 16aa57d57..11bde7cd7 100644 --- a/lib/twilio-ruby/rest/numbers/v1/webhook.rb +++ b/lib/twilio-ruby/rest/numbers/v1/webhook.rb @@ -48,6 +48,30 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + @@ -85,6 +109,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/application.rb b/lib/twilio-ruby/rest/numbers/v2/application.rb index 296756b5b..0e93a8981 100644 --- a/lib/twilio-ruby/rest/numbers/v2/application.rb +++ b/lib/twilio-ruby/rest/numbers/v2/application.rb @@ -99,6 +99,32 @@ def create(create_short_code_application_request: nil ) end + ## + # Create the ApplicationInstanceMetadata + # @param [CreateShortCodeApplicationRequest] create_short_code_application_request + # @return [ApplicationInstance] Created ApplicationInstance + def create_with_metadata(create_short_code_application_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: create_short_code_application_request.to_json) + application_instance = ApplicationInstance.new( + @version, + response.body, + ) + ApplicationInstanceMetadata.new( + @version, + application_instance, + response.headers, + response.status_code + ) + end + ## # Lists ApplicationInstance records from the API as a list. @@ -138,6 +164,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ApplicationPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ApplicationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ApplicationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -230,6 +278,31 @@ def fetch ) end + ## + # Fetch the ApplicationInstanceMetadata + # @return [ApplicationInstance] Fetched ApplicationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + application_instance = ApplicationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ApplicationInstanceMetadata.new( + @version, + application_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -246,6 +319,45 @@ def inspect end end + class ApplicationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ApplicationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ApplicationInstance] application_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ApplicationInstanceMetadata] The initialized instance with metadata. + def initialize(version, application_instance, headers, status_code) + super(version, headers, status_code) + @application_instance = application_instance + end + + def application + @application_instance + end + + def to_s + "" + end + end + + class ApplicationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @application_instance = payload.body[key].map do |data| + ApplicationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def application_instance + @instance + end + end + class ApplicationPage < Page ## # Initialize the ApplicationPage @@ -274,6 +386,54 @@ def to_s '' end end + + class ApplicationPageMetadata < PageMetadata + attr_reader :application_page + + def initialize(version, response, solution, limit) + super(version, response) + @application_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @application_page << ApplicationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @application_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ApplicationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @application = payload.body[key].map do |data| + ApplicationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def application + @application + end + end + class ApplicationInstance < InstanceResource ## # Initialize the ApplicationInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/authorization_document.rb b/lib/twilio-ruby/rest/numbers/v2/authorization_document.rb index 0f1c078cb..33a58d4fd 100644 --- a/lib/twilio-ruby/rest/numbers/v2/authorization_document.rb +++ b/lib/twilio-ruby/rest/numbers/v2/authorization_document.rb @@ -70,6 +70,52 @@ def create( ) end + ## + # Create the AuthorizationDocumentInstanceMetadata + # @param [String] address_sid A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument. + # @param [String] email Email that this AuthorizationDocument will be sent to for signing. + # @param [String] contact_phone_number The contact phone number of the person authorized to sign the Authorization Document. + # @param [Array[String]] hosted_number_order_sids A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform. + # @param [String] contact_title The title of the person authorized to sign the Authorization Document for this phone number. + # @param [Array[String]] cc_emails Email recipients who will be informed when an Authorization Document has been sent and signed. + # @return [AuthorizationDocumentInstance] Created AuthorizationDocumentInstance + def create_with_metadata( + address_sid: nil, + email: nil, + contact_phone_number: nil, + hosted_number_order_sids: nil, + contact_title: :unset, + cc_emails: :unset + ) + + data = Twilio::Values.of({ + 'AddressSid' => address_sid, + 'Email' => email, + 'ContactPhoneNumber' => contact_phone_number, + 'HostedNumberOrderSids' => Twilio.serialize_list(hosted_number_order_sids) { |e| e }, + 'ContactTitle' => contact_title, + 'CcEmails' => Twilio.serialize_list(cc_emails) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + authorizationDocument_instance = AuthorizationDocumentInstance.new( + @version, + response.body, + ) + AuthorizationDocumentInstanceMetadata.new( + @version, + authorizationDocument_instance, + response.headers, + response.status_code + ) + end + ## # Lists AuthorizationDocumentInstance records from the API as a list. @@ -117,6 +163,32 @@ def stream(email: :unset, status: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AuthorizationDocumentPageMetadata records from the API as a list. + # @param [String] email Email that this AuthorizationDocument will be sent to for signing. + # @param [Status] status Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + # @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_with_metadata(email: :unset, status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Email' => email, + 'Status' => status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AuthorizationDocumentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AuthorizationDocumentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -204,7 +276,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AuthorizationDocumentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + authorizationDocument_instance = AuthorizationDocumentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AuthorizationDocumentInstanceMetadata.new(@version, authorizationDocument_instance, response.headers, response.status_code) end ## @@ -226,6 +317,31 @@ def fetch ) end + ## + # Fetch the AuthorizationDocumentInstanceMetadata + # @return [AuthorizationDocumentInstance] Fetched AuthorizationDocumentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + authorizationDocument_instance = AuthorizationDocumentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AuthorizationDocumentInstanceMetadata.new( + @version, + authorizationDocument_instance, + response.headers, + response.status_code + ) + end + ## # Access the dependent_hosted_number_orders # @return [DependentHostedNumberOrderList] @@ -253,6 +369,45 @@ def inspect end end + class AuthorizationDocumentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AuthorizationDocumentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AuthorizationDocumentInstance] authorization_document_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AuthorizationDocumentInstanceMetadata] The initialized instance with metadata. + def initialize(version, authorization_document_instance, headers, status_code) + super(version, headers, status_code) + @authorization_document_instance = authorization_document_instance + end + + def authorization_document + @authorization_document_instance + end + + def to_s + "" + end + end + + class AuthorizationDocumentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorization_document_instance = payload.body[key].map do |data| + AuthorizationDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorization_document_instance + @instance + end + end + class AuthorizationDocumentPage < Page ## # Initialize the AuthorizationDocumentPage @@ -281,6 +436,54 @@ def to_s '' end end + + class AuthorizationDocumentPageMetadata < PageMetadata + attr_reader :authorization_document_page + + def initialize(version, response, solution, limit) + super(version, response) + @authorization_document_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @authorization_document_page << AuthorizationDocumentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @authorization_document_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthorizationDocumentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorization_document = payload.body[key].map do |data| + AuthorizationDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorization_document + @authorization_document + end + end + class AuthorizationDocumentInstance < InstanceResource ## # Initialize the AuthorizationDocumentInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/authorization_document/dependent_hosted_number_order.rb b/lib/twilio-ruby/rest/numbers/v2/authorization_document/dependent_hosted_number_order.rb index ad2cbbb4d..b57fd50e8 100644 --- a/lib/twilio-ruby/rest/numbers/v2/authorization_document/dependent_hosted_number_order.rb +++ b/lib/twilio-ruby/rest/numbers/v2/authorization_document/dependent_hosted_number_order.rb @@ -87,6 +87,36 @@ def stream(status: :unset, phone_number: :unset, incoming_phone_number_sid: :uns @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DependentHostedNumberOrderPageMetadata records from the API as a list. + # @param [Status] status Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + # @param [String] phone_number An E164 formatted phone number hosted by this HostedNumberOrder. + # @param [String] incoming_phone_number_sid A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + # @param [String] friendly_name A human readable description of this resource, up to 128 characters. + # @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_with_metadata(status: :unset, phone_number: :unset, incoming_phone_number_sid: :unset, friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'PhoneNumber' => phone_number, + 'IncomingPhoneNumberSid' => incoming_phone_number_sid, + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DependentHostedNumberOrderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DependentHostedNumberOrderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,6 +210,54 @@ def to_s '' end end + + class DependentHostedNumberOrderPageMetadata < PageMetadata + attr_reader :dependent_hosted_number_order_page + + def initialize(version, response, solution, limit) + super(version, response) + @dependent_hosted_number_order_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @dependent_hosted_number_order_page << DependentHostedNumberOrderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @dependent_hosted_number_order_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DependentHostedNumberOrderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @dependent_hosted_number_order = payload.body[key].map do |data| + DependentHostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def dependent_hosted_number_order + @dependent_hosted_number_order + end + end + class DependentHostedNumberOrderInstance < InstanceResource ## # Initialize the DependentHostedNumberOrderInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/bulk_hosted_number_order.rb b/lib/twilio-ruby/rest/numbers/v2/bulk_hosted_number_order.rb index 2d08b4acc..78f1374e5 100644 --- a/lib/twilio-ruby/rest/numbers/v2/bulk_hosted_number_order.rb +++ b/lib/twilio-ruby/rest/numbers/v2/bulk_hosted_number_order.rb @@ -50,6 +50,32 @@ def create(body: :unset ) end + ## + # Create the BulkHostedNumberOrderInstanceMetadata + # @param [Object] body + # @return [BulkHostedNumberOrderInstance] Created BulkHostedNumberOrderInstance + def create_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: body.to_json) + bulkHostedNumberOrder_instance = BulkHostedNumberOrderInstance.new( + @version, + response.body, + ) + BulkHostedNumberOrderInstanceMetadata.new( + @version, + bulkHostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + @@ -100,6 +126,37 @@ def fetch( ) end + ## + # Fetch the BulkHostedNumberOrderInstanceMetadata + # @param [String] order_status Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'. + # @return [BulkHostedNumberOrderInstance] Fetched BulkHostedNumberOrderInstance + def fetch_with_metadata( + order_status: :unset + ) + + params = Twilio::Values.of({ + 'OrderStatus' => order_status, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + bulkHostedNumberOrder_instance = BulkHostedNumberOrderInstance.new( + @version, + response.body, + bulk_hosting_sid: @solution[:bulk_hosting_sid], + ) + BulkHostedNumberOrderInstanceMetadata.new( + @version, + bulkHostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -116,6 +173,45 @@ def inspect end end + class BulkHostedNumberOrderInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BulkHostedNumberOrderInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BulkHostedNumberOrderInstance] bulk_hosted_number_order_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BulkHostedNumberOrderInstanceMetadata] The initialized instance with metadata. + def initialize(version, bulk_hosted_number_order_instance, headers, status_code) + super(version, headers, status_code) + @bulk_hosted_number_order_instance = bulk_hosted_number_order_instance + end + + def bulk_hosted_number_order + @bulk_hosted_number_order_instance + end + + def to_s + "" + end + end + + class BulkHostedNumberOrderListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bulk_hosted_number_order_instance = payload.body[key].map do |data| + BulkHostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bulk_hosted_number_order_instance + @instance + end + end + class BulkHostedNumberOrderPage < Page ## # Initialize the BulkHostedNumberOrderPage @@ -144,6 +240,54 @@ def to_s '' end end + + class BulkHostedNumberOrderPageMetadata < PageMetadata + attr_reader :bulk_hosted_number_order_page + + def initialize(version, response, solution, limit) + super(version, response) + @bulk_hosted_number_order_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bulk_hosted_number_order_page << BulkHostedNumberOrderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bulk_hosted_number_order_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BulkHostedNumberOrderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bulk_hosted_number_order = payload.body[key].map do |data| + BulkHostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bulk_hosted_number_order + @bulk_hosted_number_order + end + end + class BulkHostedNumberOrderInstance < InstanceResource ## # Initialize the BulkHostedNumberOrderInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/bundle_clone.rb b/lib/twilio-ruby/rest/numbers/v2/bundle_clone.rb index 8ebb378f9..c7462f8d7 100644 --- a/lib/twilio-ruby/rest/numbers/v2/bundle_clone.rb +++ b/lib/twilio-ruby/rest/numbers/v2/bundle_clone.rb @@ -87,6 +87,44 @@ def create( ) end + ## + # Create the BundleCloneInstanceMetadata + # @param [String] target_account_sid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) where the bundle needs to be cloned. + # @param [Boolean] move_to_draft If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved + # @param [String] friendly_name The string that you assigned to describe the cloned bundle. + # @return [BundleCloneInstance] Created BundleCloneInstance + def create_with_metadata( + target_account_sid: nil, + move_to_draft: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'TargetAccountSid' => target_account_sid, + 'MoveToDraft' => move_to_draft, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + bundleClone_instance = BundleCloneInstance.new( + @version, + response.body, + bundle_sid: @solution[:bundle_sid], + ) + BundleCloneInstanceMetadata.new( + @version, + bundleClone_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -103,6 +141,45 @@ def inspect end end + class BundleCloneInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BundleCloneInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BundleCloneInstance] bundle_clone_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BundleCloneInstanceMetadata] The initialized instance with metadata. + def initialize(version, bundle_clone_instance, headers, status_code) + super(version, headers, status_code) + @bundle_clone_instance = bundle_clone_instance + end + + def bundle_clone + @bundle_clone_instance + end + + def to_s + "" + end + end + + class BundleCloneListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bundle_clone_instance = payload.body[key].map do |data| + BundleCloneInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bundle_clone_instance + @instance + end + end + class BundleClonePage < Page ## # Initialize the BundleClonePage @@ -131,6 +208,54 @@ def to_s '' end end + + class BundleClonePageMetadata < PageMetadata + attr_reader :bundle_clone_page + + def initialize(version, response, solution, limit) + super(version, response) + @bundle_clone_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bundle_clone_page << BundleCloneListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bundle_clone_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BundleCloneListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bundle_clone = payload.body[key].map do |data| + BundleCloneInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bundle_clone + @bundle_clone + end + end + class BundleCloneInstance < InstanceResource ## # Initialize the BundleCloneInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/hosted_number_order.rb b/lib/twilio-ruby/rest/numbers/v2/hosted_number_order.rb index 5604f70d8..8559bcd39 100644 --- a/lib/twilio-ruby/rest/numbers/v2/hosted_number_order.rb +++ b/lib/twilio-ruby/rest/numbers/v2/hosted_number_order.rb @@ -100,6 +100,82 @@ def create( ) end + ## + # Create the HostedNumberOrderInstanceMetadata + # @param [String] phone_number The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format + # @param [String] contact_phone_number The contact phone number of the person authorized to sign the Authorization Document. + # @param [String] address_sid Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. + # @param [String] email Optional. Email of the owner of this phone number that is being hosted. + # @param [String] account_sid This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to. + # @param [String] friendly_name A 128 character string that is a human readable text that describes this resource. + # @param [Array[String]] cc_emails Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to. + # @param [String] sms_url The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_method The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_fallback_url A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource. + # @param [Boolean] sms_capability Used to specify that the SMS capability will be hosted on Twilio's platform. + # @param [String] sms_fallback_method The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] status_callback_url Optional. The Status Callback URL attached to the IncomingPhoneNumber resource. + # @param [String] status_callback_method Optional. The Status Callback Method attached to the IncomingPhoneNumber resource. + # @param [String] sms_application_sid Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application. + # @param [String] contact_title The title of the person authorized to sign the Authorization Document for this phone number. + # @return [HostedNumberOrderInstance] Created HostedNumberOrderInstance + def create_with_metadata( + phone_number: nil, + contact_phone_number: nil, + address_sid: nil, + email: nil, + account_sid: :unset, + friendly_name: :unset, + cc_emails: :unset, + sms_url: :unset, + sms_method: :unset, + sms_fallback_url: :unset, + sms_capability: :unset, + sms_fallback_method: :unset, + status_callback_url: :unset, + status_callback_method: :unset, + sms_application_sid: :unset, + contact_title: :unset + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + 'ContactPhoneNumber' => contact_phone_number, + 'AddressSid' => address_sid, + 'Email' => email, + 'AccountSid' => account_sid, + 'FriendlyName' => friendly_name, + 'CcEmails' => Twilio.serialize_list(cc_emails) { |e| e }, + 'SmsUrl' => sms_url, + 'SmsMethod' => sms_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsCapability' => sms_capability, + 'SmsFallbackMethod' => sms_fallback_method, + 'StatusCallbackUrl' => status_callback_url, + 'StatusCallbackMethod' => status_callback_method, + 'SmsApplicationSid' => sms_application_sid, + 'ContactTitle' => contact_title, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + ) + HostedNumberOrderInstanceMetadata.new( + @version, + hostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + ## # Lists HostedNumberOrderInstance records from the API as a list. @@ -159,6 +235,38 @@ def stream(status: :unset, sms_capability: :unset, phone_number: :unset, incomin @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists HostedNumberOrderPageMetadata records from the API as a list. + # @param [Status] status The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + # @param [Boolean] sms_capability Whether the SMS capability will be hosted on our platform. Can be `true` of `false`. + # @param [String] phone_number An E164 formatted phone number hosted by this HostedNumberOrder. + # @param [String] incoming_phone_number_sid A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + # @param [String] friendly_name A human readable description of this resource, up to 128 characters. + # @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_with_metadata(status: :unset, sms_capability: :unset, phone_number: :unset, incoming_phone_number_sid: :unset, friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'SmsCapability' => sms_capability, + 'PhoneNumber' => phone_number, + 'IncomingPhoneNumberSid' => incoming_phone_number_sid, + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + HostedNumberOrderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields HostedNumberOrderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -251,7 +359,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the HostedNumberOrderInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + HostedNumberOrderInstanceMetadata.new(@version, hostedNumberOrder_instance, response.headers, response.status_code) end ## @@ -273,6 +400,31 @@ def fetch ) end + ## + # Fetch the HostedNumberOrderInstanceMetadata + # @return [HostedNumberOrderInstance] Fetched HostedNumberOrderInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + HostedNumberOrderInstanceMetadata.new( + @version, + hostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + ## # Update the HostedNumberOrderInstance # @param [Status] status @@ -305,6 +457,44 @@ def update( ) end + ## + # Update the HostedNumberOrderInstanceMetadata + # @param [Status] status + # @param [String] verification_call_delay The number of seconds to wait before initiating the ownership verification call. Can be a value between 0 and 60, inclusive. + # @param [String] verification_call_extension The numerical extension to dial when making the ownership verification call. + # @return [HostedNumberOrderInstance] Updated HostedNumberOrderInstance + def update_with_metadata( + status: nil, + verification_call_delay: :unset, + verification_call_extension: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'VerificationCallDelay' => verification_call_delay, + 'VerificationCallExtension' => verification_call_extension, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + HostedNumberOrderInstanceMetadata.new( + @version, + hostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -321,6 +511,45 @@ def inspect end end + class HostedNumberOrderInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new HostedNumberOrderInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}HostedNumberOrderInstance] hosted_number_order_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [HostedNumberOrderInstanceMetadata] The initialized instance with metadata. + def initialize(version, hosted_number_order_instance, headers, status_code) + super(version, headers, status_code) + @hosted_number_order_instance = hosted_number_order_instance + end + + def hosted_number_order + @hosted_number_order_instance + end + + def to_s + "" + end + end + + class HostedNumberOrderListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @hosted_number_order_instance = payload.body[key].map do |data| + HostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def hosted_number_order_instance + @instance + end + end + class HostedNumberOrderPage < Page ## # Initialize the HostedNumberOrderPage @@ -349,6 +578,54 @@ def to_s '' end end + + class HostedNumberOrderPageMetadata < PageMetadata + attr_reader :hosted_number_order_page + + def initialize(version, response, solution, limit) + super(version, response) + @hosted_number_order_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @hosted_number_order_page << HostedNumberOrderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @hosted_number_order_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class HostedNumberOrderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @hosted_number_order = payload.body[key].map do |data| + HostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def hosted_number_order + @hosted_number_order + end + end + class HostedNumberOrderInstance < InstanceResource ## # Initialize the HostedNumberOrderInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb index 682fcfc06..ed3b9d9c4 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb @@ -151,6 +151,54 @@ def to_s '' end end + + class RegulatoryCompliancePageMetadata < PageMetadata + attr_reader :regulatory_compliance_page + + def initialize(version, response, solution, limit) + super(version, response) + @regulatory_compliance_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @regulatory_compliance_page << RegulatoryComplianceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @regulatory_compliance_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RegulatoryComplianceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @regulatory_compliance = payload.body[key].map do |data| + RegulatoryComplianceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def regulatory_compliance + @regulatory_compliance + end + end + class RegulatoryComplianceInstance < InstanceResource ## # Initialize the RegulatoryComplianceInstance 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 35bd10128..fea91d859 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb @@ -78,6 +78,58 @@ def create( ) end + ## + # Create the BundleInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] email The email address that will receive updates when the Bundle resource changes status. + # @param [String] status_callback The URL we call to inform your application of status changes. + # @param [String] regulation_sid The unique string of a regulation that is associated to the Bundle resource. + # @param [String] iso_country The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. + # @param [EndUserType] end_user_type + # @param [String] number_type The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. + # @param [Boolean] is_test Indicates that Bundle is a Test Bundle and will be Auto-Rejected + # @return [BundleInstance] Created BundleInstance + def create_with_metadata( + friendly_name: nil, + email: nil, + status_callback: :unset, + regulation_sid: :unset, + iso_country: :unset, + end_user_type: :unset, + number_type: :unset, + is_test: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Email' => email, + 'StatusCallback' => status_callback, + 'RegulationSid' => regulation_sid, + 'IsoCountry' => iso_country, + 'EndUserType' => end_user_type, + 'NumberType' => number_type, + 'IsTest' => is_test, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + bundle_instance = BundleInstance.new( + @version, + response.body, + ) + BundleInstanceMetadata.new( + @version, + bundle_instance, + response.headers, + response.status_code + ) + end + ## # Lists BundleInstance records from the API as a list. @@ -161,6 +213,50 @@ def stream(status: :unset, friendly_name: :unset, regulation_sid: :unset, iso_co @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BundlePageMetadata records from the API as a list. + # @param [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. 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`. + # @param [Boolean] has_valid_until_date Indicates that the Bundle is a valid Bundle until a specified expiration date. + # @param [SortBy] sort_by Can be `valid-until` or `date-updated`. Defaults to `date-created`. + # @param [SortDirection] sort_direction Default is `DESC`. Can be `ASC` or `DESC`. + # @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. [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) is the acceptable date format. + # @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. [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) is the acceptable date format. + # @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. [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) is the acceptable date format. + # @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_with_metadata(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: :unset, valid_until_date_before: :unset, valid_until_date_after: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + 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), + 'ValidUntilDate<' => Twilio.serialize_iso8601_datetime(valid_until_date_before), + 'ValidUntilDate>' => Twilio.serialize_iso8601_datetime(valid_until_date_after), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BundlePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BundleInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -269,7 +365,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BundleInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + bundle_instance = BundleInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BundleInstanceMetadata.new(@version, bundle_instance, response.headers, response.status_code) end ## @@ -291,6 +406,31 @@ def fetch ) end + ## + # Fetch the BundleInstanceMetadata + # @return [BundleInstance] Fetched BundleInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + bundle_instance = BundleInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + BundleInstanceMetadata.new( + @version, + bundle_instance, + response.headers, + response.status_code + ) + end + ## # Update the BundleInstance # @param [Status] status @@ -326,6 +466,47 @@ def update( ) end + ## + # Update the BundleInstanceMetadata + # @param [Status] status + # @param [String] status_callback The URL we call to inform your application of status changes. + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] email The email address that will receive updates when the Bundle resource changes status. + # @return [BundleInstance] Updated BundleInstance + def update_with_metadata( + status: :unset, + status_callback: :unset, + friendly_name: :unset, + email: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'StatusCallback' => status_callback, + 'FriendlyName' => friendly_name, + 'Email' => email, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + bundle_instance = BundleInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + BundleInstanceMetadata.new( + @version, + bundle_instance, + response.headers, + response.status_code + ) + end + ## # Access the replace_items # @return [ReplaceItemsList] @@ -402,6 +583,45 @@ def inspect end end + class BundleInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BundleInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BundleInstance] bundle_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BundleInstanceMetadata] The initialized instance with metadata. + def initialize(version, bundle_instance, headers, status_code) + super(version, headers, status_code) + @bundle_instance = bundle_instance + end + + def bundle + @bundle_instance + end + + def to_s + "" + end + end + + class BundleListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bundle_instance = payload.body[key].map do |data| + BundleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bundle_instance + @instance + end + end + class BundlePage < Page ## # Initialize the BundlePage @@ -430,6 +650,54 @@ def to_s '' end end + + class BundlePageMetadata < PageMetadata + attr_reader :bundle_page + + def initialize(version, response, solution, limit) + super(version, response) + @bundle_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bundle_page << BundleListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bundle_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BundleListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bundle = payload.body[key].map do |data| + BundleInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bundle + @bundle + end + end + class BundleInstance < InstanceResource ## # Initialize the BundleInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.rb index d29fb6e9a..c31b43ea8 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.rb @@ -59,6 +59,38 @@ def create( ) end + ## + # Create the BundleCopyInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the copied bundle. + # @return [BundleCopyInstance] Created BundleCopyInstance + def create_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + bundleCopy_instance = BundleCopyInstance.new( + @version, + response.body, + bundle_sid: @solution[:bundle_sid], + ) + BundleCopyInstanceMetadata.new( + @version, + bundleCopy_instance, + response.headers, + response.status_code + ) + end + ## # Lists BundleCopyInstance records from the API as a list. @@ -98,6 +130,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BundleCopyPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BundleCopyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BundleCopyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -183,6 +237,54 @@ def to_s '' end end + + class BundleCopyPageMetadata < PageMetadata + attr_reader :bundle_copy_page + + def initialize(version, response, solution, limit) + super(version, response) + @bundle_copy_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bundle_copy_page << BundleCopyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bundle_copy_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BundleCopyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bundle_copy = payload.body[key].map do |data| + BundleCopyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bundle_copy + @bundle_copy + end + end + class BundleCopyInstance < InstanceResource ## # Initialize the BundleCopyInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb index fd6ab00b7..29d72d41b 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb @@ -52,6 +52,31 @@ def create ) end + ## + # Create the EvaluationInstanceMetadata + # @return [EvaluationInstance] Created EvaluationInstance + def create_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers) + evaluation_instance = EvaluationInstance.new( + @version, + response.body, + bundle_sid: @solution[:bundle_sid], + ) + EvaluationInstanceMetadata.new( + @version, + evaluation_instance, + response.headers, + response.status_code + ) + end + ## # Lists EvaluationInstance records from the API as a list. @@ -91,6 +116,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EvaluationPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EvaluationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EvaluationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -185,6 +232,32 @@ def fetch ) end + ## + # Fetch the EvaluationInstanceMetadata + # @return [EvaluationInstance] Fetched EvaluationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + evaluation_instance = EvaluationInstance.new( + @version, + response.body, + bundle_sid: @solution[:bundle_sid], + sid: @solution[:sid], + ) + EvaluationInstanceMetadata.new( + @version, + evaluation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -201,6 +274,45 @@ def inspect end end + class EvaluationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EvaluationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EvaluationInstance] evaluation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EvaluationInstanceMetadata] The initialized instance with metadata. + def initialize(version, evaluation_instance, headers, status_code) + super(version, headers, status_code) + @evaluation_instance = evaluation_instance + end + + def evaluation + @evaluation_instance + end + + def to_s + "" + end + end + + class EvaluationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @evaluation_instance = payload.body[key].map do |data| + EvaluationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def evaluation_instance + @instance + end + end + class EvaluationPage < Page ## # Initialize the EvaluationPage @@ -229,6 +341,54 @@ def to_s '' end end + + class EvaluationPageMetadata < PageMetadata + attr_reader :evaluation_page + + def initialize(version, response, solution, limit) + super(version, response) + @evaluation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @evaluation_page << EvaluationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @evaluation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EvaluationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @evaluation = payload.body[key].map do |data| + EvaluationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def evaluation + @evaluation + end + end + class EvaluationInstance < InstanceResource ## # Initialize the EvaluationInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.rb index 2f7ae5c68..84c74a895 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.rb @@ -59,6 +59,38 @@ def create( ) end + ## + # Create the ItemAssignmentInstanceMetadata + # @param [String] object_sid The SID of an object bag that holds information of the different items. + # @return [ItemAssignmentInstance] Created ItemAssignmentInstance + def create_with_metadata( + object_sid: nil + ) + + data = Twilio::Values.of({ + 'ObjectSid' => object_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + itemAssignment_instance = ItemAssignmentInstance.new( + @version, + response.body, + bundle_sid: @solution[:bundle_sid], + ) + ItemAssignmentInstanceMetadata.new( + @version, + itemAssignment_instance, + response.headers, + response.status_code + ) + end + ## # Lists ItemAssignmentInstance records from the API as a list. @@ -98,6 +130,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ItemAssignmentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ItemAssignmentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ItemAssignmentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -181,7 +235,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ItemAssignmentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + itemAssignment_instance = ItemAssignmentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ItemAssignmentInstanceMetadata.new(@version, itemAssignment_instance, response.headers, response.status_code) end ## @@ -204,6 +277,32 @@ def fetch ) end + ## + # Fetch the ItemAssignmentInstanceMetadata + # @return [ItemAssignmentInstance] Fetched ItemAssignmentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + itemAssignment_instance = ItemAssignmentInstance.new( + @version, + response.body, + bundle_sid: @solution[:bundle_sid], + sid: @solution[:sid], + ) + ItemAssignmentInstanceMetadata.new( + @version, + itemAssignment_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -220,6 +319,45 @@ def inspect end end + class ItemAssignmentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ItemAssignmentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ItemAssignmentInstance] item_assignment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ItemAssignmentInstanceMetadata] The initialized instance with metadata. + def initialize(version, item_assignment_instance, headers, status_code) + super(version, headers, status_code) + @item_assignment_instance = item_assignment_instance + end + + def item_assignment + @item_assignment_instance + end + + def to_s + "" + end + end + + class ItemAssignmentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @item_assignment_instance = payload.body[key].map do |data| + ItemAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def item_assignment_instance + @instance + end + end + class ItemAssignmentPage < Page ## # Initialize the ItemAssignmentPage @@ -248,6 +386,54 @@ def to_s '' end end + + class ItemAssignmentPageMetadata < PageMetadata + attr_reader :item_assignment_page + + def initialize(version, response, solution, limit) + super(version, response) + @item_assignment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @item_assignment_page << ItemAssignmentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @item_assignment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ItemAssignmentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @item_assignment = payload.body[key].map do |data| + ItemAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def item_assignment + @item_assignment + end + end + class ItemAssignmentInstance < InstanceResource ## # Initialize the ItemAssignmentInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/replace_items.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/replace_items.rb index e93e3aabc..1b3489216 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/replace_items.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/replace_items.rb @@ -59,6 +59,38 @@ def create( ) end + ## + # Create the ReplaceItemsInstanceMetadata + # @param [String] from_bundle_sid The source bundle sid to copy the item assignments from. + # @return [ReplaceItemsInstance] Created ReplaceItemsInstance + def create_with_metadata( + from_bundle_sid: nil + ) + + data = Twilio::Values.of({ + 'FromBundleSid' => from_bundle_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + replaceItems_instance = ReplaceItemsInstance.new( + @version, + response.body, + bundle_sid: @solution[:bundle_sid], + ) + ReplaceItemsInstanceMetadata.new( + @version, + replaceItems_instance, + response.headers, + response.status_code + ) + end + @@ -96,6 +128,54 @@ def to_s '' end end + + class ReplaceItemsPageMetadata < PageMetadata + attr_reader :replace_items_page + + def initialize(version, response, solution, limit) + super(version, response) + @replace_items_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @replace_items_page << ReplaceItemsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @replace_items_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ReplaceItemsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @replace_items = payload.body[key].map do |data| + ReplaceItemsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def replace_items + @replace_items + end + end + class ReplaceItemsInstance < InstanceResource ## # Initialize the ReplaceItemsInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb index 3141be118..1305d4535 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb @@ -63,6 +63,43 @@ def create( ) end + ## + # Create the EndUserInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [Type] type + # @param [Object] attributes The set of parameters that are the attributes of the End User resource which are derived End User Types. + # @return [EndUserInstance] Created EndUserInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + ) + EndUserInstanceMetadata.new( + @version, + endUser_instance, + response.headers, + response.status_code + ) + end + ## # Lists EndUserInstance records from the API as a list. @@ -102,6 +139,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EndUserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EndUserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EndUserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +243,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the EndUserInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + EndUserInstanceMetadata.new(@version, endUser_instance, response.headers, response.status_code) end ## @@ -206,6 +284,31 @@ def fetch ) end + ## + # Fetch the EndUserInstanceMetadata + # @return [EndUserInstance] Fetched EndUserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EndUserInstanceMetadata.new( + @version, + endUser_instance, + response.headers, + response.status_code + ) + end + ## # Update the EndUserInstance # @param [String] friendly_name The string that you assigned to describe the resource. @@ -235,6 +338,41 @@ def update( ) end + ## + # Update the EndUserInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [Object] attributes The set of parameters that are the attributes of the End User resource which are derived End User Types. + # @return [EndUserInstance] Updated EndUserInstance + def update_with_metadata( + friendly_name: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EndUserInstanceMetadata.new( + @version, + endUser_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -251,6 +389,45 @@ def inspect end end + class EndUserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EndUserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EndUserInstance] end_user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EndUserInstanceMetadata] The initialized instance with metadata. + def initialize(version, end_user_instance, headers, status_code) + super(version, headers, status_code) + @end_user_instance = end_user_instance + end + + def end_user + @end_user_instance + end + + def to_s + "" + end + end + + class EndUserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user_instance = payload.body[key].map do |data| + EndUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user_instance + @instance + end + end + class EndUserPage < Page ## # Initialize the EndUserPage @@ -279,6 +456,54 @@ def to_s '' end end + + class EndUserPageMetadata < PageMetadata + attr_reader :end_user_page + + def initialize(version, response, solution, limit) + super(version, response) + @end_user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @end_user_page << EndUserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @end_user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EndUserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user = payload.body[key].map do |data| + EndUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user + @end_user + end + end + class EndUserInstance < InstanceResource ## # Initialize the EndUserInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user_type.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user_type.rb index 5ce75e3a0..ad66c10a8 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user_type.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user_type.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EndUserTypePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EndUserTypePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EndUserTypeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,6 +185,31 @@ def fetch ) end + ## + # Fetch the EndUserTypeInstanceMetadata + # @return [EndUserTypeInstance] Fetched EndUserTypeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + endUserType_instance = EndUserTypeInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EndUserTypeInstanceMetadata.new( + @version, + endUserType_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -179,6 +226,45 @@ def inspect end end + class EndUserTypeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EndUserTypeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EndUserTypeInstance] end_user_type_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EndUserTypeInstanceMetadata] The initialized instance with metadata. + def initialize(version, end_user_type_instance, headers, status_code) + super(version, headers, status_code) + @end_user_type_instance = end_user_type_instance + end + + def end_user_type + @end_user_type_instance + end + + def to_s + "" + end + end + + class EndUserTypeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user_type_instance = payload.body[key].map do |data| + EndUserTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user_type_instance + @instance + end + end + class EndUserTypePage < Page ## # Initialize the EndUserTypePage @@ -207,6 +293,54 @@ def to_s '' end end + + class EndUserTypePageMetadata < PageMetadata + attr_reader :end_user_type_page + + def initialize(version, response, solution, limit) + super(version, response) + @end_user_type_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @end_user_type_page << EndUserTypeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @end_user_type_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EndUserTypeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user_type = payload.body[key].map do |data| + EndUserTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user_type + @end_user_type + end + end + class EndUserTypeInstance < InstanceResource ## # Initialize the EndUserTypeInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/regulation.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/regulation.rb index f5fbea14f..59cfdab40 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/regulation.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/regulation.rb @@ -87,6 +87,36 @@ def stream(end_user_type: :unset, iso_country: :unset, number_type: :unset, incl @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RegulationPageMetadata records from the API as a list. + # @param [EndUserType] end_user_type The type of End User the regulation requires - can be `individual` or `business`. + # @param [String] iso_country The ISO country code of the phone number's country. + # @param [String] number_type The type of phone number that the regulatory requiremnt is restricting. + # @param [Boolean] include_constraints A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields + # @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_with_metadata(end_user_type: :unset, iso_country: :unset, number_type: :unset, include_constraints: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'EndUserType' => end_user_type, + 'IsoCountry' => iso_country, + 'NumberType' => number_type, + 'IncludeConstraints' => include_constraints, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RegulationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RegulationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,6 +223,37 @@ def fetch( ) end + ## + # Fetch the RegulationInstanceMetadata + # @param [Boolean] include_constraints A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields + # @return [RegulationInstance] Fetched RegulationInstance + def fetch_with_metadata( + include_constraints: :unset + ) + + params = Twilio::Values.of({ + 'IncludeConstraints' => include_constraints, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + regulation_instance = RegulationInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RegulationInstanceMetadata.new( + @version, + regulation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -209,6 +270,45 @@ def inspect end end + class RegulationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RegulationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RegulationInstance] regulation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RegulationInstanceMetadata] The initialized instance with metadata. + def initialize(version, regulation_instance, headers, status_code) + super(version, headers, status_code) + @regulation_instance = regulation_instance + end + + def regulation + @regulation_instance + end + + def to_s + "" + end + end + + class RegulationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @regulation_instance = payload.body[key].map do |data| + RegulationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def regulation_instance + @instance + end + end + class RegulationPage < Page ## # Initialize the RegulationPage @@ -237,6 +337,54 @@ def to_s '' end end + + class RegulationPageMetadata < PageMetadata + attr_reader :regulation_page + + def initialize(version, response, solution, limit) + super(version, response) + @regulation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @regulation_page << RegulationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @regulation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RegulationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @regulation = payload.body[key].map do |data| + RegulationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def regulation + @regulation + end + end + class RegulationInstance < InstanceResource ## # Initialize the RegulationInstance 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 6ff569b0e..f5272ee99 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 @@ -63,6 +63,43 @@ def create( ) end + ## + # Create the SupportingDocumentInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] type The type of the Supporting Document. + # @param [Object] attributes The set of parameters that are the attributes of the Supporting Documents resource which are derived Supporting Document Types. + # @return [SupportingDocumentInstance] Created SupportingDocumentInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + ) + SupportingDocumentInstanceMetadata.new( + @version, + supportingDocument_instance, + response.headers, + response.status_code + ) + end + ## # Lists SupportingDocumentInstance records from the API as a list. @@ -102,6 +139,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SupportingDocumentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SupportingDocumentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SupportingDocumentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +243,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SupportingDocumentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SupportingDocumentInstanceMetadata.new(@version, supportingDocument_instance, response.headers, response.status_code) end ## @@ -206,6 +284,31 @@ def fetch ) end + ## + # Fetch the SupportingDocumentInstanceMetadata + # @return [SupportingDocumentInstance] Fetched SupportingDocumentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SupportingDocumentInstanceMetadata.new( + @version, + supportingDocument_instance, + response.headers, + response.status_code + ) + end + ## # Update the SupportingDocumentInstance # @param [String] friendly_name The string that you assigned to describe the resource. @@ -235,6 +338,41 @@ def update( ) end + ## + # Update the SupportingDocumentInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [Object] attributes The set of parameters that are the attributes of the Supporting Document resource which are derived Supporting Document Types. + # @return [SupportingDocumentInstance] Updated SupportingDocumentInstance + def update_with_metadata( + friendly_name: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SupportingDocumentInstanceMetadata.new( + @version, + supportingDocument_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -251,6 +389,45 @@ def inspect end end + class SupportingDocumentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SupportingDocumentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SupportingDocumentInstance] supporting_document_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SupportingDocumentInstanceMetadata] The initialized instance with metadata. + def initialize(version, supporting_document_instance, headers, status_code) + super(version, headers, status_code) + @supporting_document_instance = supporting_document_instance + end + + def supporting_document + @supporting_document_instance + end + + def to_s + "" + end + end + + class SupportingDocumentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document_instance = payload.body[key].map do |data| + SupportingDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document_instance + @instance + end + end + class SupportingDocumentPage < Page ## # Initialize the SupportingDocumentPage @@ -279,6 +456,54 @@ def to_s '' end end + + class SupportingDocumentPageMetadata < PageMetadata + attr_reader :supporting_document_page + + def initialize(version, response, solution, limit) + super(version, response) + @supporting_document_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @supporting_document_page << SupportingDocumentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @supporting_document_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SupportingDocumentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document = payload.body[key].map do |data| + SupportingDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document + @supporting_document + end + end + class SupportingDocumentInstance < InstanceResource ## # Initialize the SupportingDocumentInstance diff --git a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document_type.rb b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document_type.rb index fcbe50679..2b5588c38 100644 --- a/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document_type.rb +++ b/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document_type.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SupportingDocumentTypePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SupportingDocumentTypePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SupportingDocumentTypeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,6 +185,31 @@ def fetch ) end + ## + # Fetch the SupportingDocumentTypeInstanceMetadata + # @return [SupportingDocumentTypeInstance] Fetched SupportingDocumentTypeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + supportingDocumentType_instance = SupportingDocumentTypeInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SupportingDocumentTypeInstanceMetadata.new( + @version, + supportingDocumentType_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -179,6 +226,45 @@ def inspect end end + class SupportingDocumentTypeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SupportingDocumentTypeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SupportingDocumentTypeInstance] supporting_document_type_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SupportingDocumentTypeInstanceMetadata] The initialized instance with metadata. + def initialize(version, supporting_document_type_instance, headers, status_code) + super(version, headers, status_code) + @supporting_document_type_instance = supporting_document_type_instance + end + + def supporting_document_type + @supporting_document_type_instance + end + + def to_s + "" + end + end + + class SupportingDocumentTypeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document_type_instance = payload.body[key].map do |data| + SupportingDocumentTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document_type_instance + @instance + end + end + class SupportingDocumentTypePage < Page ## # Initialize the SupportingDocumentTypePage @@ -207,6 +293,54 @@ def to_s '' end end + + class SupportingDocumentTypePageMetadata < PageMetadata + attr_reader :supporting_document_type_page + + def initialize(version, response, solution, limit) + super(version, response) + @supporting_document_type_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @supporting_document_type_page << SupportingDocumentTypeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @supporting_document_type_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SupportingDocumentTypeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document_type = payload.body[key].map do |data| + SupportingDocumentTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document_type + @supporting_document_type + end + end + class SupportingDocumentTypeInstance < InstanceResource ## # Initialize the SupportingDocumentTypeInstance diff --git a/lib/twilio-ruby/rest/numbers/v3/hosted_number_order.rb b/lib/twilio-ruby/rest/numbers/v3/hosted_number_order.rb index d5a1adf09..01200ddc3 100644 --- a/lib/twilio-ruby/rest/numbers/v3/hosted_number_order.rb +++ b/lib/twilio-ruby/rest/numbers/v3/hosted_number_order.rb @@ -103,6 +103,85 @@ def create( ) end + ## + # Create the HostedNumberOrderInstanceMetadata + # @param [String] phone_number The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format + # @param [Boolean] sms_capability Used to specify that the SMS capability will be hosted on Twilio's platform. + # @param [String] account_sid This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to. + # @param [String] friendly_name A 64 character string that is a human readable text that describes this resource. + # @param [String] unique_name Optional. Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID. + # @param [Array[String]] cc_emails Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to. + # @param [String] sms_url The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_method The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_fallback_url A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_fallback_method The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] status_callback_url Optional. The Status Callback URL attached to the IncomingPhoneNumber resource. + # @param [String] status_callback_method Optional. The Status Callback Method attached to the IncomingPhoneNumber resource. + # @param [String] sms_application_sid Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application. + # @param [String] address_sid Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. + # @param [String] email Optional. Email of the owner of this phone number that is being hosted. + # @param [VerificationType] verification_type + # @param [String] verification_document_sid Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill. + # @return [HostedNumberOrderInstance] Created HostedNumberOrderInstance + def create_with_metadata( + phone_number: nil, + sms_capability: nil, + account_sid: :unset, + friendly_name: :unset, + unique_name: :unset, + cc_emails: :unset, + sms_url: :unset, + sms_method: :unset, + sms_fallback_url: :unset, + sms_fallback_method: :unset, + status_callback_url: :unset, + status_callback_method: :unset, + sms_application_sid: :unset, + address_sid: :unset, + email: :unset, + verification_type: :unset, + verification_document_sid: :unset + ) + + data = Twilio::Values.of({ + 'phoneNumber' => phone_number, + 'smsCapability' => sms_capability, + 'accountSid' => account_sid, + 'friendlyName' => friendly_name, + 'uniqueName' => unique_name, + 'ccEmails' => Twilio.serialize_list(cc_emails) { |e| e }, + 'smsUrl' => sms_url, + 'smsMethod' => sms_method, + 'smsFallbackUrl' => sms_fallback_url, + 'smsFallbackMethod' => sms_fallback_method, + 'statusCallbackUrl' => status_callback_url, + 'statusCallbackMethod' => status_callback_method, + 'smsApplicationSid' => sms_application_sid, + 'addressSid' => address_sid, + 'email' => email, + 'verificationType' => verification_type, + 'verificationDocumentSid' => verification_document_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + ) + HostedNumberOrderInstanceMetadata.new( + @version, + hostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + @@ -140,6 +219,54 @@ def to_s '' end end + + class HostedNumberOrderPageMetadata < PageMetadata + attr_reader :hosted_number_order_page + + def initialize(version, response, solution, limit) + super(version, response) + @hosted_number_order_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @hosted_number_order_page << HostedNumberOrderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @hosted_number_order_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class HostedNumberOrderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @hosted_number_order = payload.body[key].map do |data| + HostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def hosted_number_order + @hosted_number_order + end + end + class HostedNumberOrderInstance < InstanceResource ## # Initialize the HostedNumberOrderInstance diff --git a/lib/twilio-ruby/rest/oauth/v1/authorize.rb b/lib/twilio-ruby/rest/oauth/v1/authorize.rb index 72650acc2..78ffab3c6 100644 --- a/lib/twilio-ruby/rest/oauth/v1/authorize.rb +++ b/lib/twilio-ruby/rest/oauth/v1/authorize.rb @@ -66,6 +66,48 @@ def fetch( ) end + ## + # Fetch the AuthorizeInstanceMetadata + # @param [String] response_type Response Type + # @param [String] client_id The Client Identifier + # @param [String] redirect_uri The url to which response will be redirected to + # @param [String] scope The scope of the access request + # @param [String] state An opaque value which can be used to maintain state between the request and callback + # @return [AuthorizeInstance] Fetched AuthorizeInstance + def fetch_with_metadata( + response_type: :unset, + client_id: :unset, + redirect_uri: :unset, + scope: :unset, + state: :unset + ) + + params = Twilio::Values.of({ + 'ResponseType' => response_type, + 'ClientId' => client_id, + 'RedirectUri' => redirect_uri, + 'Scope' => scope, + 'State' => state, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + authorize_instance = AuthorizeInstance.new( + @version, + response.body, + ) + AuthorizeInstanceMetadata.new( + @version, + authorize_instance, + response.headers, + response.status_code + ) + end + @@ -103,6 +145,54 @@ def to_s '' end end + + class AuthorizePageMetadata < PageMetadata + attr_reader :authorize_page + + def initialize(version, response, solution, limit) + super(version, response) + @authorize_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @authorize_page << AuthorizeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @authorize_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthorizeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorize = payload.body[key].map do |data| + AuthorizeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorize + @authorize + end + end + class AuthorizeInstance < InstanceResource ## # Initialize the AuthorizeInstance diff --git a/lib/twilio-ruby/rest/oauth/v1/token.rb b/lib/twilio-ruby/rest/oauth/v1/token.rb index 87a507808..e38ac4c41 100644 --- a/lib/twilio-ruby/rest/oauth/v1/token.rb +++ b/lib/twilio-ruby/rest/oauth/v1/token.rb @@ -76,6 +76,58 @@ def create( ) end + ## + # Create the TokenInstanceMetadata + # @param [String] grant_type Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + # @param [String] client_id A 34 character string that uniquely identifies this OAuth App. + # @param [String] client_secret The credential for confidential OAuth App. + # @param [String] code JWT token related to the authorization code grant type. + # @param [String] redirect_uri The redirect uri + # @param [String] audience The targeted audience uri + # @param [String] refresh_token JWT token related to refresh access token. + # @param [String] scope The scope of token + # @return [TokenInstance] Created TokenInstance + def create_with_metadata( + grant_type: nil, + client_id: nil, + client_secret: :unset, + code: :unset, + redirect_uri: :unset, + audience: :unset, + refresh_token: :unset, + scope: :unset + ) + + data = Twilio::Values.of({ + 'GrantType' => grant_type, + 'ClientId' => client_id, + 'ClientSecret' => client_secret, + 'Code' => code, + 'RedirectUri' => redirect_uri, + 'Audience' => audience, + 'RefreshToken' => refresh_token, + 'Scope' => scope, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + token_instance = TokenInstance.new( + @version, + response.body, + ) + TokenInstanceMetadata.new( + @version, + token_instance, + response.headers, + response.status_code + ) + end + @@ -113,6 +165,54 @@ def to_s '' end end + + class TokenPageMetadata < PageMetadata + attr_reader :token_page + + def initialize(version, response, solution, limit) + super(version, response) + @token_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @token_page << TokenListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @token_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TokenListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @token = payload.body[key].map do |data| + TokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def token + @token + end + end + class TokenInstance < InstanceResource ## # Initialize the TokenInstance diff --git a/lib/twilio-ruby/rest/oauth/v2/token.rb b/lib/twilio-ruby/rest/oauth/v2/token.rb index 53f08aab6..cab584d84 100644 --- a/lib/twilio-ruby/rest/oauth/v2/token.rb +++ b/lib/twilio-ruby/rest/oauth/v2/token.rb @@ -81,6 +81,63 @@ def create( ) end + ## + # Create the TokenInstanceMetadata + # @param [String] account_sid Optional Account SID to perform on behalf of requests. + # @param [String] grant_type Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + # @param [String] client_id A 34 character string that uniquely identifies this OAuth App. + # @param [String] client_secret The credential for confidential OAuth App. + # @param [String] code JWT token related to the authorization code grant type. + # @param [String] redirect_uri The redirect uri + # @param [String] audience The targeted audience uri + # @param [String] refresh_token JWT token related to refresh access token. + # @param [String] scope The scope of token + # @return [TokenInstance] Created TokenInstance + def create_with_metadata( + account_sid: :unset, + grant_type: :unset, + client_id: :unset, + client_secret: :unset, + code: :unset, + redirect_uri: :unset, + audience: :unset, + refresh_token: :unset, + scope: :unset + ) + + params = Twilio::Values.of({ + 'account_sid' => account_sid, + }) + data = Twilio::Values.of({ + 'grant_type' => grant_type, + 'client_id' => client_id, + 'client_secret' => client_secret, + 'code' => code, + 'redirect_uri' => redirect_uri, + 'audience' => audience, + 'refresh_token' => refresh_token, + 'scope' => scope, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, params: params, data: data, headers: headers) + token_instance = TokenInstance.new( + @version, + response.body, + ) + TokenInstanceMetadata.new( + @version, + token_instance, + response.headers, + response.status_code + ) + end + @@ -118,6 +175,54 @@ def to_s '' end end + + class TokenPageMetadata < PageMetadata + attr_reader :token_page + + def initialize(version, response, solution, limit) + super(version, response) + @token_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @token_page << TokenListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @token_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TokenListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @token = payload.body[key].map do |data| + TokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def token + @token + end + end + class TokenInstance < InstanceResource ## # Initialize the TokenInstance diff --git a/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb b/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb index d74e57f6a..a999368a8 100644 --- a/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +++ b/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb @@ -70,6 +70,52 @@ def create( ) end + ## + # Create the AuthorizationDocumentInstanceMetadata + # @param [Array[String]] hosted_number_order_sids A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform. + # @param [String] address_sid A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument. + # @param [String] email Email that this AuthorizationDocument will be sent to for signing. + # @param [String] contact_title The title of the person authorized to sign the Authorization Document for this phone number. + # @param [String] contact_phone_number The contact phone number of the person authorized to sign the Authorization Document. + # @param [Array[String]] cc_emails Email recipients who will be informed when an Authorization Document has been sent and signed. + # @return [AuthorizationDocumentInstance] Created AuthorizationDocumentInstance + def create_with_metadata( + hosted_number_order_sids: nil, + address_sid: nil, + email: nil, + contact_title: nil, + contact_phone_number: nil, + cc_emails: :unset + ) + + data = Twilio::Values.of({ + 'HostedNumberOrderSids' => Twilio.serialize_list(hosted_number_order_sids) { |e| e }, + 'AddressSid' => address_sid, + 'Email' => email, + 'ContactTitle' => contact_title, + 'ContactPhoneNumber' => contact_phone_number, + 'CcEmails' => Twilio.serialize_list(cc_emails) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + authorizationDocument_instance = AuthorizationDocumentInstance.new( + @version, + response.body, + ) + AuthorizationDocumentInstanceMetadata.new( + @version, + authorizationDocument_instance, + response.headers, + response.status_code + ) + end + ## # Lists AuthorizationDocumentInstance records from the API as a list. @@ -117,6 +163,32 @@ def stream(email: :unset, status: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AuthorizationDocumentPageMetadata records from the API as a list. + # @param [String] email Email that this AuthorizationDocument will be sent to for signing. + # @param [Status] status Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + # @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_with_metadata(email: :unset, status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Email' => email, + 'Status' => status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AuthorizationDocumentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AuthorizationDocumentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -214,6 +286,31 @@ def fetch ) end + ## + # Fetch the AuthorizationDocumentInstanceMetadata + # @return [AuthorizationDocumentInstance] Fetched AuthorizationDocumentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + authorizationDocument_instance = AuthorizationDocumentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AuthorizationDocumentInstanceMetadata.new( + @version, + authorizationDocument_instance, + response.headers, + response.status_code + ) + end + ## # Update the AuthorizationDocumentInstance # @param [Array[String]] hosted_number_order_sids A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform. @@ -258,6 +355,56 @@ def update( ) end + ## + # Update the AuthorizationDocumentInstanceMetadata + # @param [Array[String]] hosted_number_order_sids A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform. + # @param [String] address_sid A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument. + # @param [String] email Email that this AuthorizationDocument will be sent to for signing. + # @param [Array[String]] cc_emails Email recipients who will be informed when an Authorization Document has been sent and signed + # @param [Status] status + # @param [String] contact_title The title of the person authorized to sign the Authorization Document for this phone number. + # @param [String] contact_phone_number The contact phone number of the person authorized to sign the Authorization Document. + # @return [AuthorizationDocumentInstance] Updated AuthorizationDocumentInstance + def update_with_metadata( + hosted_number_order_sids: :unset, + address_sid: :unset, + email: :unset, + cc_emails: :unset, + status: :unset, + contact_title: :unset, + contact_phone_number: :unset + ) + + data = Twilio::Values.of({ + 'HostedNumberOrderSids' => Twilio.serialize_list(hosted_number_order_sids) { |e| e }, + 'AddressSid' => address_sid, + 'Email' => email, + 'CcEmails' => Twilio.serialize_list(cc_emails) { |e| e }, + 'Status' => status, + 'ContactTitle' => contact_title, + 'ContactPhoneNumber' => contact_phone_number, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + authorizationDocument_instance = AuthorizationDocumentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AuthorizationDocumentInstanceMetadata.new( + @version, + authorizationDocument_instance, + response.headers, + response.status_code + ) + end + ## # Access the dependent_hosted_number_orders # @return [DependentHostedNumberOrderList] @@ -285,6 +432,45 @@ def inspect end end + class AuthorizationDocumentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AuthorizationDocumentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AuthorizationDocumentInstance] authorization_document_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AuthorizationDocumentInstanceMetadata] The initialized instance with metadata. + def initialize(version, authorization_document_instance, headers, status_code) + super(version, headers, status_code) + @authorization_document_instance = authorization_document_instance + end + + def authorization_document + @authorization_document_instance + end + + def to_s + "" + end + end + + class AuthorizationDocumentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorization_document_instance = payload.body[key].map do |data| + AuthorizationDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorization_document_instance + @instance + end + end + class AuthorizationDocumentPage < Page ## # Initialize the AuthorizationDocumentPage @@ -313,6 +499,54 @@ def to_s '' end end + + class AuthorizationDocumentPageMetadata < PageMetadata + attr_reader :authorization_document_page + + def initialize(version, response, solution, limit) + super(version, response) + @authorization_document_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @authorization_document_page << AuthorizationDocumentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @authorization_document_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthorizationDocumentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorization_document = payload.body[key].map do |data| + AuthorizationDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorization_document + @authorization_document + end + end + class AuthorizationDocumentInstance < InstanceResource ## # Initialize the AuthorizationDocumentInstance diff --git a/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb b/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb index 1513db87d..bf4ba42c2 100644 --- a/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb +++ b/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb @@ -91,6 +91,38 @@ def stream(status: :unset, phone_number: :unset, incoming_phone_number_sid: :uns @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DependentHostedNumberOrderPageMetadata records from the API as a list. + # @param [Status] status Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + # @param [String] phone_number An E164 formatted phone number hosted by this HostedNumberOrder. + # @param [String] incoming_phone_number_sid A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + # @param [String] friendly_name A human readable description of this resource, up to 64 characters. + # @param [String] unique_name Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID. + # @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_with_metadata(status: :unset, phone_number: :unset, incoming_phone_number_sid: :unset, friendly_name: :unset, unique_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'PhoneNumber' => phone_number, + 'IncomingPhoneNumberSid' => incoming_phone_number_sid, + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DependentHostedNumberOrderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DependentHostedNumberOrderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,6 +218,54 @@ def to_s '' end end + + class DependentHostedNumberOrderPageMetadata < PageMetadata + attr_reader :dependent_hosted_number_order_page + + def initialize(version, response, solution, limit) + super(version, response) + @dependent_hosted_number_order_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @dependent_hosted_number_order_page << DependentHostedNumberOrderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @dependent_hosted_number_order_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DependentHostedNumberOrderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @dependent_hosted_number_order = payload.body[key].map do |data| + DependentHostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def dependent_hosted_number_order + @dependent_hosted_number_order + end + end + class DependentHostedNumberOrderInstance < InstanceResource ## # Initialize the DependentHostedNumberOrderInstance diff --git a/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb b/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb index 886341983..18d1197aa 100644 --- a/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +++ b/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb @@ -103,6 +103,85 @@ def create( ) end + ## + # Create the HostedNumberOrderInstanceMetadata + # @param [String] phone_number The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format + # @param [Boolean] sms_capability Used to specify that the SMS capability will be hosted on Twilio's platform. + # @param [String] account_sid This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to. + # @param [String] friendly_name A 64 character string that is a human readable text that describes this resource. + # @param [String] unique_name Optional. Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID. + # @param [Array[String]] cc_emails Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to. + # @param [String] sms_url The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_method The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_fallback_url A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] sms_fallback_method The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + # @param [String] status_callback_url Optional. The Status Callback URL attached to the IncomingPhoneNumber resource. + # @param [String] status_callback_method Optional. The Status Callback Method attached to the IncomingPhoneNumber resource. + # @param [String] sms_application_sid Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application. + # @param [String] address_sid Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. + # @param [String] email Optional. Email of the owner of this phone number that is being hosted. + # @param [VerificationType] verification_type + # @param [String] verification_document_sid Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill. + # @return [HostedNumberOrderInstance] Created HostedNumberOrderInstance + def create_with_metadata( + phone_number: nil, + sms_capability: nil, + account_sid: :unset, + friendly_name: :unset, + unique_name: :unset, + cc_emails: :unset, + sms_url: :unset, + sms_method: :unset, + sms_fallback_url: :unset, + sms_fallback_method: :unset, + status_callback_url: :unset, + status_callback_method: :unset, + sms_application_sid: :unset, + address_sid: :unset, + email: :unset, + verification_type: :unset, + verification_document_sid: :unset + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + 'SmsCapability' => sms_capability, + 'AccountSid' => account_sid, + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'CcEmails' => Twilio.serialize_list(cc_emails) { |e| e }, + 'SmsUrl' => sms_url, + 'SmsMethod' => sms_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsFallbackMethod' => sms_fallback_method, + 'StatusCallbackUrl' => status_callback_url, + 'StatusCallbackMethod' => status_callback_method, + 'SmsApplicationSid' => sms_application_sid, + 'AddressSid' => address_sid, + 'Email' => email, + 'VerificationType' => verification_type, + 'VerificationDocumentSid' => verification_document_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + ) + HostedNumberOrderInstanceMetadata.new( + @version, + hostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + ## # Lists HostedNumberOrderInstance records from the API as a list. @@ -162,6 +241,38 @@ def stream(status: :unset, phone_number: :unset, incoming_phone_number_sid: :uns @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists HostedNumberOrderPageMetadata records from the API as a list. + # @param [Status] status The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + # @param [String] phone_number An E164 formatted phone number hosted by this HostedNumberOrder. + # @param [String] incoming_phone_number_sid A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + # @param [String] friendly_name A human readable description of this resource, up to 64 characters. + # @param [String] unique_name Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID. + # @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_with_metadata(status: :unset, phone_number: :unset, incoming_phone_number_sid: :unset, friendly_name: :unset, unique_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'PhoneNumber' => phone_number, + 'IncomingPhoneNumberSid' => incoming_phone_number_sid, + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + HostedNumberOrderPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields HostedNumberOrderInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -254,7 +365,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the HostedNumberOrderInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + HostedNumberOrderInstanceMetadata.new(@version, hostedNumberOrder_instance, response.headers, response.status_code) end ## @@ -276,6 +406,31 @@ def fetch ) end + ## + # Fetch the HostedNumberOrderInstanceMetadata + # @return [HostedNumberOrderInstance] Fetched HostedNumberOrderInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + HostedNumberOrderInstanceMetadata.new( + @version, + hostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + ## # Update the HostedNumberOrderInstance # @param [String] friendly_name A 64 character string that is a human readable text that describes this resource. @@ -329,6 +484,65 @@ def update( ) end + ## + # Update the HostedNumberOrderInstanceMetadata + # @param [String] friendly_name A 64 character string that is a human readable text that describes this resource. + # @param [String] unique_name Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID. + # @param [String] email Email of the owner of this phone number that is being hosted. + # @param [Array[String]] cc_emails Optional. A list of emails that LOA document for this HostedNumberOrder will be carbon copied to. + # @param [Status] status + # @param [String] verification_code A verification code that is given to the user via a phone call to the phone number that is being hosted. + # @param [VerificationType] verification_type + # @param [String] verification_document_sid Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill. + # @param [String] extension Digits to dial after connecting the verification call. + # @param [String] call_delay The number of seconds, between 0 and 60, to delay before initiating the verification call. Defaults to 0. + # @return [HostedNumberOrderInstance] Updated HostedNumberOrderInstance + def update_with_metadata( + friendly_name: :unset, + unique_name: :unset, + email: :unset, + cc_emails: :unset, + status: :unset, + verification_code: :unset, + verification_type: :unset, + verification_document_sid: :unset, + extension: :unset, + call_delay: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'Email' => email, + 'CcEmails' => Twilio.serialize_list(cc_emails) { |e| e }, + 'Status' => status, + 'VerificationCode' => verification_code, + 'VerificationType' => verification_type, + 'VerificationDocumentSid' => verification_document_sid, + 'Extension' => extension, + 'CallDelay' => call_delay, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + hostedNumberOrder_instance = HostedNumberOrderInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + HostedNumberOrderInstanceMetadata.new( + @version, + hostedNumberOrder_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -345,6 +559,45 @@ def inspect end end + class HostedNumberOrderInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new HostedNumberOrderInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}HostedNumberOrderInstance] hosted_number_order_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [HostedNumberOrderInstanceMetadata] The initialized instance with metadata. + def initialize(version, hosted_number_order_instance, headers, status_code) + super(version, headers, status_code) + @hosted_number_order_instance = hosted_number_order_instance + end + + def hosted_number_order + @hosted_number_order_instance + end + + def to_s + "" + end + end + + class HostedNumberOrderListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @hosted_number_order_instance = payload.body[key].map do |data| + HostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def hosted_number_order_instance + @instance + end + end + class HostedNumberOrderPage < Page ## # Initialize the HostedNumberOrderPage @@ -373,6 +626,54 @@ def to_s '' end end + + class HostedNumberOrderPageMetadata < PageMetadata + attr_reader :hosted_number_order_page + + def initialize(version, response, solution, limit) + super(version, response) + @hosted_number_order_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @hosted_number_order_page << HostedNumberOrderListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @hosted_number_order_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class HostedNumberOrderListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @hosted_number_order = payload.body[key].map do |data| + HostedNumberOrderInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def hosted_number_order + @hosted_number_order + end + end + class HostedNumberOrderInstance < InstanceResource ## # Initialize the HostedNumberOrderInstance diff --git a/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb b/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb index 246d97cbc..b5c54ca0a 100644 --- a/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb +++ b/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AvailableAddOnPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AvailableAddOnPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AvailableAddOnInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -162,6 +184,31 @@ def fetch ) end + ## + # Fetch the AvailableAddOnInstanceMetadata + # @return [AvailableAddOnInstance] Fetched AvailableAddOnInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + availableAddOn_instance = AvailableAddOnInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + AvailableAddOnInstanceMetadata.new( + @version, + availableAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Access the extensions # @return [AvailableAddOnExtensionList] @@ -197,6 +244,45 @@ def inspect end end + class AvailableAddOnInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AvailableAddOnInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AvailableAddOnInstance] available_add_on_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AvailableAddOnInstanceMetadata] The initialized instance with metadata. + def initialize(version, available_add_on_instance, headers, status_code) + super(version, headers, status_code) + @available_add_on_instance = available_add_on_instance + end + + def available_add_on + @available_add_on_instance + end + + def to_s + "" + end + end + + class AvailableAddOnListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on_instance = payload.body[key].map do |data| + AvailableAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on_instance + @instance + end + end + class AvailableAddOnPage < Page ## # Initialize the AvailableAddOnPage @@ -225,6 +311,54 @@ def to_s '' end end + + class AvailableAddOnPageMetadata < PageMetadata + attr_reader :available_add_on_page + + def initialize(version, response, solution, limit) + super(version, response) + @available_add_on_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @available_add_on_page << AvailableAddOnListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @available_add_on_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AvailableAddOnListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on = payload.body[key].map do |data| + AvailableAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on + @available_add_on + end + end + class AvailableAddOnInstance < InstanceResource ## # Initialize the AvailableAddOnInstance diff --git a/lib/twilio-ruby/rest/preview/marketplace/available_add_on/available_add_on_extension.rb b/lib/twilio-ruby/rest/preview/marketplace/available_add_on/available_add_on_extension.rb index e0526f470..53d2a903d 100644 --- a/lib/twilio-ruby/rest/preview/marketplace/available_add_on/available_add_on_extension.rb +++ b/lib/twilio-ruby/rest/preview/marketplace/available_add_on/available_add_on_extension.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AvailableAddOnExtensionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AvailableAddOnExtensionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AvailableAddOnExtensionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the AvailableAddOnExtensionInstanceMetadata + # @return [AvailableAddOnExtensionInstance] Fetched AvailableAddOnExtensionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + availableAddOnExtension_instance = AvailableAddOnExtensionInstance.new( + @version, + response.body, + available_add_on_sid: @solution[:available_add_on_sid], + sid: @solution[:sid], + ) + AvailableAddOnExtensionInstanceMetadata.new( + @version, + availableAddOnExtension_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class AvailableAddOnExtensionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AvailableAddOnExtensionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AvailableAddOnExtensionInstance] available_add_on_extension_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AvailableAddOnExtensionInstanceMetadata] The initialized instance with metadata. + def initialize(version, available_add_on_extension_instance, headers, status_code) + super(version, headers, status_code) + @available_add_on_extension_instance = available_add_on_extension_instance + end + + def available_add_on_extension + @available_add_on_extension_instance + end + + def to_s + "" + end + end + + class AvailableAddOnExtensionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on_extension_instance = payload.body[key].map do |data| + AvailableAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on_extension_instance + @instance + end + end + class AvailableAddOnExtensionPage < Page ## # Initialize the AvailableAddOnExtensionPage @@ -209,6 +296,54 @@ def to_s '' end end + + class AvailableAddOnExtensionPageMetadata < PageMetadata + attr_reader :available_add_on_extension_page + + def initialize(version, response, solution, limit) + super(version, response) + @available_add_on_extension_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @available_add_on_extension_page << AvailableAddOnExtensionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @available_add_on_extension_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AvailableAddOnExtensionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @available_add_on_extension = payload.body[key].map do |data| + AvailableAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def available_add_on_extension + @available_add_on_extension + end + end + class AvailableAddOnExtensionInstance < InstanceResource ## # Initialize the AvailableAddOnExtensionInstance diff --git a/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb b/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb index 8442d0bd0..ff8c40049 100644 --- a/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb +++ b/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the InstalledAddOnInstanceMetadata + # @param [String] available_add_on_sid The SID of the AvaliableAddOn to install. + # @param [Boolean] accept_terms_of_service Whether the Terms of Service were accepted. + # @param [Object] configuration The JSON object that represents the configuration of the new Add-on being installed. + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + # @return [InstalledAddOnInstance] Created InstalledAddOnInstance + def create_with_metadata( + available_add_on_sid: nil, + accept_terms_of_service: nil, + configuration: :unset, + unique_name: :unset + ) + + data = Twilio::Values.of({ + 'AvailableAddOnSid' => available_add_on_sid, + 'AcceptTermsOfService' => accept_terms_of_service, + 'Configuration' => Twilio.serialize_object(configuration), + 'UniqueName' => unique_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + ) + InstalledAddOnInstanceMetadata.new( + @version, + installedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Lists InstalledAddOnInstance records from the API as a list. @@ -103,6 +143,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InstalledAddOnPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InstalledAddOnPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InstalledAddOnInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +248,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InstalledAddOnInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InstalledAddOnInstanceMetadata.new(@version, installedAddOn_instance, response.headers, response.status_code) end ## @@ -208,6 +289,31 @@ def fetch ) end + ## + # Fetch the InstalledAddOnInstanceMetadata + # @return [InstalledAddOnInstance] Fetched InstalledAddOnInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + InstalledAddOnInstanceMetadata.new( + @version, + installedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Update the InstalledAddOnInstance # @param [Object] configuration Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured @@ -237,6 +343,41 @@ def update( ) end + ## + # Update the InstalledAddOnInstanceMetadata + # @param [Object] configuration Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + # @return [InstalledAddOnInstance] Updated InstalledAddOnInstance + def update_with_metadata( + configuration: :unset, + unique_name: :unset + ) + + data = Twilio::Values.of({ + 'Configuration' => Twilio.serialize_object(configuration), + 'UniqueName' => unique_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + installedAddOn_instance = InstalledAddOnInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + InstalledAddOnInstanceMetadata.new( + @version, + installedAddOn_instance, + response.headers, + response.status_code + ) + end + ## # Access the extensions # @return [InstalledAddOnExtensionList] @@ -272,6 +413,45 @@ def inspect end end + class InstalledAddOnInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InstalledAddOnInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InstalledAddOnInstance] installed_add_on_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InstalledAddOnInstanceMetadata] The initialized instance with metadata. + def initialize(version, installed_add_on_instance, headers, status_code) + super(version, headers, status_code) + @installed_add_on_instance = installed_add_on_instance + end + + def installed_add_on + @installed_add_on_instance + end + + def to_s + "" + end + end + + class InstalledAddOnListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on_instance = payload.body[key].map do |data| + InstalledAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on_instance + @instance + end + end + class InstalledAddOnPage < Page ## # Initialize the InstalledAddOnPage @@ -300,6 +480,54 @@ def to_s '' end end + + class InstalledAddOnPageMetadata < PageMetadata + attr_reader :installed_add_on_page + + def initialize(version, response, solution, limit) + super(version, response) + @installed_add_on_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @installed_add_on_page << InstalledAddOnListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @installed_add_on_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InstalledAddOnListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on = payload.body[key].map do |data| + InstalledAddOnInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on + @installed_add_on + end + end + class InstalledAddOnInstance < InstanceResource ## # Initialize the InstalledAddOnInstance diff --git a/lib/twilio-ruby/rest/preview/marketplace/installed_add_on/installed_add_on_extension.rb b/lib/twilio-ruby/rest/preview/marketplace/installed_add_on/installed_add_on_extension.rb index cad1a974a..6217d9210 100644 --- a/lib/twilio-ruby/rest/preview/marketplace/installed_add_on/installed_add_on_extension.rb +++ b/lib/twilio-ruby/rest/preview/marketplace/installed_add_on/installed_add_on_extension.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InstalledAddOnExtensionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InstalledAddOnExtensionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InstalledAddOnExtensionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the InstalledAddOnExtensionInstanceMetadata + # @return [InstalledAddOnExtensionInstance] Fetched InstalledAddOnExtensionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + installedAddOnExtension_instance = InstalledAddOnExtensionInstance.new( + @version, + response.body, + installed_add_on_sid: @solution[:installed_add_on_sid], + sid: @solution[:sid], + ) + InstalledAddOnExtensionInstanceMetadata.new( + @version, + installedAddOnExtension_instance, + response.headers, + response.status_code + ) + end + ## # Update the InstalledAddOnExtensionInstance # @param [Boolean] enabled Whether the Extension should be invoked. @@ -192,6 +240,39 @@ def update( ) end + ## + # Update the InstalledAddOnExtensionInstanceMetadata + # @param [Boolean] enabled Whether the Extension should be invoked. + # @return [InstalledAddOnExtensionInstance] Updated InstalledAddOnExtensionInstance + def update_with_metadata( + enabled: nil + ) + + data = Twilio::Values.of({ + 'Enabled' => enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + installedAddOnExtension_instance = InstalledAddOnExtensionInstance.new( + @version, + response.body, + installed_add_on_sid: @solution[:installed_add_on_sid], + sid: @solution[:sid], + ) + InstalledAddOnExtensionInstanceMetadata.new( + @version, + installedAddOnExtension_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -208,6 +289,45 @@ def inspect end end + class InstalledAddOnExtensionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InstalledAddOnExtensionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InstalledAddOnExtensionInstance] installed_add_on_extension_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InstalledAddOnExtensionInstanceMetadata] The initialized instance with metadata. + def initialize(version, installed_add_on_extension_instance, headers, status_code) + super(version, headers, status_code) + @installed_add_on_extension_instance = installed_add_on_extension_instance + end + + def installed_add_on_extension + @installed_add_on_extension_instance + end + + def to_s + "" + end + end + + class InstalledAddOnExtensionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on_extension_instance = payload.body[key].map do |data| + InstalledAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on_extension_instance + @instance + end + end + class InstalledAddOnExtensionPage < Page ## # Initialize the InstalledAddOnExtensionPage @@ -236,6 +356,54 @@ def to_s '' end end + + class InstalledAddOnExtensionPageMetadata < PageMetadata + attr_reader :installed_add_on_extension_page + + def initialize(version, response, solution, limit) + super(version, response) + @installed_add_on_extension_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @installed_add_on_extension_page << InstalledAddOnExtensionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @installed_add_on_extension_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InstalledAddOnExtensionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @installed_add_on_extension = payload.body[key].map do |data| + InstalledAddOnExtensionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def installed_add_on_extension + @installed_add_on_extension + end + end + class InstalledAddOnExtensionInstance < InstanceResource ## # Initialize the InstalledAddOnExtensionInstance diff --git a/lib/twilio-ruby/rest/preview/wireless/command.rb b/lib/twilio-ruby/rest/preview/wireless/command.rb index 31f6c36d9..cf148cc36 100644 --- a/lib/twilio-ruby/rest/preview/wireless/command.rb +++ b/lib/twilio-ruby/rest/preview/wireless/command.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CommandInstanceMetadata + # @param [String] command + # @param [String] device + # @param [String] sim + # @param [String] callback_method + # @param [String] callback_url + # @param [String] command_mode + # @param [String] include_sid + # @return [CommandInstance] Created CommandInstance + def create_with_metadata( + command: nil, + device: :unset, + sim: :unset, + callback_method: :unset, + callback_url: :unset, + command_mode: :unset, + include_sid: :unset + ) + + data = Twilio::Values.of({ + 'Command' => command, + 'Device' => device, + 'Sim' => sim, + 'CallbackMethod' => callback_method, + 'CallbackUrl' => callback_url, + 'CommandMode' => command_mode, + 'IncludeSid' => include_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + command_instance = CommandInstance.new( + @version, + response.body, + ) + CommandInstanceMetadata.new( + @version, + command_instance, + response.headers, + response.status_code + ) + end + ## # Lists CommandInstance records from the API as a list. @@ -128,6 +177,36 @@ def stream(device: :unset, sim: :unset, status: :unset, direction: :unset, limit @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CommandPageMetadata records from the API as a list. + # @param [String] device + # @param [String] sim + # @param [String] status + # @param [String] direction + # @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_with_metadata(device: :unset, sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Device' => device, + 'Sim' => sim, + 'Status' => status, + 'Direction' => direction, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CommandPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CommandInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -228,6 +307,31 @@ def fetch ) end + ## + # Fetch the CommandInstanceMetadata + # @return [CommandInstance] Fetched CommandInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + command_instance = CommandInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CommandInstanceMetadata.new( + @version, + command_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -244,6 +348,45 @@ def inspect end end + class CommandInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CommandInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CommandInstance] command_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CommandInstanceMetadata] The initialized instance with metadata. + def initialize(version, command_instance, headers, status_code) + super(version, headers, status_code) + @command_instance = command_instance + end + + def command + @command_instance + end + + def to_s + "" + end + end + + class CommandListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @command_instance = payload.body[key].map do |data| + CommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def command_instance + @instance + end + end + class CommandPage < Page ## # Initialize the CommandPage @@ -272,6 +415,54 @@ def to_s '' end end + + class CommandPageMetadata < PageMetadata + attr_reader :command_page + + def initialize(version, response, solution, limit) + super(version, response) + @command_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @command_page << CommandListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @command_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CommandListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @command = payload.body[key].map do |data| + CommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def command + @command + end + end + class CommandInstance < InstanceResource ## # Initialize the CommandInstance diff --git a/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb b/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb index 87c49cc63..c6a69298a 100644 --- a/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb +++ b/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb @@ -82,6 +82,64 @@ def create( ) end + ## + # Create the RatePlanInstanceMetadata + # @param [String] unique_name + # @param [String] friendly_name + # @param [Boolean] data_enabled + # @param [String] data_limit + # @param [String] data_metering + # @param [Boolean] messaging_enabled + # @param [Boolean] voice_enabled + # @param [Boolean] commands_enabled + # @param [Boolean] national_roaming_enabled + # @param [Array[String]] international_roaming + # @return [RatePlanInstance] Created RatePlanInstance + def create_with_metadata( + unique_name: :unset, + friendly_name: :unset, + data_enabled: :unset, + data_limit: :unset, + data_metering: :unset, + messaging_enabled: :unset, + voice_enabled: :unset, + commands_enabled: :unset, + national_roaming_enabled: :unset, + international_roaming: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'FriendlyName' => friendly_name, + 'DataEnabled' => data_enabled, + 'DataLimit' => data_limit, + 'DataMetering' => data_metering, + 'MessagingEnabled' => messaging_enabled, + 'VoiceEnabled' => voice_enabled, + 'CommandsEnabled' => commands_enabled, + 'NationalRoamingEnabled' => national_roaming_enabled, + 'InternationalRoaming' => Twilio.serialize_list(international_roaming) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + ) + RatePlanInstanceMetadata.new( + @version, + ratePlan_instance, + response.headers, + response.status_code + ) + end + ## # Lists RatePlanInstance records from the API as a list. @@ -121,6 +179,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RatePlanPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RatePlanPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RatePlanInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -203,7 +283,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RatePlanInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RatePlanInstanceMetadata.new(@version, ratePlan_instance, response.headers, response.status_code) end ## @@ -225,6 +324,31 @@ def fetch ) end + ## + # Fetch the RatePlanInstanceMetadata + # @return [RatePlanInstance] Fetched RatePlanInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RatePlanInstanceMetadata.new( + @version, + ratePlan_instance, + response.headers, + response.status_code + ) + end + ## # Update the RatePlanInstance # @param [String] unique_name @@ -254,6 +378,41 @@ def update( ) end + ## + # Update the RatePlanInstanceMetadata + # @param [String] unique_name + # @param [String] friendly_name + # @return [RatePlanInstance] Updated RatePlanInstance + def update_with_metadata( + unique_name: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RatePlanInstanceMetadata.new( + @version, + ratePlan_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -270,6 +429,45 @@ def inspect end end + class RatePlanInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RatePlanInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RatePlanInstance] rate_plan_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RatePlanInstanceMetadata] The initialized instance with metadata. + def initialize(version, rate_plan_instance, headers, status_code) + super(version, headers, status_code) + @rate_plan_instance = rate_plan_instance + end + + def rate_plan + @rate_plan_instance + end + + def to_s + "" + end + end + + class RatePlanListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @rate_plan_instance = payload.body[key].map do |data| + RatePlanInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def rate_plan_instance + @instance + end + end + class RatePlanPage < Page ## # Initialize the RatePlanPage @@ -298,6 +496,54 @@ def to_s '' end end + + class RatePlanPageMetadata < PageMetadata + attr_reader :rate_plan_page + + def initialize(version, response, solution, limit) + super(version, response) + @rate_plan_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @rate_plan_page << RatePlanListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @rate_plan_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RatePlanListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @rate_plan = payload.body[key].map do |data| + RatePlanInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def rate_plan + @rate_plan + end + end + class RatePlanInstance < InstanceResource ## # Initialize the RatePlanInstance diff --git a/lib/twilio-ruby/rest/preview/wireless/sim.rb b/lib/twilio-ruby/rest/preview/wireless/sim.rb index 6ea65cf36..e5bc7bbce 100644 --- a/lib/twilio-ruby/rest/preview/wireless/sim.rb +++ b/lib/twilio-ruby/rest/preview/wireless/sim.rb @@ -89,6 +89,38 @@ def stream(status: :unset, iccid: :unset, rate_plan: :unset, e_id: :unset, sim_r @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SimPageMetadata records from the API as a list. + # @param [String] status + # @param [String] iccid + # @param [String] rate_plan + # @param [String] e_id + # @param [String] sim_registration_code + # @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_with_metadata(status: :unset, iccid: :unset, rate_plan: :unset, e_id: :unset, sim_registration_code: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'Iccid' => iccid, + 'RatePlan' => rate_plan, + 'EId' => e_id, + 'SimRegistrationCode' => sim_registration_code, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SimPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SimInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -192,6 +224,31 @@ def fetch ) end + ## + # Fetch the SimInstanceMetadata + # @return [SimInstance] Fetched SimInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SimInstanceMetadata.new( + @version, + sim_instance, + response.headers, + response.status_code + ) + end + ## # Update the SimInstance # @param [String] unique_name @@ -263,6 +320,83 @@ def update( ) end + ## + # Update the SimInstanceMetadata + # @param [String] unique_name + # @param [String] callback_method + # @param [String] callback_url + # @param [String] friendly_name + # @param [String] rate_plan + # @param [String] status + # @param [String] commands_callback_method + # @param [String] commands_callback_url + # @param [String] sms_fallback_method + # @param [String] sms_fallback_url + # @param [String] sms_method + # @param [String] sms_url + # @param [String] voice_fallback_method + # @param [String] voice_fallback_url + # @param [String] voice_method + # @param [String] voice_url + # @return [SimInstance] Updated SimInstance + def update_with_metadata( + unique_name: :unset, + callback_method: :unset, + callback_url: :unset, + friendly_name: :unset, + rate_plan: :unset, + status: :unset, + commands_callback_method: :unset, + commands_callback_url: :unset, + sms_fallback_method: :unset, + sms_fallback_url: :unset, + sms_method: :unset, + sms_url: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_url: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'CallbackMethod' => callback_method, + 'CallbackUrl' => callback_url, + 'FriendlyName' => friendly_name, + 'RatePlan' => rate_plan, + 'Status' => status, + 'CommandsCallbackMethod' => commands_callback_method, + 'CommandsCallbackUrl' => commands_callback_url, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsMethod' => sms_method, + 'SmsUrl' => sms_url, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceUrl' => voice_url, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SimInstanceMetadata.new( + @version, + sim_instance, + response.headers, + response.status_code + ) + end + ## # Access the usage # @return [UsageList] @@ -289,6 +423,45 @@ def inspect end end + class SimInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SimInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SimInstance] sim_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SimInstanceMetadata] The initialized instance with metadata. + def initialize(version, sim_instance, headers, status_code) + super(version, headers, status_code) + @sim_instance = sim_instance + end + + def sim + @sim_instance + end + + def to_s + "" + end + end + + class SimListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sim_instance = payload.body[key].map do |data| + SimInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sim_instance + @instance + end + end + class SimPage < Page ## # Initialize the SimPage @@ -317,6 +490,54 @@ def to_s '' end end + + class SimPageMetadata < PageMetadata + attr_reader :sim_page + + def initialize(version, response, solution, limit) + super(version, response) + @sim_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sim_page << SimListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sim_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SimListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sim = payload.body[key].map do |data| + SimInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sim + @sim + end + end + class SimInstance < InstanceResource ## # Initialize the SimInstance diff --git a/lib/twilio-ruby/rest/preview/wireless/sim/usage.rb b/lib/twilio-ruby/rest/preview/wireless/sim/usage.rb index 3628f6a90..c862afa9d 100644 --- a/lib/twilio-ruby/rest/preview/wireless/sim/usage.rb +++ b/lib/twilio-ruby/rest/preview/wireless/sim/usage.rb @@ -85,6 +85,40 @@ def fetch( ) end + ## + # Fetch the UsageInstanceMetadata + # @param [String] end_ + # @param [String] start + # @return [UsageInstance] Fetched UsageInstance + def fetch_with_metadata( + end_: :unset, + start: :unset + ) + + params = Twilio::Values.of({ + 'End' => end_, + 'Start' => start, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + usage_instance = UsageInstance.new( + @version, + response.body, + sim_sid: @solution[:sim_sid], + ) + UsageInstanceMetadata.new( + @version, + usage_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -101,6 +135,45 @@ def inspect end end + class UsageInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UsageInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UsageInstance] usage_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UsageInstanceMetadata] The initialized instance with metadata. + def initialize(version, usage_instance, headers, status_code) + super(version, headers, status_code) + @usage_instance = usage_instance + end + + def usage + @usage_instance + end + + def to_s + "" + end + end + + class UsageListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @usage_instance = payload.body[key].map do |data| + UsageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def usage_instance + @instance + end + end + class UsagePage < Page ## # Initialize the UsagePage @@ -129,6 +202,54 @@ def to_s '' end end + + class UsagePageMetadata < PageMetadata + attr_reader :usage_page + + def initialize(version, response, solution, limit) + super(version, response) + @usage_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @usage_page << UsageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @usage_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @usage = payload.body[key].map do |data| + UsageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def usage + @usage + end + end + class UsageInstance < InstanceResource ## # Initialize the UsageInstance diff --git a/lib/twilio-ruby/rest/preview_iam/v1/authorize.rb b/lib/twilio-ruby/rest/preview_iam/v1/authorize.rb index e7e7b11bd..cb35f79a2 100644 --- a/lib/twilio-ruby/rest/preview_iam/v1/authorize.rb +++ b/lib/twilio-ruby/rest/preview_iam/v1/authorize.rb @@ -66,6 +66,48 @@ def fetch( ) end + ## + # Fetch the AuthorizeInstanceMetadata + # @param [String] response_type Response Type + # @param [String] client_id The Client Identifier + # @param [String] redirect_uri The url to which response will be redirected to + # @param [String] scope The scope of the access request + # @param [String] state An opaque value which can be used to maintain state between the request and callback + # @return [AuthorizeInstance] Fetched AuthorizeInstance + def fetch_with_metadata( + response_type: :unset, + client_id: :unset, + redirect_uri: :unset, + scope: :unset, + state: :unset + ) + + params = Twilio::Values.of({ + 'response_type' => response_type, + 'client_id' => client_id, + 'redirect_uri' => redirect_uri, + 'scope' => scope, + 'state' => state, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + authorize_instance = AuthorizeInstance.new( + @version, + response.body, + ) + AuthorizeInstanceMetadata.new( + @version, + authorize_instance, + response.headers, + response.status_code + ) + end + @@ -103,6 +145,54 @@ def to_s '' end end + + class AuthorizePageMetadata < PageMetadata + attr_reader :authorize_page + + def initialize(version, response, solution, limit) + super(version, response) + @authorize_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @authorize_page << AuthorizeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @authorize_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AuthorizeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @authorize = payload.body[key].map do |data| + AuthorizeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def authorize + @authorize + end + end + class AuthorizeInstance < InstanceResource ## # Initialize the AuthorizeInstance diff --git a/lib/twilio-ruby/rest/preview_iam/v1/token.rb b/lib/twilio-ruby/rest/preview_iam/v1/token.rb index 703cddd93..80945fb24 100644 --- a/lib/twilio-ruby/rest/preview_iam/v1/token.rb +++ b/lib/twilio-ruby/rest/preview_iam/v1/token.rb @@ -76,6 +76,58 @@ def create( ) end + ## + # Create the TokenInstanceMetadata + # @param [String] grant_type Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + # @param [String] client_id A 34 character string that uniquely identifies this OAuth App. + # @param [String] client_secret The credential for confidential OAuth App. + # @param [String] code JWT token related to the authorization code grant type. + # @param [String] redirect_uri The redirect uri + # @param [String] audience The targeted audience uri + # @param [String] refresh_token JWT token related to refresh access token. + # @param [String] scope The scope of token + # @return [TokenInstance] Created TokenInstance + def create_with_metadata( + grant_type: nil, + client_id: nil, + client_secret: :unset, + code: :unset, + redirect_uri: :unset, + audience: :unset, + refresh_token: :unset, + scope: :unset + ) + + data = Twilio::Values.of({ + 'grant_type' => grant_type, + 'client_id' => client_id, + 'client_secret' => client_secret, + 'code' => code, + 'redirect_uri' => redirect_uri, + 'audience' => audience, + 'refresh_token' => refresh_token, + 'scope' => scope, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + token_instance = TokenInstance.new( + @version, + response.body, + ) + TokenInstanceMetadata.new( + @version, + token_instance, + response.headers, + response.status_code + ) + end + @@ -113,6 +165,54 @@ def to_s '' end end + + class TokenPageMetadata < PageMetadata + attr_reader :token_page + + def initialize(version, response, solution, limit) + super(version, response) + @token_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @token_page << TokenListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @token_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TokenListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @token = payload.body[key].map do |data| + TokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def token + @token + end + end + class TokenInstance < InstanceResource ## # Initialize the TokenInstance diff --git a/lib/twilio-ruby/rest/preview_iam/versionless/organization.rb b/lib/twilio-ruby/rest/preview_iam/versionless/organization.rb index ea78a873c..ff1b7e278 100644 --- a/lib/twilio-ruby/rest/preview_iam/versionless/organization.rb +++ b/lib/twilio-ruby/rest/preview_iam/versionless/organization.rb @@ -78,6 +78,31 @@ def fetch ) end + ## + # Fetch the OrganizationInstanceMetadata + # @return [OrganizationInstance] Fetched OrganizationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + headers['Accept'] = 'application/scim+json' + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + organization_instance = OrganizationInstance.new( + @version, + response.body, + organization_sid: @solution[:organization_sid], + ) + OrganizationInstanceMetadata.new( + @version, + organization_instance, + response.headers, + response.status_code + ) + end + ## # Access the resource_types # @return [ResourceTypeList] @@ -162,6 +187,45 @@ def inspect end end + class OrganizationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OrganizationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OrganizationInstance] organization_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OrganizationInstanceMetadata] The initialized instance with metadata. + def initialize(version, organization_instance, headers, status_code) + super(version, headers, status_code) + @organization_instance = organization_instance + end + + def organization + @organization_instance + end + + def to_s + "" + end + end + + class OrganizationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @organization_instance = payload.body[key].map do |data| + OrganizationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def organization_instance + @instance + end + end + class OrganizationPage < Page ## # Initialize the OrganizationPage @@ -190,6 +254,54 @@ def to_s '' end end + + class OrganizationPageMetadata < PageMetadata + attr_reader :organization_page + + def initialize(version, response, solution, limit) + super(version, response) + @organization_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @organization_page << OrganizationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @organization_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OrganizationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @organization = payload.body[key].map do |data| + OrganizationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def organization + @organization + end + end + class OrganizationInstance < InstanceResource ## # Initialize the OrganizationInstance diff --git a/lib/twilio-ruby/rest/preview_iam/versionless/organization/account.rb b/lib/twilio-ruby/rest/preview_iam/versionless/organization/account.rb index a5638174d..952b79d51 100644 --- a/lib/twilio-ruby/rest/preview_iam/versionless/organization/account.rb +++ b/lib/twilio-ruby/rest/preview_iam/versionless/organization/account.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AccountPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AccountPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AccountInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the AccountInstanceMetadata + # @return [AccountInstance] Fetched AccountInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + account_instance = AccountInstance.new( + @version, + response.body, + organization_sid: @solution[:organization_sid], + account_sid: @solution[:account_sid], + ) + AccountInstanceMetadata.new( + @version, + account_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class AccountInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AccountInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AccountInstance] account_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AccountInstanceMetadata] The initialized instance with metadata. + def initialize(version, account_instance, headers, status_code) + super(version, headers, status_code) + @account_instance = account_instance + end + + def account + @account_instance + end + + def to_s + "" + end + end + + class AccountListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @account_instance = payload.body[key].map do |data| + AccountInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def account_instance + @instance + end + end + class AccountPage < Page ## # Initialize the AccountPage @@ -209,6 +296,54 @@ def to_s '' end end + + class AccountPageMetadata < PageMetadata + attr_reader :account_page + + def initialize(version, response, solution, limit) + super(version, response) + @account_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @account_page << AccountListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @account_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AccountListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @account = payload.body[key].map do |data| + AccountInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def account + @account + end + end + class AccountInstance < InstanceResource ## # Initialize the AccountInstance diff --git a/lib/twilio-ruby/rest/preview_iam/versionless/organization/role_assignment.rb b/lib/twilio-ruby/rest/preview_iam/versionless/organization/role_assignment.rb index 88a36532e..a48e6be8e 100644 --- a/lib/twilio-ruby/rest/preview_iam/versionless/organization/role_assignment.rb +++ b/lib/twilio-ruby/rest/preview_iam/versionless/organization/role_assignment.rb @@ -73,6 +73,33 @@ def create(public_api_create_role_assignment_request: nil ) end + ## + # Create the RoleAssignmentInstanceMetadata + # @param [PublicApiCreateRoleAssignmentRequest] public_api_create_role_assignment_request + # @return [RoleAssignmentInstance] Created RoleAssignmentInstance + def create_with_metadata(public_api_create_role_assignment_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + headers['Accept'] = '*/*' + response = @version.create_with_metadata('POST', @uri, headers: headers, data: public_api_create_role_assignment_request.to_json) + roleAssignment_instance = RoleAssignmentInstance.new( + @version, + response.body, + organization_sid: @solution[:organization_sid], + ) + RoleAssignmentInstanceMetadata.new( + @version, + roleAssignment_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoleAssignmentInstance records from the API as a list. @@ -120,6 +147,32 @@ def stream(identity: :unset, scope: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RoleAssignmentPageMetadata records from the API as a list. + # @param [String] identity + # @param [String] scope + # @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_with_metadata(identity: :unset, scope: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Identity' => identity, + 'Scope' => scope, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RoleAssignmentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoleAssignmentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -207,7 +260,26 @@ def delete headers['Accept'] = '*/*' - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoleAssignmentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + headers['Accept'] = '*/*' + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + roleAssignment_instance = RoleAssignmentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoleAssignmentInstanceMetadata.new(@version, roleAssignment_instance, response.headers, response.status_code) end @@ -226,6 +298,45 @@ def inspect end end + class RoleAssignmentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoleAssignmentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoleAssignmentInstance] role_assignment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoleAssignmentInstanceMetadata] The initialized instance with metadata. + def initialize(version, role_assignment_instance, headers, status_code) + super(version, headers, status_code) + @role_assignment_instance = role_assignment_instance + end + + def role_assignment + @role_assignment_instance + end + + def to_s + "" + end + end + + class RoleAssignmentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_assignment_instance = payload.body[key].map do |data| + RoleAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_assignment_instance + @instance + end + end + class RoleAssignmentPage < Page ## # Initialize the RoleAssignmentPage @@ -254,6 +365,54 @@ def to_s '' end end + + class RoleAssignmentPageMetadata < PageMetadata + attr_reader :role_assignment_page + + def initialize(version, response, solution, limit) + super(version, response) + @role_assignment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @role_assignment_page << RoleAssignmentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @role_assignment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoleAssignmentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @role_assignment = payload.body[key].map do |data| + RoleAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def role_assignment + @role_assignment + end + end + class RoleAssignmentInstance < InstanceResource ## # Initialize the RoleAssignmentInstance diff --git a/lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb b/lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb index d6dd5d84a..7949e53cb 100644 --- a/lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb +++ b/lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb @@ -112,6 +112,33 @@ def create(scim_user: nil ) end + ## + # Create the UserInstanceMetadata + # @param [ScimUser] scim_user + # @return [UserInstance] Created UserInstance + def create_with_metadata(scim_user: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + headers['Content-Type'] = 'application/scim+json' + + headers['Accept'] = 'application/scim+json' + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: scim_user.to_json) + user_instance = UserInstance.new( + @version, + response.body, + organization_sid: @solution[:organization_sid], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Lists UserInstance records from the API as a list. @@ -155,6 +182,30 @@ def stream(filter: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UserPageMetadata records from the API as a list. + # @param [String] filter + # @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_with_metadata(filter: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'filter' => filter, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -240,7 +291,26 @@ def delete headers['Accept'] = '*/*' - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the UserInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + headers['Accept'] = '*/*' + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code) end ## @@ -263,6 +333,32 @@ def fetch ) end + ## + # Fetch the UserInstanceMetadata + # @return [UserInstance] Fetched UserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + headers['Accept'] = 'application/scim+json' + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + user_instance = UserInstance.new( + @version, + response.body, + organization_sid: @solution[:organization_sid], + id: @solution[:id], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Update the UserInstance # @param [String] if_match @@ -287,6 +383,36 @@ def update( ) end + ## + # Update the UserInstanceMetadata + # @param [String] if_match + # @param [ScimUser] scim_user + # @return [UserInstance] Updated UserInstance + def update_with_metadata( + if_match: :unset,scim_user: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + headers['Content-Type'] = 'application/scim+json' + + headers['Accept'] = 'application/scim+json' + + response = @version.update_with_metadata('PUT', @uri, headers: headers, data: scim_user.to_json) + user_instance = UserInstance.new( + @version, + response.body, + organization_sid: @solution[:organization_sid], + id: @solution[:id], + ) + UserInstanceMetadata.new( + @version, + user_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -303,6 +429,45 @@ def inspect end end + class UserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new UserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}UserInstance] user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [UserInstanceMetadata] The initialized instance with metadata. + def initialize(version, user_instance, headers, status_code) + super(version, headers, status_code) + @user_instance = user_instance + end + + def user + @user_instance + end + + def to_s + "" + end + end + + class UserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user_instance = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user_instance + @instance + end + end + class UserPage < Page ## # Initialize the UserPage @@ -331,6 +496,54 @@ def to_s '' end end + + class UserPageMetadata < PageMetadata + attr_reader :user_page + + def initialize(version, response, solution, limit) + super(version, response) + @user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @user_page << UserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @user = payload.body[key].map do |data| + UserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def user + @user + end + end + class UserInstance < InstanceResource ## # Initialize the UserInstance diff --git a/lib/twilio-ruby/rest/pricing/v1/messaging.rb b/lib/twilio-ruby/rest/pricing/v1/messaging.rb index f885193c5..acfe14deb 100644 --- a/lib/twilio-ruby/rest/pricing/v1/messaging.rb +++ b/lib/twilio-ruby/rest/pricing/v1/messaging.rb @@ -81,6 +81,54 @@ def to_s '' end end + + class MessagingPageMetadata < PageMetadata + attr_reader :messaging_page + + def initialize(version, response, solution, limit) + super(version, response) + @messaging_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @messaging_page << MessagingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @messaging_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessagingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @messaging = payload.body[key].map do |data| + MessagingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def messaging + @messaging + end + end + class MessagingInstance < InstanceResource ## # Initialize the MessagingInstance diff --git a/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb b/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb index 6e8c62ca1..d4170b31e 100644 --- a/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb +++ b/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CountryPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CountryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CountryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,6 +185,31 @@ def fetch ) end + ## + # Fetch the CountryInstanceMetadata + # @return [CountryInstance] Fetched CountryInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + country_instance = CountryInstance.new( + @version, + response.body, + iso_country: @solution[:iso_country], + ) + CountryInstanceMetadata.new( + @version, + country_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -179,6 +226,45 @@ def inspect end end + class CountryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CountryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CountryInstance] country_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CountryInstanceMetadata] The initialized instance with metadata. + def initialize(version, country_instance, headers, status_code) + super(version, headers, status_code) + @country_instance = country_instance + end + + def country + @country_instance + end + + def to_s + "" + end + end + + class CountryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country_instance = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country_instance + @instance + end + end + class CountryPage < Page ## # Initialize the CountryPage @@ -207,6 +293,54 @@ def to_s '' end end + + class CountryPageMetadata < PageMetadata + attr_reader :country_page + + def initialize(version, response, solution, limit) + super(version, response) + @country_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @country_page << CountryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @country_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CountryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country + @country + end + end + class CountryInstance < InstanceResource ## # Initialize the CountryInstance diff --git a/lib/twilio-ruby/rest/pricing/v1/phone_number.rb b/lib/twilio-ruby/rest/pricing/v1/phone_number.rb index 65627a36e..544f10a01 100644 --- a/lib/twilio-ruby/rest/pricing/v1/phone_number.rb +++ b/lib/twilio-ruby/rest/pricing/v1/phone_number.rb @@ -81,6 +81,54 @@ def to_s '' end end + + class PhoneNumberPageMetadata < PageMetadata + attr_reader :phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @phone_number_page << PhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number + @phone_number + end + end + class PhoneNumberInstance < InstanceResource ## # Initialize the PhoneNumberInstance diff --git a/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb b/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb index 91b3f8510..b3f677f13 100644 --- a/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb +++ b/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CountryPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CountryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CountryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,6 +185,31 @@ def fetch ) end + ## + # Fetch the CountryInstanceMetadata + # @return [CountryInstance] Fetched CountryInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + country_instance = CountryInstance.new( + @version, + response.body, + iso_country: @solution[:iso_country], + ) + CountryInstanceMetadata.new( + @version, + country_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -179,6 +226,45 @@ def inspect end end + class CountryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CountryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CountryInstance] country_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CountryInstanceMetadata] The initialized instance with metadata. + def initialize(version, country_instance, headers, status_code) + super(version, headers, status_code) + @country_instance = country_instance + end + + def country + @country_instance + end + + def to_s + "" + end + end + + class CountryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country_instance = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country_instance + @instance + end + end + class CountryPage < Page ## # Initialize the CountryPage @@ -207,6 +293,54 @@ def to_s '' end end + + class CountryPageMetadata < PageMetadata + attr_reader :country_page + + def initialize(version, response, solution, limit) + super(version, response) + @country_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @country_page << CountryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @country_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CountryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country + @country + end + end + class CountryInstance < InstanceResource ## # Initialize the CountryInstance diff --git a/lib/twilio-ruby/rest/pricing/v1/voice.rb b/lib/twilio-ruby/rest/pricing/v1/voice.rb index 59b060233..502765e2e 100644 --- a/lib/twilio-ruby/rest/pricing/v1/voice.rb +++ b/lib/twilio-ruby/rest/pricing/v1/voice.rb @@ -95,6 +95,54 @@ def to_s '' end end + + class VoicePageMetadata < PageMetadata + attr_reader :voice_page + + def initialize(version, response, solution, limit) + super(version, response) + @voice_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @voice_page << VoiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @voice_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VoiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @voice = payload.body[key].map do |data| + VoiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def voice + @voice + end + end + class VoiceInstance < InstanceResource ## # Initialize the VoiceInstance diff --git a/lib/twilio-ruby/rest/pricing/v1/voice/country.rb b/lib/twilio-ruby/rest/pricing/v1/voice/country.rb index 93a53f80d..9030ad7a5 100644 --- a/lib/twilio-ruby/rest/pricing/v1/voice/country.rb +++ b/lib/twilio-ruby/rest/pricing/v1/voice/country.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CountryPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CountryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CountryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,6 +185,31 @@ def fetch ) end + ## + # Fetch the CountryInstanceMetadata + # @return [CountryInstance] Fetched CountryInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + country_instance = CountryInstance.new( + @version, + response.body, + iso_country: @solution[:iso_country], + ) + CountryInstanceMetadata.new( + @version, + country_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -179,6 +226,45 @@ def inspect end end + class CountryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CountryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CountryInstance] country_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CountryInstanceMetadata] The initialized instance with metadata. + def initialize(version, country_instance, headers, status_code) + super(version, headers, status_code) + @country_instance = country_instance + end + + def country + @country_instance + end + + def to_s + "" + end + end + + class CountryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country_instance = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country_instance + @instance + end + end + class CountryPage < Page ## # Initialize the CountryPage @@ -207,6 +293,54 @@ def to_s '' end end + + class CountryPageMetadata < PageMetadata + attr_reader :country_page + + def initialize(version, response, solution, limit) + super(version, response) + @country_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @country_page << CountryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @country_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CountryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country + @country + end + end + class CountryInstance < InstanceResource ## # Initialize the CountryInstance diff --git a/lib/twilio-ruby/rest/pricing/v1/voice/number.rb b/lib/twilio-ruby/rest/pricing/v1/voice/number.rb index e73b3bd21..a9baeaf85 100644 --- a/lib/twilio-ruby/rest/pricing/v1/voice/number.rb +++ b/lib/twilio-ruby/rest/pricing/v1/voice/number.rb @@ -76,6 +76,31 @@ def fetch ) end + ## + # Fetch the NumberInstanceMetadata + # @return [NumberInstance] Fetched NumberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + number_instance = NumberInstance.new( + @version, + response.body, + number: @solution[:number], + ) + NumberInstanceMetadata.new( + @version, + number_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -92,6 +117,45 @@ def inspect end end + class NumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NumberInstance] number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, number_instance, headers, status_code) + super(version, headers, status_code) + @number_instance = number_instance + end + + def number + @number_instance + end + + def to_s + "" + end + end + + class NumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @number_instance = payload.body[key].map do |data| + NumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def number_instance + @instance + end + end + class NumberPage < Page ## # Initialize the NumberPage @@ -120,6 +184,54 @@ def to_s '' end end + + class NumberPageMetadata < PageMetadata + attr_reader :number_page + + def initialize(version, response, solution, limit) + super(version, response) + @number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @number_page << NumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @number = payload.body[key].map do |data| + NumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def number + @number + end + end + class NumberInstance < InstanceResource ## # Initialize the NumberInstance diff --git a/lib/twilio-ruby/rest/pricing/v2/country.rb b/lib/twilio-ruby/rest/pricing/v2/country.rb index 8970589e6..591f52b87 100644 --- a/lib/twilio-ruby/rest/pricing/v2/country.rb +++ b/lib/twilio-ruby/rest/pricing/v2/country.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CountryPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CountryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CountryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -161,6 +183,31 @@ def fetch ) end + ## + # Fetch the CountryInstanceMetadata + # @return [CountryInstance] Fetched CountryInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + country_instance = CountryInstance.new( + @version, + response.body, + iso_country: @solution[:iso_country], + ) + CountryInstanceMetadata.new( + @version, + country_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -177,6 +224,45 @@ def inspect end end + class CountryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CountryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CountryInstance] country_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CountryInstanceMetadata] The initialized instance with metadata. + def initialize(version, country_instance, headers, status_code) + super(version, headers, status_code) + @country_instance = country_instance + end + + def country + @country_instance + end + + def to_s + "" + end + end + + class CountryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country_instance = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country_instance + @instance + end + end + class CountryPage < Page ## # Initialize the CountryPage @@ -205,6 +291,54 @@ def to_s '' end end + + class CountryPageMetadata < PageMetadata + attr_reader :country_page + + def initialize(version, response, solution, limit) + super(version, response) + @country_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @country_page << CountryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @country_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CountryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country + @country + end + end + class CountryInstance < InstanceResource ## # Initialize the CountryInstance diff --git a/lib/twilio-ruby/rest/pricing/v2/number.rb b/lib/twilio-ruby/rest/pricing/v2/number.rb index 2583c5a72..1b0168374 100644 --- a/lib/twilio-ruby/rest/pricing/v2/number.rb +++ b/lib/twilio-ruby/rest/pricing/v2/number.rb @@ -80,6 +80,37 @@ def fetch( ) end + ## + # Fetch the NumberInstanceMetadata + # @param [String] origination_number The origination phone number, in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, for which to fetch the origin-based voice pricing information. E.164 format consists of a + followed by the country code and subscriber number. + # @return [NumberInstance] Fetched NumberInstance + def fetch_with_metadata( + origination_number: :unset + ) + + params = Twilio::Values.of({ + 'OriginationNumber' => origination_number, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + number_instance = NumberInstance.new( + @version, + response.body, + destination_number: @solution[:destination_number], + ) + NumberInstanceMetadata.new( + @version, + number_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -96,6 +127,45 @@ def inspect end end + class NumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NumberInstance] number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, number_instance, headers, status_code) + super(version, headers, status_code) + @number_instance = number_instance + end + + def number + @number_instance + end + + def to_s + "" + end + end + + class NumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @number_instance = payload.body[key].map do |data| + NumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def number_instance + @instance + end + end + class NumberPage < Page ## # Initialize the NumberPage @@ -124,6 +194,54 @@ def to_s '' end end + + class NumberPageMetadata < PageMetadata + attr_reader :number_page + + def initialize(version, response, solution, limit) + super(version, response) + @number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @number_page << NumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @number = payload.body[key].map do |data| + NumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def number + @number + end + end + class NumberInstance < InstanceResource ## # Initialize the NumberInstance diff --git a/lib/twilio-ruby/rest/pricing/v2/voice.rb b/lib/twilio-ruby/rest/pricing/v2/voice.rb index ee8cd539c..79f290f93 100644 --- a/lib/twilio-ruby/rest/pricing/v2/voice.rb +++ b/lib/twilio-ruby/rest/pricing/v2/voice.rb @@ -95,6 +95,54 @@ def to_s '' end end + + class VoicePageMetadata < PageMetadata + attr_reader :voice_page + + def initialize(version, response, solution, limit) + super(version, response) + @voice_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @voice_page << VoiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @voice_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VoiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @voice = payload.body[key].map do |data| + VoiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def voice + @voice + end + end + class VoiceInstance < InstanceResource ## # Initialize the VoiceInstance diff --git a/lib/twilio-ruby/rest/pricing/v2/voice/country.rb b/lib/twilio-ruby/rest/pricing/v2/voice/country.rb index fa541d200..3742b716d 100644 --- a/lib/twilio-ruby/rest/pricing/v2/voice/country.rb +++ b/lib/twilio-ruby/rest/pricing/v2/voice/country.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CountryPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CountryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CountryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -163,6 +185,31 @@ def fetch ) end + ## + # Fetch the CountryInstanceMetadata + # @return [CountryInstance] Fetched CountryInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + country_instance = CountryInstance.new( + @version, + response.body, + iso_country: @solution[:iso_country], + ) + CountryInstanceMetadata.new( + @version, + country_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -179,6 +226,45 @@ def inspect end end + class CountryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CountryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CountryInstance] country_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CountryInstanceMetadata] The initialized instance with metadata. + def initialize(version, country_instance, headers, status_code) + super(version, headers, status_code) + @country_instance = country_instance + end + + def country + @country_instance + end + + def to_s + "" + end + end + + class CountryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country_instance = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country_instance + @instance + end + end + class CountryPage < Page ## # Initialize the CountryPage @@ -207,6 +293,54 @@ def to_s '' end end + + class CountryPageMetadata < PageMetadata + attr_reader :country_page + + def initialize(version, response, solution, limit) + super(version, response) + @country_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @country_page << CountryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @country_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CountryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country + @country + end + end + class CountryInstance < InstanceResource ## # Initialize the CountryInstance diff --git a/lib/twilio-ruby/rest/pricing/v2/voice/number.rb b/lib/twilio-ruby/rest/pricing/v2/voice/number.rb index 8dd48ddcb..4f6cfc380 100644 --- a/lib/twilio-ruby/rest/pricing/v2/voice/number.rb +++ b/lib/twilio-ruby/rest/pricing/v2/voice/number.rb @@ -82,6 +82,37 @@ def fetch( ) end + ## + # Fetch the NumberInstanceMetadata + # @param [String] origination_number The origination phone number, in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, for which to fetch the origin-based voice pricing information. E.164 format consists of a + followed by the country code and subscriber number. + # @return [NumberInstance] Fetched NumberInstance + def fetch_with_metadata( + origination_number: :unset + ) + + params = Twilio::Values.of({ + 'OriginationNumber' => origination_number, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + number_instance = NumberInstance.new( + @version, + response.body, + destination_number: @solution[:destination_number], + ) + NumberInstanceMetadata.new( + @version, + number_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +129,45 @@ def inspect end end + class NumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NumberInstance] number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, number_instance, headers, status_code) + super(version, headers, status_code) + @number_instance = number_instance + end + + def number + @number_instance + end + + def to_s + "" + end + end + + class NumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @number_instance = payload.body[key].map do |data| + NumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def number_instance + @instance + end + end + class NumberPage < Page ## # Initialize the NumberPage @@ -126,6 +196,54 @@ def to_s '' end end + + class NumberPageMetadata < PageMetadata + attr_reader :number_page + + def initialize(version, response, solution, limit) + super(version, response) + @number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @number_page << NumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @number = payload.body[key].map do |data| + NumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def number + @number + end + end + class NumberInstance < InstanceResource ## # Initialize the NumberInstance diff --git a/lib/twilio-ruby/rest/proxy/v1/service.rb b/lib/twilio-ruby/rest/proxy/v1/service.rb index 4442b14da..3579e9e6e 100644 --- a/lib/twilio-ruby/rest/proxy/v1/service.rb +++ b/lib/twilio-ruby/rest/proxy/v1/service.rb @@ -76,6 +76,58 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.** + # @param [String] default_ttl The default `ttl` value to set for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session's last create or last Interaction. The default value of `0` indicates an unlimited Session length. You can override a Session's default TTL value by setting its `ttl` value. + # @param [String] callback_url The URL we should call when the interaction status changes. + # @param [GeoMatchLevel] geo_match_level + # @param [NumberSelectionBehavior] number_selection_behavior + # @param [String] intercept_callback_url The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. + # @param [String] out_of_session_callback_url The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + # @param [String] chat_instance_sid The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + unique_name: nil, + default_ttl: :unset, + callback_url: :unset, + geo_match_level: :unset, + number_selection_behavior: :unset, + intercept_callback_url: :unset, + out_of_session_callback_url: :unset, + chat_instance_sid: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'DefaultTtl' => default_ttl, + 'CallbackUrl' => callback_url, + 'GeoMatchLevel' => geo_match_level, + 'NumberSelectionBehavior' => number_selection_behavior, + 'InterceptCallbackUrl' => intercept_callback_url, + 'OutOfSessionCallbackUrl' => out_of_session_callback_url, + 'ChatInstanceSid' => chat_instance_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -115,6 +167,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -199,7 +273,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -221,6 +314,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.** @@ -268,6 +386,59 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.** + # @param [String] default_ttl The default `ttl` value to set for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session's last create or last Interaction. The default value of `0` indicates an unlimited Session length. You can override a Session's default TTL value by setting its `ttl` value. + # @param [String] callback_url The URL we should call when the interaction status changes. + # @param [GeoMatchLevel] geo_match_level + # @param [NumberSelectionBehavior] number_selection_behavior + # @param [String] intercept_callback_url The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. + # @param [String] out_of_session_callback_url The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + # @param [String] chat_instance_sid The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + unique_name: :unset, + default_ttl: :unset, + callback_url: :unset, + geo_match_level: :unset, + number_selection_behavior: :unset, + intercept_callback_url: :unset, + out_of_session_callback_url: :unset, + chat_instance_sid: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'DefaultTtl' => default_ttl, + 'CallbackUrl' => callback_url, + 'GeoMatchLevel' => geo_match_level, + 'NumberSelectionBehavior' => number_selection_behavior, + 'InterceptCallbackUrl' => intercept_callback_url, + 'OutOfSessionCallbackUrl' => out_of_session_callback_url, + 'ChatInstanceSid' => chat_instance_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the sessions # @return [SessionList] @@ -322,6 +493,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -350,6 +560,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb b/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb index 9c46b978e..42efa8ce5 100644 --- a/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +++ b/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the PhoneNumberInstanceMetadata + # @param [String] sid The SID of a Twilio [IncomingPhoneNumber](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource) resource that represents the Twilio Number you would like to assign to your Proxy Service. + # @param [String] phone_number The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234. + # @param [Boolean] is_reserved Whether the new phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. + # @return [PhoneNumberInstance] Created PhoneNumberInstance + def create_with_metadata( + sid: :unset, + phone_number: :unset, + is_reserved: :unset + ) + + data = Twilio::Values.of({ + 'Sid' => sid, + 'PhoneNumber' => phone_number, + 'IsReserved' => is_reserved, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Lists PhoneNumberInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PhoneNumberPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PhoneNumberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PhoneNumberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +246,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PhoneNumberInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PhoneNumberInstanceMetadata.new(@version, phoneNumber_instance, response.headers, response.status_code) end ## @@ -209,6 +288,32 @@ def fetch ) end + ## + # Fetch the PhoneNumberInstanceMetadata + # @return [PhoneNumberInstance] Fetched PhoneNumberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Update the PhoneNumberInstance # @param [Boolean] is_reserved Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. @@ -236,6 +341,39 @@ def update( ) end + ## + # Update the PhoneNumberInstanceMetadata + # @param [Boolean] is_reserved Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. + # @return [PhoneNumberInstance] Updated PhoneNumberInstance + def update_with_metadata( + is_reserved: :unset + ) + + data = Twilio::Values.of({ + 'IsReserved' => is_reserved, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -252,6 +390,45 @@ def inspect end end + class PhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PhoneNumberInstance] phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, phone_number_instance, headers, status_code) + super(version, headers, status_code) + @phone_number_instance = phone_number_instance + end + + def phone_number + @phone_number_instance + end + + def to_s + "" + end + end + + class PhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number_instance = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number_instance + @instance + end + end + class PhoneNumberPage < Page ## # Initialize the PhoneNumberPage @@ -280,6 +457,54 @@ def to_s '' end end + + class PhoneNumberPageMetadata < PageMetadata + attr_reader :phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @phone_number_page << PhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number + @phone_number + end + end + class PhoneNumberInstance < InstanceResource ## # Initialize the PhoneNumberInstance diff --git a/lib/twilio-ruby/rest/proxy/v1/service/session.rb b/lib/twilio-ruby/rest/proxy/v1/service/session.rb index 575f7c911..6031125bf 100644 --- a/lib/twilio-ruby/rest/proxy/v1/service/session.rb +++ b/lib/twilio-ruby/rest/proxy/v1/service/session.rb @@ -73,6 +73,53 @@ def create( ) end + ## + # Create the SessionInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.** + # @param [Time] date_expiry The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session should expire. If this is value is present, it overrides the `ttl` value. + # @param [String] ttl The time, in seconds, when the session will expire. The time is measured from the last Session create or the Session's last Interaction. + # @param [Mode] mode + # @param [Status] status + # @param [Array[Hash]] participants The Participant objects to include in the new session. + # @return [SessionInstance] Created SessionInstance + def create_with_metadata( + unique_name: :unset, + date_expiry: :unset, + ttl: :unset, + mode: :unset, + status: :unset, + participants: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'DateExpiry' => Twilio.serialize_iso8601_datetime(date_expiry), + 'Ttl' => ttl, + 'Mode' => mode, + 'Status' => status, + 'Participants' => Twilio.serialize_list(participants) { |e| Twilio.serialize_object(e) }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + session_instance = SessionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + SessionInstanceMetadata.new( + @version, + session_instance, + response.headers, + response.status_code + ) + end + ## # Lists SessionInstance records from the API as a list. @@ -112,6 +159,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SessionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SessionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SessionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -197,7 +266,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SessionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + session_instance = SessionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SessionInstanceMetadata.new(@version, session_instance, response.headers, response.status_code) end ## @@ -220,6 +308,32 @@ def fetch ) end + ## + # Fetch the SessionInstanceMetadata + # @return [SessionInstance] Fetched SessionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + session_instance = SessionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SessionInstanceMetadata.new( + @version, + session_instance, + response.headers, + response.status_code + ) + end + ## # Update the SessionInstance # @param [Time] date_expiry The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session should expire. If this is value is present, it overrides the `ttl` value. @@ -253,6 +367,45 @@ def update( ) end + ## + # Update the SessionInstanceMetadata + # @param [Time] date_expiry The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session should expire. If this is value is present, it overrides the `ttl` value. + # @param [String] ttl The time, in seconds, when the session will expire. The time is measured from the last Session create or the Session's last Interaction. + # @param [Status] status + # @return [SessionInstance] Updated SessionInstance + def update_with_metadata( + date_expiry: :unset, + ttl: :unset, + status: :unset + ) + + data = Twilio::Values.of({ + 'DateExpiry' => Twilio.serialize_iso8601_datetime(date_expiry), + 'Ttl' => ttl, + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + session_instance = SessionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SessionInstanceMetadata.new( + @version, + session_instance, + response.headers, + response.status_code + ) + end + ## # Access the interactions # @return [InteractionList] @@ -307,6 +460,45 @@ def inspect end end + class SessionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SessionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SessionInstance] session_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SessionInstanceMetadata] The initialized instance with metadata. + def initialize(version, session_instance, headers, status_code) + super(version, headers, status_code) + @session_instance = session_instance + end + + def session + @session_instance + end + + def to_s + "" + end + end + + class SessionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @session_instance = payload.body[key].map do |data| + SessionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def session_instance + @instance + end + end + class SessionPage < Page ## # Initialize the SessionPage @@ -335,6 +527,54 @@ def to_s '' end end + + class SessionPageMetadata < PageMetadata + attr_reader :session_page + + def initialize(version, response, solution, limit) + super(version, response) + @session_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @session_page << SessionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @session_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SessionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @session = payload.body[key].map do |data| + SessionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def session + @session + end + end + class SessionInstance < InstanceResource ## # Initialize the SessionInstance diff --git a/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb b/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb index b032028b6..e24fbc6c4 100644 --- a/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb +++ b/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists InteractionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + InteractionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields InteractionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the InteractionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + interaction_instance = InteractionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + InteractionInstanceMetadata.new(@version, interaction_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the InteractionInstanceMetadata + # @return [InteractionInstance] Fetched InteractionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + interaction_instance = InteractionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + session_sid: @solution[:session_sid], + sid: @solution[:sid], + ) + InteractionInstanceMetadata.new( + @version, + interaction_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -196,6 +264,45 @@ def inspect end end + class InteractionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new InteractionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}InteractionInstance] interaction_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [InteractionInstanceMetadata] The initialized instance with metadata. + def initialize(version, interaction_instance, headers, status_code) + super(version, headers, status_code) + @interaction_instance = interaction_instance + end + + def interaction + @interaction_instance + end + + def to_s + "" + end + end + + class InteractionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction_instance = payload.body[key].map do |data| + InteractionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction_instance + @instance + end + end + class InteractionPage < Page ## # Initialize the InteractionPage @@ -224,6 +331,54 @@ def to_s '' end end + + class InteractionPageMetadata < PageMetadata + attr_reader :interaction_page + + def initialize(version, response, solution, limit) + super(version, response) + @interaction_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @interaction_page << InteractionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @interaction_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class InteractionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @interaction = payload.body[key].map do |data| + InteractionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def interaction + @interaction + end + end + class InteractionInstance < InstanceResource ## # Initialize the InteractionInstance diff --git a/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb b/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb index 5ca8ecfa1..b28890c64 100644 --- a/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +++ b/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb @@ -69,6 +69,48 @@ def create( ) end + ## + # Create the ParticipantInstanceMetadata + # @param [String] identifier The phone number of the Participant. + # @param [String] friendly_name The string that you assigned to describe the participant. This value must be 255 characters or fewer. **This value should not have PII.** + # @param [String] proxy_identifier The proxy phone number to use for the Participant. If not specified, Proxy will select a number from the pool. + # @param [String] proxy_identifier_sid The SID of the Proxy Identifier to assign to the Participant. + # @return [ParticipantInstance] Created ParticipantInstance + def create_with_metadata( + identifier: nil, + friendly_name: :unset, + proxy_identifier: :unset, + proxy_identifier_sid: :unset + ) + + data = Twilio::Values.of({ + 'Identifier' => identifier, + 'FriendlyName' => friendly_name, + 'ProxyIdentifier' => proxy_identifier, + 'ProxyIdentifierSid' => proxy_identifier_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + session_sid: @solution[:session_sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Lists ParticipantInstance records from the API as a list. @@ -108,6 +150,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,7 +257,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ParticipantInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new(@version, participant_instance, response.headers, response.status_code) end ## @@ -217,6 +300,33 @@ def fetch ) end + ## + # Fetch the ParticipantInstanceMetadata + # @return [ParticipantInstance] Fetched ParticipantInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + session_sid: @solution[:session_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Access the message_interactions # @return [MessageInteractionList] @@ -252,6 +362,45 @@ def inspect end end + class ParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ParticipantInstance] participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, participant_instance, headers, status_code) + super(version, headers, status_code) + @participant_instance = participant_instance + end + + def participant + @participant_instance + end + + def to_s + "" + end + end + + class ParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_instance = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_instance + @instance + end + end + class ParticipantPage < Page ## # Initialize the ParticipantPage @@ -280,6 +429,54 @@ def to_s '' end end + + class ParticipantPageMetadata < PageMetadata + attr_reader :participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_page << ParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant + @participant + end + end + class ParticipantInstance < InstanceResource ## # Initialize the ParticipantInstance diff --git a/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb b/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb index 7d560a3ab..dc69b8942 100644 --- a/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb +++ b/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb @@ -65,6 +65,43 @@ def create( ) end + ## + # Create the MessageInteractionInstanceMetadata + # @param [String] body The message to send to the participant + # @param [Array[String]] media_url Reserved. Not currently supported. + # @return [MessageInteractionInstance] Created MessageInteractionInstance + def create_with_metadata( + body: :unset, + media_url: :unset + ) + + data = Twilio::Values.of({ + 'Body' => body, + 'MediaUrl' => Twilio.serialize_list(media_url) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + messageInteraction_instance = MessageInteractionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + session_sid: @solution[:session_sid], + participant_sid: @solution[:participant_sid], + ) + MessageInteractionInstanceMetadata.new( + @version, + messageInteraction_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessageInteractionInstance records from the API as a list. @@ -104,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessageInteractionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessageInteractionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessageInteractionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -202,6 +261,34 @@ def fetch ) end + ## + # Fetch the MessageInteractionInstanceMetadata + # @return [MessageInteractionInstance] Fetched MessageInteractionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + messageInteraction_instance = MessageInteractionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + session_sid: @solution[:session_sid], + participant_sid: @solution[:participant_sid], + sid: @solution[:sid], + ) + MessageInteractionInstanceMetadata.new( + @version, + messageInteraction_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -218,6 +305,45 @@ def inspect end end + class MessageInteractionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessageInteractionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessageInteractionInstance] message_interaction_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessageInteractionInstanceMetadata] The initialized instance with metadata. + def initialize(version, message_interaction_instance, headers, status_code) + super(version, headers, status_code) + @message_interaction_instance = message_interaction_instance + end + + def message_interaction + @message_interaction_instance + end + + def to_s + "" + end + end + + class MessageInteractionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_interaction_instance = payload.body[key].map do |data| + MessageInteractionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_interaction_instance + @instance + end + end + class MessageInteractionPage < Page ## # Initialize the MessageInteractionPage @@ -246,6 +372,54 @@ def to_s '' end end + + class MessageInteractionPageMetadata < PageMetadata + attr_reader :message_interaction_page + + def initialize(version, response, solution, limit) + super(version, response) + @message_interaction_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @message_interaction_page << MessageInteractionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @message_interaction_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessageInteractionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @message_interaction = payload.body[key].map do |data| + MessageInteractionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def message_interaction + @message_interaction + end + end + class MessageInteractionInstance < InstanceResource ## # Initialize the MessageInteractionInstance diff --git a/lib/twilio-ruby/rest/routes/v2/phone_number.rb b/lib/twilio-ruby/rest/routes/v2/phone_number.rb index 6e34e5ffb..21abbd0bc 100644 --- a/lib/twilio-ruby/rest/routes/v2/phone_number.rb +++ b/lib/twilio-ruby/rest/routes/v2/phone_number.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the PhoneNumberInstanceMetadata + # @return [PhoneNumberInstance] Fetched PhoneNumberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + phone_number: @solution[:phone_number], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Update the PhoneNumberInstance # @param [String] voice_region The Inbound Processing Region used for this phone number for voice @@ -103,6 +128,41 @@ def update( ) end + ## + # Update the PhoneNumberInstanceMetadata + # @param [String] voice_region The Inbound Processing Region used for this phone number for voice + # @param [String] friendly_name A human readable description of this resource, up to 64 characters. + # @return [PhoneNumberInstance] Updated PhoneNumberInstance + def update_with_metadata( + voice_region: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'VoiceRegion' => voice_region, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + phone_number: @solution[:phone_number], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -119,6 +179,45 @@ def inspect end end + class PhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PhoneNumberInstance] phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, phone_number_instance, headers, status_code) + super(version, headers, status_code) + @phone_number_instance = phone_number_instance + end + + def phone_number + @phone_number_instance + end + + def to_s + "" + end + end + + class PhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number_instance = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number_instance + @instance + end + end + class PhoneNumberPage < Page ## # Initialize the PhoneNumberPage @@ -147,6 +246,54 @@ def to_s '' end end + + class PhoneNumberPageMetadata < PageMetadata + attr_reader :phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @phone_number_page << PhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number + @phone_number + end + end + class PhoneNumberInstance < InstanceResource ## # Initialize the PhoneNumberInstance diff --git a/lib/twilio-ruby/rest/routes/v2/sip_domain.rb b/lib/twilio-ruby/rest/routes/v2/sip_domain.rb index 1c4ad8ce4..b033e1645 100644 --- a/lib/twilio-ruby/rest/routes/v2/sip_domain.rb +++ b/lib/twilio-ruby/rest/routes/v2/sip_domain.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the SipDomainInstanceMetadata + # @return [SipDomainInstance] Fetched SipDomainInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + sipDomain_instance = SipDomainInstance.new( + @version, + response.body, + sip_domain: @solution[:sip_domain], + ) + SipDomainInstanceMetadata.new( + @version, + sipDomain_instance, + response.headers, + response.status_code + ) + end + ## # Update the SipDomainInstance # @param [String] voice_region @@ -103,6 +128,41 @@ def update( ) end + ## + # Update the SipDomainInstanceMetadata + # @param [String] voice_region + # @param [String] friendly_name + # @return [SipDomainInstance] Updated SipDomainInstance + def update_with_metadata( + voice_region: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'VoiceRegion' => voice_region, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + sipDomain_instance = SipDomainInstance.new( + @version, + response.body, + sip_domain: @solution[:sip_domain], + ) + SipDomainInstanceMetadata.new( + @version, + sipDomain_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -119,6 +179,45 @@ def inspect end end + class SipDomainInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SipDomainInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SipDomainInstance] sip_domain_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SipDomainInstanceMetadata] The initialized instance with metadata. + def initialize(version, sip_domain_instance, headers, status_code) + super(version, headers, status_code) + @sip_domain_instance = sip_domain_instance + end + + def sip_domain + @sip_domain_instance + end + + def to_s + "" + end + end + + class SipDomainListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sip_domain_instance = payload.body[key].map do |data| + SipDomainInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sip_domain_instance + @instance + end + end + class SipDomainPage < Page ## # Initialize the SipDomainPage @@ -147,6 +246,54 @@ def to_s '' end end + + class SipDomainPageMetadata < PageMetadata + attr_reader :sip_domain_page + + def initialize(version, response, solution, limit) + super(version, response) + @sip_domain_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sip_domain_page << SipDomainListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sip_domain_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SipDomainListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sip_domain = payload.body[key].map do |data| + SipDomainInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sip_domain + @sip_domain + end + end + class SipDomainInstance < InstanceResource ## # Initialize the SipDomainInstance diff --git a/lib/twilio-ruby/rest/routes/v2/trunk.rb b/lib/twilio-ruby/rest/routes/v2/trunk.rb index 1b0b189df..f9ff4394c 100644 --- a/lib/twilio-ruby/rest/routes/v2/trunk.rb +++ b/lib/twilio-ruby/rest/routes/v2/trunk.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the TrunkInstanceMetadata + # @return [TrunkInstance] Fetched TrunkInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + trunk_instance = TrunkInstance.new( + @version, + response.body, + sip_trunk_domain: @solution[:sip_trunk_domain], + ) + TrunkInstanceMetadata.new( + @version, + trunk_instance, + response.headers, + response.status_code + ) + end + ## # Update the TrunkInstance # @param [String] voice_region The Inbound Processing Region used for this SIP Trunk for voice @@ -103,6 +128,41 @@ def update( ) end + ## + # Update the TrunkInstanceMetadata + # @param [String] voice_region The Inbound Processing Region used for this SIP Trunk for voice + # @param [String] friendly_name A human readable description of this resource, up to 64 characters. + # @return [TrunkInstance] Updated TrunkInstance + def update_with_metadata( + voice_region: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'VoiceRegion' => voice_region, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + trunk_instance = TrunkInstance.new( + @version, + response.body, + sip_trunk_domain: @solution[:sip_trunk_domain], + ) + TrunkInstanceMetadata.new( + @version, + trunk_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -119,6 +179,45 @@ def inspect end end + class TrunkInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TrunkInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TrunkInstance] trunk_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TrunkInstanceMetadata] The initialized instance with metadata. + def initialize(version, trunk_instance, headers, status_code) + super(version, headers, status_code) + @trunk_instance = trunk_instance + end + + def trunk + @trunk_instance + end + + def to_s + "" + end + end + + class TrunkListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trunk_instance = payload.body[key].map do |data| + TrunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trunk_instance + @instance + end + end + class TrunkPage < Page ## # Initialize the TrunkPage @@ -147,6 +246,54 @@ def to_s '' end end + + class TrunkPageMetadata < PageMetadata + attr_reader :trunk_page + + def initialize(version, response, solution, limit) + super(version, response) + @trunk_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @trunk_page << TrunkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @trunk_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TrunkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trunk = payload.body[key].map do |data| + TrunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trunk + @trunk + end + end + class TrunkInstance < InstanceResource ## # Initialize the TrunkInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service.rb b/lib/twilio-ruby/rest/serverless/v1/service.rb index 5c29b7ef6..56538bd1f 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] unique_name A user-defined string that uniquely identifies the Service resource. It can be used as an alternative to the `sid` in the URL path to address the Service resource. This value must be 50 characters or less in length and be unique. + # @param [String] friendly_name A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters. + # @param [Boolean] include_credentials Whether to inject Account credentials into a function invocation context. The default value is `true`. + # @param [Boolean] ui_editable Whether the Service's properties and subresources can be edited via the UI. The default value is `false`. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + unique_name: nil, + friendly_name: nil, + include_credentials: :unset, + ui_editable: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'FriendlyName' => friendly_name, + 'IncludeCredentials' => include_credentials, + 'UiEditable' => ui_editable, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -103,6 +143,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -189,7 +251,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -211,6 +292,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [Boolean] include_credentials Whether to inject Account credentials into a function invocation context. @@ -243,6 +349,44 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [Boolean] include_credentials Whether to inject Account credentials into a function invocation context. + # @param [String] friendly_name A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters. + # @param [Boolean] ui_editable Whether the Service resource's properties and subresources can be edited via the UI. The default value is `false`. + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + include_credentials: :unset, + friendly_name: :unset, + ui_editable: :unset + ) + + data = Twilio::Values.of({ + 'IncludeCredentials' => include_credentials, + 'FriendlyName' => friendly_name, + 'UiEditable' => ui_editable, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the environments # @return [EnvironmentList] @@ -335,6 +479,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -363,6 +546,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/asset.rb b/lib/twilio-ruby/rest/serverless/v1/service/asset.rb index 7cbe7609b..dcabab8e6 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/asset.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the AssetInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters. + # @return [AssetInstance] Created AssetInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + asset_instance = AssetInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + AssetInstanceMetadata.new( + @version, + asset_instance, + response.headers, + response.status_code + ) + end + ## # Lists AssetInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssetPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssetPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssetInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -181,7 +235,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the AssetInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + asset_instance = AssetInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + AssetInstanceMetadata.new(@version, asset_instance, response.headers, response.status_code) end ## @@ -204,6 +277,32 @@ def fetch ) end + ## + # Fetch the AssetInstanceMetadata + # @return [AssetInstance] Fetched AssetInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + asset_instance = AssetInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + AssetInstanceMetadata.new( + @version, + asset_instance, + response.headers, + response.status_code + ) + end + ## # Update the AssetInstance # @param [String] friendly_name A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters. @@ -231,6 +330,39 @@ def update( ) end + ## + # Update the AssetInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters. + # @return [AssetInstance] Updated AssetInstance + def update_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + asset_instance = AssetInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + AssetInstanceMetadata.new( + @version, + asset_instance, + response.headers, + response.status_code + ) + end + ## # Access the asset_versions # @return [AssetVersionList] @@ -266,6 +398,45 @@ def inspect end end + class AssetInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssetInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssetInstance] asset_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssetInstanceMetadata] The initialized instance with metadata. + def initialize(version, asset_instance, headers, status_code) + super(version, headers, status_code) + @asset_instance = asset_instance + end + + def asset + @asset_instance + end + + def to_s + "" + end + end + + class AssetListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @asset_instance = payload.body[key].map do |data| + AssetInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def asset_instance + @instance + end + end + class AssetPage < Page ## # Initialize the AssetPage @@ -294,6 +465,54 @@ def to_s '' end end + + class AssetPageMetadata < PageMetadata + attr_reader :asset_page + + def initialize(version, response, solution, limit) + super(version, response) + @asset_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @asset_page << AssetListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @asset_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssetListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @asset = payload.body[key].map do |data| + AssetInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def asset + @asset + end + end + class AssetInstance < InstanceResource ## # Initialize the AssetInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb b/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb index 433c0ecf7..e29cc6284 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists AssetVersionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + AssetVersionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields AssetVersionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +190,33 @@ def fetch ) end + ## + # Fetch the AssetVersionInstanceMetadata + # @return [AssetVersionInstance] Fetched AssetVersionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + assetVersion_instance = AssetVersionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + asset_sid: @solution[:asset_sid], + sid: @solution[:sid], + ) + AssetVersionInstanceMetadata.new( + @version, + assetVersion_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -184,6 +233,45 @@ def inspect end end + class AssetVersionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AssetVersionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AssetVersionInstance] asset_version_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AssetVersionInstanceMetadata] The initialized instance with metadata. + def initialize(version, asset_version_instance, headers, status_code) + super(version, headers, status_code) + @asset_version_instance = asset_version_instance + end + + def asset_version + @asset_version_instance + end + + def to_s + "" + end + end + + class AssetVersionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @asset_version_instance = payload.body[key].map do |data| + AssetVersionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def asset_version_instance + @instance + end + end + class AssetVersionPage < Page ## # Initialize the AssetVersionPage @@ -212,6 +300,54 @@ def to_s '' end end + + class AssetVersionPageMetadata < PageMetadata + attr_reader :asset_version_page + + def initialize(version, response, solution, limit) + super(version, response) + @asset_version_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @asset_version_page << AssetVersionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @asset_version_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AssetVersionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @asset_version = payload.body[key].map do |data| + AssetVersionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def asset_version + @asset_version + end + end + class AssetVersionInstance < InstanceResource ## # Initialize the AssetVersionInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/build.rb b/lib/twilio-ruby/rest/serverless/v1/service/build.rb index a74623187..448441ac9 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/build.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/build.rb @@ -67,6 +67,47 @@ def create( ) end + ## + # Create the BuildInstanceMetadata + # @param [Array[String]] asset_versions The list of Asset Version resource SIDs to include in the Build. + # @param [Array[String]] function_versions The list of the Function Version resource SIDs to include in the Build. + # @param [String] dependencies A list of objects that describe the Dependencies included in the Build. Each object contains the `name` and `version` of the dependency. + # @param [String] runtime The Runtime version that will be used to run the Build resource when it is deployed. + # @return [BuildInstance] Created BuildInstance + def create_with_metadata( + asset_versions: :unset, + function_versions: :unset, + dependencies: :unset, + runtime: :unset + ) + + data = Twilio::Values.of({ + 'AssetVersions' => Twilio.serialize_list(asset_versions) { |e| e }, + 'FunctionVersions' => Twilio.serialize_list(function_versions) { |e| e }, + 'Dependencies' => dependencies, + 'Runtime' => runtime, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + build_instance = BuildInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + BuildInstanceMetadata.new( + @version, + build_instance, + response.headers, + response.status_code + ) + end + ## # Lists BuildInstance records from the API as a list. @@ -106,6 +147,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BuildPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BuildPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BuildInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -190,7 +253,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BuildInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + build_instance = BuildInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BuildInstanceMetadata.new(@version, build_instance, response.headers, response.status_code) end ## @@ -213,6 +295,32 @@ def fetch ) end + ## + # Fetch the BuildInstanceMetadata + # @return [BuildInstance] Fetched BuildInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + build_instance = BuildInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + BuildInstanceMetadata.new( + @version, + build_instance, + response.headers, + response.status_code + ) + end + ## # Access the build_status # @return [BuildStatusList] @@ -240,6 +348,45 @@ def inspect end end + class BuildInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BuildInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BuildInstance] build_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BuildInstanceMetadata] The initialized instance with metadata. + def initialize(version, build_instance, headers, status_code) + super(version, headers, status_code) + @build_instance = build_instance + end + + def build + @build_instance + end + + def to_s + "" + end + end + + class BuildListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @build_instance = payload.body[key].map do |data| + BuildInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def build_instance + @instance + end + end + class BuildPage < Page ## # Initialize the BuildPage @@ -268,6 +415,54 @@ def to_s '' end end + + class BuildPageMetadata < PageMetadata + attr_reader :build_page + + def initialize(version, response, solution, limit) + super(version, response) + @build_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @build_page << BuildListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @build_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BuildListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @build = payload.body[key].map do |data| + BuildInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def build + @build + end + end + class BuildInstance < InstanceResource ## # Initialize the BuildInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/build/build_status.rb b/lib/twilio-ruby/rest/serverless/v1/service/build/build_status.rb index f9b485ea3..5fde3e69d 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/build/build_status.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/build/build_status.rb @@ -79,6 +79,32 @@ def fetch ) end + ## + # Fetch the BuildStatusInstanceMetadata + # @return [BuildStatusInstance] Fetched BuildStatusInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + buildStatus_instance = BuildStatusInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + BuildStatusInstanceMetadata.new( + @version, + buildStatus_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -95,6 +121,45 @@ def inspect end end + class BuildStatusInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BuildStatusInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BuildStatusInstance] build_status_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BuildStatusInstanceMetadata] The initialized instance with metadata. + def initialize(version, build_status_instance, headers, status_code) + super(version, headers, status_code) + @build_status_instance = build_status_instance + end + + def build_status + @build_status_instance + end + + def to_s + "" + end + end + + class BuildStatusListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @build_status_instance = payload.body[key].map do |data| + BuildStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def build_status_instance + @instance + end + end + class BuildStatusPage < Page ## # Initialize the BuildStatusPage @@ -123,6 +188,54 @@ def to_s '' end end + + class BuildStatusPageMetadata < PageMetadata + attr_reader :build_status_page + + def initialize(version, response, solution, limit) + super(version, response) + @build_status_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @build_status_page << BuildStatusListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @build_status_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BuildStatusListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @build_status = payload.body[key].map do |data| + BuildStatusInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def build_status + @build_status + end + end + class BuildStatusInstance < InstanceResource ## # Initialize the BuildStatusInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/environment.rb b/lib/twilio-ruby/rest/serverless/v1/service/environment.rb index 466283875..82a521917 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/environment.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the EnvironmentInstanceMetadata + # @param [String] unique_name A user-defined string that uniquely identifies the Environment resource. It can be a maximum of 100 characters. + # @param [String] domain_suffix A URL-friendly name that represents the environment and forms part of the domain name. It can be a maximum of 16 characters. + # @return [EnvironmentInstance] Created EnvironmentInstance + def create_with_metadata( + unique_name: nil, + domain_suffix: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'DomainSuffix' => domain_suffix, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + environment_instance = EnvironmentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + EnvironmentInstanceMetadata.new( + @version, + environment_instance, + response.headers, + response.status_code + ) + end + ## # Lists EnvironmentInstance records from the API as a list. @@ -100,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EnvironmentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EnvironmentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EnvironmentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +243,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the EnvironmentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + environment_instance = EnvironmentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + EnvironmentInstanceMetadata.new(@version, environment_instance, response.headers, response.status_code) end ## @@ -209,6 +285,32 @@ def fetch ) end + ## + # Fetch the EnvironmentInstanceMetadata + # @return [EnvironmentInstance] Fetched EnvironmentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + environment_instance = EnvironmentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + EnvironmentInstanceMetadata.new( + @version, + environment_instance, + response.headers, + response.status_code + ) + end + ## # Access the logs # @return [LogList] @@ -282,6 +384,45 @@ def inspect end end + class EnvironmentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EnvironmentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EnvironmentInstance] environment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EnvironmentInstanceMetadata] The initialized instance with metadata. + def initialize(version, environment_instance, headers, status_code) + super(version, headers, status_code) + @environment_instance = environment_instance + end + + def environment + @environment_instance + end + + def to_s + "" + end + end + + class EnvironmentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @environment_instance = payload.body[key].map do |data| + EnvironmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def environment_instance + @instance + end + end + class EnvironmentPage < Page ## # Initialize the EnvironmentPage @@ -310,6 +451,54 @@ def to_s '' end end + + class EnvironmentPageMetadata < PageMetadata + attr_reader :environment_page + + def initialize(version, response, solution, limit) + super(version, response) + @environment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @environment_page << EnvironmentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @environment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EnvironmentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @environment = payload.body[key].map do |data| + EnvironmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def environment + @environment + end + end + class EnvironmentInstance < InstanceResource ## # Initialize the EnvironmentInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb b/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb index b38382e38..b0f199fff 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the DeploymentInstanceMetadata + # @param [String] build_sid The SID of the Build for the Deployment. + # @param [Boolean] is_plugin Whether the Deployment is a plugin. + # @return [DeploymentInstance] Created DeploymentInstance + def create_with_metadata( + build_sid: :unset, + is_plugin: :unset + ) + + data = Twilio::Values.of({ + 'BuildSid' => build_sid, + 'IsPlugin' => is_plugin, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + deployment_instance = DeploymentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + environment_sid: @solution[:environment_sid], + ) + DeploymentInstanceMetadata.new( + @version, + deployment_instance, + response.headers, + response.status_code + ) + end + ## # Lists DeploymentInstance records from the API as a list. @@ -102,6 +138,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DeploymentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DeploymentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DeploymentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -198,6 +256,33 @@ def fetch ) end + ## + # Fetch the DeploymentInstanceMetadata + # @return [DeploymentInstance] Fetched DeploymentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + deployment_instance = DeploymentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + environment_sid: @solution[:environment_sid], + sid: @solution[:sid], + ) + DeploymentInstanceMetadata.new( + @version, + deployment_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -214,6 +299,45 @@ def inspect end end + class DeploymentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DeploymentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DeploymentInstance] deployment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DeploymentInstanceMetadata] The initialized instance with metadata. + def initialize(version, deployment_instance, headers, status_code) + super(version, headers, status_code) + @deployment_instance = deployment_instance + end + + def deployment + @deployment_instance + end + + def to_s + "" + end + end + + class DeploymentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @deployment_instance = payload.body[key].map do |data| + DeploymentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def deployment_instance + @instance + end + end + class DeploymentPage < Page ## # Initialize the DeploymentPage @@ -242,6 +366,54 @@ def to_s '' end end + + class DeploymentPageMetadata < PageMetadata + attr_reader :deployment_page + + def initialize(version, response, solution, limit) + super(version, response) + @deployment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @deployment_page << DeploymentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @deployment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DeploymentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @deployment = payload.body[key].map do |data| + DeploymentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def deployment + @deployment + end + end + class DeploymentInstance < InstanceResource ## # Initialize the DeploymentInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb b/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb index 8fce238da..03d01fcae 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb @@ -84,6 +84,34 @@ def stream(function_sid: :unset, start_date: :unset, end_date: :unset, limit: ni @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists LogPageMetadata records from the API as a list. + # @param [String] function_sid The SID of the function whose invocation produced the Log resources to read. + # @param [Time] start_date The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time. + # @param [Time] end_date The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/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 + # 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_with_metadata(function_sid: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FunctionSid' => function_sid, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + LogPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields LogInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,6 +214,33 @@ def fetch ) end + ## + # Fetch the LogInstanceMetadata + # @return [LogInstance] Fetched LogInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + log_instance = LogInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + environment_sid: @solution[:environment_sid], + sid: @solution[:sid], + ) + LogInstanceMetadata.new( + @version, + log_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -202,6 +257,45 @@ def inspect end end + class LogInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new LogInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}LogInstance] log_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [LogInstanceMetadata] The initialized instance with metadata. + def initialize(version, log_instance, headers, status_code) + super(version, headers, status_code) + @log_instance = log_instance + end + + def log + @log_instance + end + + def to_s + "" + end + end + + class LogListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @log_instance = payload.body[key].map do |data| + LogInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def log_instance + @instance + end + end + class LogPage < Page ## # Initialize the LogPage @@ -230,6 +324,54 @@ def to_s '' end end + + class LogPageMetadata < PageMetadata + attr_reader :log_page + + def initialize(version, response, solution, limit) + super(version, response) + @log_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @log_page << LogListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @log_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class LogListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @log = payload.body[key].map do |data| + LogInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def log + @log + end + end + class LogInstance < InstanceResource ## # Initialize the LogInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb b/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb index 97665a1c6..df1c9ece4 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the VariableInstanceMetadata + # @param [String] key A string by which the Variable resource can be referenced. It can be a maximum of 128 characters. + # @param [String] value A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size. + # @return [VariableInstance] Created VariableInstance + def create_with_metadata( + key: nil, + value: nil + ) + + data = Twilio::Values.of({ + 'Key' => key, + 'Value' => value, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + variable_instance = VariableInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + environment_sid: @solution[:environment_sid], + ) + VariableInstanceMetadata.new( + @version, + variable_instance, + response.headers, + response.status_code + ) + end + ## # Lists VariableInstance records from the API as a list. @@ -102,6 +138,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists VariablePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + VariablePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields VariableInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +244,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the VariableInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + variable_instance = VariableInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + VariableInstanceMetadata.new(@version, variable_instance, response.headers, response.status_code) end ## @@ -210,6 +287,33 @@ def fetch ) end + ## + # Fetch the VariableInstanceMetadata + # @return [VariableInstance] Fetched VariableInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + variable_instance = VariableInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + environment_sid: @solution[:environment_sid], + sid: @solution[:sid], + ) + VariableInstanceMetadata.new( + @version, + variable_instance, + response.headers, + response.status_code + ) + end + ## # Update the VariableInstance # @param [String] key A string by which the Variable resource can be referenced. It can be a maximum of 128 characters. @@ -241,6 +345,43 @@ def update( ) end + ## + # Update the VariableInstanceMetadata + # @param [String] key A string by which the Variable resource can be referenced. It can be a maximum of 128 characters. + # @param [String] value A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size. + # @return [VariableInstance] Updated VariableInstance + def update_with_metadata( + key: :unset, + value: :unset + ) + + data = Twilio::Values.of({ + 'Key' => key, + 'Value' => value, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + variable_instance = VariableInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + environment_sid: @solution[:environment_sid], + sid: @solution[:sid], + ) + VariableInstanceMetadata.new( + @version, + variable_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -257,6 +398,45 @@ def inspect end end + class VariableInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new VariableInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}VariableInstance] variable_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [VariableInstanceMetadata] The initialized instance with metadata. + def initialize(version, variable_instance, headers, status_code) + super(version, headers, status_code) + @variable_instance = variable_instance + end + + def variable + @variable_instance + end + + def to_s + "" + end + end + + class VariableListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @variable_instance = payload.body[key].map do |data| + VariableInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def variable_instance + @instance + end + end + class VariablePage < Page ## # Initialize the VariablePage @@ -285,6 +465,54 @@ def to_s '' end end + + class VariablePageMetadata < PageMetadata + attr_reader :variable_page + + def initialize(version, response, solution, limit) + super(version, response) + @variable_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @variable_page << VariableListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @variable_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VariableListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @variable = payload.body[key].map do |data| + VariableInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def variable + @variable + end + end + class VariableInstance < InstanceResource ## # Initialize the VariableInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/function.rb b/lib/twilio-ruby/rest/serverless/v1/service/function.rb index f71f2e6e2..42de289d0 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/function.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/function.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the FunctionInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters. + # @return [FunctionInstance] Created FunctionInstance + def create_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + function_instance = FunctionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + FunctionInstanceMetadata.new( + @version, + function_instance, + response.headers, + response.status_code + ) + end + ## # Lists FunctionInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FunctionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FunctionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FunctionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -181,7 +235,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the FunctionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + function_instance = FunctionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + FunctionInstanceMetadata.new(@version, function_instance, response.headers, response.status_code) end ## @@ -204,6 +277,32 @@ def fetch ) end + ## + # Fetch the FunctionInstanceMetadata + # @return [FunctionInstance] Fetched FunctionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + function_instance = FunctionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + FunctionInstanceMetadata.new( + @version, + function_instance, + response.headers, + response.status_code + ) + end + ## # Update the FunctionInstance # @param [String] friendly_name A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters. @@ -231,6 +330,39 @@ def update( ) end + ## + # Update the FunctionInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters. + # @return [FunctionInstance] Updated FunctionInstance + def update_with_metadata( + friendly_name: nil + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + function_instance = FunctionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + FunctionInstanceMetadata.new( + @version, + function_instance, + response.headers, + response.status_code + ) + end + ## # Access the function_versions # @return [FunctionVersionList] @@ -266,6 +398,45 @@ def inspect end end + class FunctionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FunctionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FunctionInstance] function_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FunctionInstanceMetadata] The initialized instance with metadata. + def initialize(version, function_instance, headers, status_code) + super(version, headers, status_code) + @function_instance = function_instance + end + + def function + @function_instance + end + + def to_s + "" + end + end + + class FunctionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @function_instance = payload.body[key].map do |data| + FunctionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def function_instance + @instance + end + end + class FunctionPage < Page ## # Initialize the FunctionPage @@ -294,6 +465,54 @@ def to_s '' end end + + class FunctionPageMetadata < PageMetadata + attr_reader :function_page + + def initialize(version, response, solution, limit) + super(version, response) + @function_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @function_page << FunctionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @function_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FunctionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @function = payload.body[key].map do |data| + FunctionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def function + @function + end + end + class FunctionInstance < InstanceResource ## # Initialize the FunctionInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb b/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb index dd868a462..997c74c33 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FunctionVersionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FunctionVersionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FunctionVersionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -169,6 +191,33 @@ def fetch ) end + ## + # Fetch the FunctionVersionInstanceMetadata + # @return [FunctionVersionInstance] Fetched FunctionVersionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + functionVersion_instance = FunctionVersionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + function_sid: @solution[:function_sid], + sid: @solution[:sid], + ) + FunctionVersionInstanceMetadata.new( + @version, + functionVersion_instance, + response.headers, + response.status_code + ) + end + ## # Access the function_version_content # @return [FunctionVersionContentList] @@ -197,6 +246,45 @@ def inspect end end + class FunctionVersionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FunctionVersionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FunctionVersionInstance] function_version_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FunctionVersionInstanceMetadata] The initialized instance with metadata. + def initialize(version, function_version_instance, headers, status_code) + super(version, headers, status_code) + @function_version_instance = function_version_instance + end + + def function_version + @function_version_instance + end + + def to_s + "" + end + end + + class FunctionVersionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @function_version_instance = payload.body[key].map do |data| + FunctionVersionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def function_version_instance + @instance + end + end + class FunctionVersionPage < Page ## # Initialize the FunctionVersionPage @@ -225,6 +313,54 @@ def to_s '' end end + + class FunctionVersionPageMetadata < PageMetadata + attr_reader :function_version_page + + def initialize(version, response, solution, limit) + super(version, response) + @function_version_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @function_version_page << FunctionVersionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @function_version_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FunctionVersionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @function_version = payload.body[key].map do |data| + FunctionVersionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def function_version + @function_version + end + end + class FunctionVersionInstance < InstanceResource ## # Initialize the FunctionVersionInstance diff --git a/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb b/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb index 8b9d7b9e7..9a5301d7b 100644 --- a/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +++ b/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb @@ -82,6 +82,33 @@ def fetch ) end + ## + # Fetch the FunctionVersionContentInstanceMetadata + # @return [FunctionVersionContentInstance] Fetched FunctionVersionContentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + functionVersionContent_instance = FunctionVersionContentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + function_sid: @solution[:function_sid], + sid: @solution[:sid], + ) + FunctionVersionContentInstanceMetadata.new( + @version, + functionVersionContent_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +125,45 @@ def inspect end end + class FunctionVersionContentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FunctionVersionContentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FunctionVersionContentInstance] function_version_content_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FunctionVersionContentInstanceMetadata] The initialized instance with metadata. + def initialize(version, function_version_content_instance, headers, status_code) + super(version, headers, status_code) + @function_version_content_instance = function_version_content_instance + end + + def function_version_content + @function_version_content_instance + end + + def to_s + "" + end + end + + class FunctionVersionContentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @function_version_content_instance = payload.body[key].map do |data| + FunctionVersionContentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def function_version_content_instance + @instance + end + end + class FunctionVersionContentPage < Page ## # Initialize the FunctionVersionContentPage @@ -126,6 +192,54 @@ def to_s '' end end + + class FunctionVersionContentPageMetadata < PageMetadata + attr_reader :function_version_content_page + + def initialize(version, response, solution, limit) + super(version, response) + @function_version_content_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @function_version_content_page << FunctionVersionContentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @function_version_content_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FunctionVersionContentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @function_version_content = payload.body[key].map do |data| + FunctionVersionContentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def function_version_content + @function_version_content + end + end + class FunctionVersionContentInstance < InstanceResource ## # Initialize the FunctionVersionContentInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow.rb b/lib/twilio-ruby/rest/studio/v1/flow.rb index 8c5b0cb74..dde389603 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FlowPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FlowPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FlowInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -153,7 +175,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the FlowInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + flow_instance = FlowInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + FlowInstanceMetadata.new(@version, flow_instance, response.headers, response.status_code) end ## @@ -175,6 +216,31 @@ def fetch ) end + ## + # Fetch the FlowInstanceMetadata + # @return [FlowInstance] Fetched FlowInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + flow_instance = FlowInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FlowInstanceMetadata.new( + @version, + flow_instance, + response.headers, + response.status_code + ) + end + ## # Access the executions # @return [ExecutionList] @@ -229,6 +295,45 @@ def inspect end end + class FlowInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FlowInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FlowInstance] flow_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FlowInstanceMetadata] The initialized instance with metadata. + def initialize(version, flow_instance, headers, status_code) + super(version, headers, status_code) + @flow_instance = flow_instance + end + + def flow + @flow_instance + end + + def to_s + "" + end + end + + class FlowListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow_instance = payload.body[key].map do |data| + FlowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow_instance + @instance + end + end + class FlowPage < Page ## # Initialize the FlowPage @@ -257,6 +362,54 @@ def to_s '' end end + + class FlowPageMetadata < PageMetadata + attr_reader :flow_page + + def initialize(version, response, solution, limit) + super(version, response) + @flow_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @flow_page << FlowListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @flow_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FlowListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow = payload.body[key].map do |data| + FlowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow + @flow + end + end + class FlowInstance < InstanceResource ## # Initialize the FlowInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/engagement.rb b/lib/twilio-ruby/rest/studio/v1/flow/engagement.rb index 3fc184c3e..02416a4eb 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/engagement.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/engagement.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the EngagementInstanceMetadata + # @param [String] to The Contact phone number to start a Studio Flow Engagement, available as variable `{{contact.channel.address}}`. + # @param [String] from The Twilio phone number to send messages or initiate calls from during the Flow Engagement. Available as variable `{{flow.channel.address}}` + # @param [Object] parameters A JSON string we will add to your flow's context and that you can access as variables inside your flow. For example, if you pass in `Parameters={'name':'Zeke'}` then inside a widget you can reference the variable `{{flow.data.name}}` which will return the string 'Zeke'. Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode your JSON string. + # @return [EngagementInstance] Created EngagementInstance + def create_with_metadata( + to: nil, + from: nil, + parameters: :unset + ) + + data = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'Parameters' => Twilio.serialize_object(parameters), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + engagement_instance = EngagementInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + ) + EngagementInstanceMetadata.new( + @version, + engagement_instance, + response.headers, + response.status_code + ) + end + ## # Lists EngagementInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EngagementPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EngagementPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EngagementInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -188,7 +248,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the EngagementInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + engagement_instance = EngagementInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + EngagementInstanceMetadata.new(@version, engagement_instance, response.headers, response.status_code) end ## @@ -211,6 +290,32 @@ def fetch ) end + ## + # Fetch the EngagementInstanceMetadata + # @return [EngagementInstance] Fetched EngagementInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + engagement_instance = EngagementInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + sid: @solution[:sid], + ) + EngagementInstanceMetadata.new( + @version, + engagement_instance, + response.headers, + response.status_code + ) + end + ## # Access the steps # @return [StepList] @@ -257,6 +362,45 @@ def inspect end end + class EngagementInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EngagementInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EngagementInstance] engagement_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EngagementInstanceMetadata] The initialized instance with metadata. + def initialize(version, engagement_instance, headers, status_code) + super(version, headers, status_code) + @engagement_instance = engagement_instance + end + + def engagement + @engagement_instance + end + + def to_s + "" + end + end + + class EngagementListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @engagement_instance = payload.body[key].map do |data| + EngagementInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def engagement_instance + @instance + end + end + class EngagementPage < Page ## # Initialize the EngagementPage @@ -285,6 +429,54 @@ def to_s '' end end + + class EngagementPageMetadata < PageMetadata + attr_reader :engagement_page + + def initialize(version, response, solution, limit) + super(version, response) + @engagement_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @engagement_page << EngagementListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @engagement_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EngagementListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @engagement = payload.body[key].map do |data| + EngagementInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def engagement + @engagement + end + end + class EngagementInstance < InstanceResource ## # Initialize the EngagementInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb b/lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb index 1f8a40f02..913ccbf9c 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb @@ -79,6 +79,32 @@ def fetch ) end + ## + # Fetch the EngagementContextInstanceMetadata + # @return [EngagementContextInstance] Fetched EngagementContextInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + engagementContext_instance = EngagementContextInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + engagement_sid: @solution[:engagement_sid], + ) + EngagementContextInstanceMetadata.new( + @version, + engagementContext_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -95,6 +121,45 @@ def inspect end end + class EngagementContextInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EngagementContextInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EngagementContextInstance] engagement_context_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EngagementContextInstanceMetadata] The initialized instance with metadata. + def initialize(version, engagement_context_instance, headers, status_code) + super(version, headers, status_code) + @engagement_context_instance = engagement_context_instance + end + + def engagement_context + @engagement_context_instance + end + + def to_s + "" + end + end + + class EngagementContextListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @engagement_context_instance = payload.body[key].map do |data| + EngagementContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def engagement_context_instance + @instance + end + end + class EngagementContextPage < Page ## # Initialize the EngagementContextPage @@ -123,6 +188,54 @@ def to_s '' end end + + class EngagementContextPageMetadata < PageMetadata + attr_reader :engagement_context_page + + def initialize(version, response, solution, limit) + super(version, response) + @engagement_context_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @engagement_context_page << EngagementContextListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @engagement_context_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EngagementContextListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @engagement_context = payload.body[key].map do |data| + EngagementContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def engagement_context + @engagement_context + end + end + class EngagementContextInstance < InstanceResource ## # Initialize the EngagementContextInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb b/lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb index 49cad5466..3f4965cc7 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists StepPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + StepPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields StepInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -169,6 +191,33 @@ def fetch ) end + ## + # Fetch the StepInstanceMetadata + # @return [StepInstance] Fetched StepInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + step_instance = StepInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + engagement_sid: @solution[:engagement_sid], + sid: @solution[:sid], + ) + StepInstanceMetadata.new( + @version, + step_instance, + response.headers, + response.status_code + ) + end + ## # Access the step_context # @return [StepContextList] @@ -197,6 +246,45 @@ def inspect end end + class StepInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new StepInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}StepInstance] step_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [StepInstanceMetadata] The initialized instance with metadata. + def initialize(version, step_instance, headers, status_code) + super(version, headers, status_code) + @step_instance = step_instance + end + + def step + @step_instance + end + + def to_s + "" + end + end + + class StepListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @step_instance = payload.body[key].map do |data| + StepInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def step_instance + @instance + end + end + class StepPage < Page ## # Initialize the StepPage @@ -225,6 +313,54 @@ def to_s '' end end + + class StepPageMetadata < PageMetadata + attr_reader :step_page + + def initialize(version, response, solution, limit) + super(version, response) + @step_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @step_page << StepListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @step_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class StepListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @step = payload.body[key].map do |data| + StepInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def step + @step + end + end + class StepInstance < InstanceResource ## # Initialize the StepInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb b/lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb index d36ee246c..67ee3469d 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb @@ -82,6 +82,33 @@ def fetch ) end + ## + # Fetch the StepContextInstanceMetadata + # @return [StepContextInstance] Fetched StepContextInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + stepContext_instance = StepContextInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + engagement_sid: @solution[:engagement_sid], + step_sid: @solution[:step_sid], + ) + StepContextInstanceMetadata.new( + @version, + stepContext_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +125,45 @@ def inspect end end + class StepContextInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new StepContextInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}StepContextInstance] step_context_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [StepContextInstanceMetadata] The initialized instance with metadata. + def initialize(version, step_context_instance, headers, status_code) + super(version, headers, status_code) + @step_context_instance = step_context_instance + end + + def step_context + @step_context_instance + end + + def to_s + "" + end + end + + class StepContextListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @step_context_instance = payload.body[key].map do |data| + StepContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def step_context_instance + @instance + end + end + class StepContextPage < Page ## # Initialize the StepContextPage @@ -126,6 +192,54 @@ def to_s '' end end + + class StepContextPageMetadata < PageMetadata + attr_reader :step_context_page + + def initialize(version, response, solution, limit) + super(version, response) + @step_context_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @step_context_page << StepContextListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @step_context_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class StepContextListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @step_context = payload.body[key].map do |data| + StepContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def step_context + @step_context + end + end + class StepContextInstance < InstanceResource ## # Initialize the StepContextInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/execution.rb b/lib/twilio-ruby/rest/studio/v1/flow/execution.rb index 0fba117ec..d5914c0a4 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/execution.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/execution.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the ExecutionInstanceMetadata + # @param [String] to The Contact phone number to start a Studio Flow Execution, available as variable `{{contact.channel.address}}`. + # @param [String] from The Twilio phone number to send messages or initiate calls from during the Flow's Execution. Available as variable `{{flow.channel.address}}`. For SMS, this can also be a Messaging Service SID. + # @param [Object] parameters JSON data that will be added to the Flow's context and that can be accessed as variables inside your Flow. For example, if you pass in `Parameters={\\\"name\\\":\\\"Zeke\\\"}`, a widget in your Flow can reference the variable `{{flow.data.name}}`, which returns \\\"Zeke\\\". Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode the JSON string. + # @return [ExecutionInstance] Created ExecutionInstance + def create_with_metadata( + to: nil, + from: nil, + parameters: :unset + ) + + data = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'Parameters' => Twilio.serialize_object(parameters), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + ) + ExecutionInstanceMetadata.new( + @version, + execution_instance, + response.headers, + response.status_code + ) + end + ## # Lists ExecutionInstance records from the API as a list. @@ -111,6 +149,32 @@ def stream(date_created_from: :unset, date_created_to: :unset, limit: nil, page_ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ExecutionPageMetadata records from the API as a list. + # @param [Time] date_created_from Only show Execution resources starting on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`. + # @param [Time] date_created_to Only show Execution resources starting before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`. + # @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_with_metadata(date_created_from: :unset, date_created_to: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'DateCreatedFrom' => Twilio.serialize_iso8601_datetime(date_created_from), + 'DateCreatedTo' => Twilio.serialize_iso8601_datetime(date_created_to), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ExecutionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ExecutionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -200,7 +264,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ExecutionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ExecutionInstanceMetadata.new(@version, execution_instance, response.headers, response.status_code) end ## @@ -223,6 +306,32 @@ def fetch ) end + ## + # Fetch the ExecutionInstanceMetadata + # @return [ExecutionInstance] Fetched ExecutionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + sid: @solution[:sid], + ) + ExecutionInstanceMetadata.new( + @version, + execution_instance, + response.headers, + response.status_code + ) + end + ## # Update the ExecutionInstance # @param [Status] status @@ -250,6 +359,39 @@ def update( ) end + ## + # Update the ExecutionInstanceMetadata + # @param [Status] status + # @return [ExecutionInstance] Updated ExecutionInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + sid: @solution[:sid], + ) + ExecutionInstanceMetadata.new( + @version, + execution_instance, + response.headers, + response.status_code + ) + end + ## # Access the execution_context # @return [ExecutionContextList] @@ -296,6 +438,45 @@ def inspect end end + class ExecutionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionInstance] execution_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_instance, headers, status_code) + super(version, headers, status_code) + @execution_instance = execution_instance + end + + def execution + @execution_instance + end + + def to_s + "" + end + end + + class ExecutionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_instance = payload.body[key].map do |data| + ExecutionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_instance + @instance + end + end + class ExecutionPage < Page ## # Initialize the ExecutionPage @@ -324,6 +505,54 @@ def to_s '' end end + + class ExecutionPageMetadata < PageMetadata + attr_reader :execution_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_page << ExecutionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution = payload.body[key].map do |data| + ExecutionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution + @execution + end + end + class ExecutionInstance < InstanceResource ## # Initialize the ExecutionInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb b/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb index 69834575a..bf2801698 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb @@ -79,6 +79,32 @@ def fetch ) end + ## + # Fetch the ExecutionContextInstanceMetadata + # @return [ExecutionContextInstance] Fetched ExecutionContextInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + executionContext_instance = ExecutionContextInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + execution_sid: @solution[:execution_sid], + ) + ExecutionContextInstanceMetadata.new( + @version, + executionContext_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -95,6 +121,45 @@ def inspect end end + class ExecutionContextInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionContextInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionContextInstance] execution_context_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionContextInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_context_instance, headers, status_code) + super(version, headers, status_code) + @execution_context_instance = execution_context_instance + end + + def execution_context + @execution_context_instance + end + + def to_s + "" + end + end + + class ExecutionContextListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_context_instance = payload.body[key].map do |data| + ExecutionContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_context_instance + @instance + end + end + class ExecutionContextPage < Page ## # Initialize the ExecutionContextPage @@ -123,6 +188,54 @@ def to_s '' end end + + class ExecutionContextPageMetadata < PageMetadata + attr_reader :execution_context_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_context_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_context_page << ExecutionContextListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_context_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionContextListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_context = payload.body[key].map do |data| + ExecutionContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_context + @execution_context + end + end + class ExecutionContextInstance < InstanceResource ## # Initialize the ExecutionContextInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb b/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb index 489458e0a..fc5524471 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ExecutionStepPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ExecutionStepPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ExecutionStepInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -169,6 +191,33 @@ def fetch ) end + ## + # Fetch the ExecutionStepInstanceMetadata + # @return [ExecutionStepInstance] Fetched ExecutionStepInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + executionStep_instance = ExecutionStepInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + execution_sid: @solution[:execution_sid], + sid: @solution[:sid], + ) + ExecutionStepInstanceMetadata.new( + @version, + executionStep_instance, + response.headers, + response.status_code + ) + end + ## # Access the step_context # @return [ExecutionStepContextList] @@ -197,6 +246,45 @@ def inspect end end + class ExecutionStepInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionStepInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionStepInstance] execution_step_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionStepInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_step_instance, headers, status_code) + super(version, headers, status_code) + @execution_step_instance = execution_step_instance + end + + def execution_step + @execution_step_instance + end + + def to_s + "" + end + end + + class ExecutionStepListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step_instance = payload.body[key].map do |data| + ExecutionStepInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step_instance + @instance + end + end + class ExecutionStepPage < Page ## # Initialize the ExecutionStepPage @@ -225,6 +313,54 @@ def to_s '' end end + + class ExecutionStepPageMetadata < PageMetadata + attr_reader :execution_step_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_step_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_step_page << ExecutionStepListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_step_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionStepListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step = payload.body[key].map do |data| + ExecutionStepInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step + @execution_step + end + end + class ExecutionStepInstance < InstanceResource ## # Initialize the ExecutionStepInstance diff --git a/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb b/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb index 6d58ca115..00d23f7fd 100644 --- a/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb +++ b/lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb @@ -82,6 +82,33 @@ def fetch ) end + ## + # Fetch the ExecutionStepContextInstanceMetadata + # @return [ExecutionStepContextInstance] Fetched ExecutionStepContextInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + executionStepContext_instance = ExecutionStepContextInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + execution_sid: @solution[:execution_sid], + step_sid: @solution[:step_sid], + ) + ExecutionStepContextInstanceMetadata.new( + @version, + executionStepContext_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +125,45 @@ def inspect end end + class ExecutionStepContextInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionStepContextInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionStepContextInstance] execution_step_context_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionStepContextInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_step_context_instance, headers, status_code) + super(version, headers, status_code) + @execution_step_context_instance = execution_step_context_instance + end + + def execution_step_context + @execution_step_context_instance + end + + def to_s + "" + end + end + + class ExecutionStepContextListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step_context_instance = payload.body[key].map do |data| + ExecutionStepContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step_context_instance + @instance + end + end + class ExecutionStepContextPage < Page ## # Initialize the ExecutionStepContextPage @@ -126,6 +192,54 @@ def to_s '' end end + + class ExecutionStepContextPageMetadata < PageMetadata + attr_reader :execution_step_context_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_step_context_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_step_context_page << ExecutionStepContextListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_step_context_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionStepContextListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step_context = payload.body[key].map do |data| + ExecutionStepContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step_context + @execution_step_context + end + end + class ExecutionStepContextInstance < InstanceResource ## # Initialize the ExecutionStepContextInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow.rb b/lib/twilio-ruby/rest/studio/v2/flow.rb index adbfb9860..b20890f6b 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the FlowInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the Flow. + # @param [Status] status + # @param [Object] definition JSON representation of flow definition. + # @param [String] commit_message Description of change made in the revision. + # @return [FlowInstance] Created FlowInstance + def create_with_metadata( + friendly_name: nil, + status: nil, + definition: nil, + commit_message: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Status' => status, + 'Definition' => Twilio.serialize_object(definition), + 'CommitMessage' => commit_message, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + flow_instance = FlowInstance.new( + @version, + response.body, + ) + FlowInstanceMetadata.new( + @version, + flow_instance, + response.headers, + response.status_code + ) + end + ## # Lists FlowInstance records from the API as a list. @@ -103,6 +143,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FlowPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FlowPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FlowInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -188,7 +250,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the FlowInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + flow_instance = FlowInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + FlowInstanceMetadata.new(@version, flow_instance, response.headers, response.status_code) end ## @@ -210,6 +291,31 @@ def fetch ) end + ## + # Fetch the FlowInstanceMetadata + # @return [FlowInstance] Fetched FlowInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + flow_instance = FlowInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FlowInstanceMetadata.new( + @version, + flow_instance, + response.headers, + response.status_code + ) + end + ## # Update the FlowInstance # @param [Status] status @@ -245,6 +351,47 @@ def update( ) end + ## + # Update the FlowInstanceMetadata + # @param [Status] status + # @param [String] friendly_name The string that you assigned to describe the Flow. + # @param [Object] definition JSON representation of flow definition. + # @param [String] commit_message Description of change made in the revision. + # @return [FlowInstance] Updated FlowInstance + def update_with_metadata( + status: nil, + friendly_name: :unset, + definition: :unset, + commit_message: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'FriendlyName' => friendly_name, + 'Definition' => Twilio.serialize_object(definition), + 'CommitMessage' => commit_message, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + flow_instance = FlowInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FlowInstanceMetadata.new( + @version, + flow_instance, + response.headers, + response.status_code + ) + end + ## # Access the executions # @return [ExecutionList] @@ -309,6 +456,45 @@ def inspect end end + class FlowInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FlowInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FlowInstance] flow_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FlowInstanceMetadata] The initialized instance with metadata. + def initialize(version, flow_instance, headers, status_code) + super(version, headers, status_code) + @flow_instance = flow_instance + end + + def flow + @flow_instance + end + + def to_s + "" + end + end + + class FlowListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow_instance = payload.body[key].map do |data| + FlowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow_instance + @instance + end + end + class FlowPage < Page ## # Initialize the FlowPage @@ -337,6 +523,54 @@ def to_s '' end end + + class FlowPageMetadata < PageMetadata + attr_reader :flow_page + + def initialize(version, response, solution, limit) + super(version, response) + @flow_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @flow_page << FlowListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @flow_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FlowListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow = payload.body[key].map do |data| + FlowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow + @flow + end + end + class FlowInstance < InstanceResource ## # Initialize the FlowInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow/execution.rb b/lib/twilio-ruby/rest/studio/v2/flow/execution.rb index fc6afde5e..325914459 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow/execution.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow/execution.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the ExecutionInstanceMetadata + # @param [String] to The Contact phone number to start a Studio Flow Execution, available as variable `{{contact.channel.address}}`. + # @param [String] from The Twilio phone number to send messages or initiate calls from during the Flow's Execution. Available as variable `{{flow.channel.address}}`. For SMS, this can also be a Messaging Service SID. + # @param [Object] parameters JSON data that will be added to the Flow's context and that can be accessed as variables inside your Flow. For example, if you pass in `Parameters={\\\"name\\\":\\\"Zeke\\\"}`, a widget in your Flow can reference the variable `{{flow.data.name}}`, which returns \\\"Zeke\\\". Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode the JSON string. + # @return [ExecutionInstance] Created ExecutionInstance + def create_with_metadata( + to: nil, + from: nil, + parameters: :unset + ) + + data = Twilio::Values.of({ + 'To' => to, + 'From' => from, + 'Parameters' => Twilio.serialize_object(parameters), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + ) + ExecutionInstanceMetadata.new( + @version, + execution_instance, + response.headers, + response.status_code + ) + end + ## # Lists ExecutionInstance records from the API as a list. @@ -111,6 +149,32 @@ def stream(date_created_from: :unset, date_created_to: :unset, limit: nil, page_ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ExecutionPageMetadata records from the API as a list. + # @param [Time] date_created_from Only show Execution resources starting on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`. + # @param [Time] date_created_to Only show Execution resources starting before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`. + # @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_with_metadata(date_created_from: :unset, date_created_to: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'DateCreatedFrom' => Twilio.serialize_iso8601_datetime(date_created_from), + 'DateCreatedTo' => Twilio.serialize_iso8601_datetime(date_created_to), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ExecutionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ExecutionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -200,7 +264,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ExecutionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ExecutionInstanceMetadata.new(@version, execution_instance, response.headers, response.status_code) end ## @@ -223,6 +306,32 @@ def fetch ) end + ## + # Fetch the ExecutionInstanceMetadata + # @return [ExecutionInstance] Fetched ExecutionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + sid: @solution[:sid], + ) + ExecutionInstanceMetadata.new( + @version, + execution_instance, + response.headers, + response.status_code + ) + end + ## # Update the ExecutionInstance # @param [Status] status @@ -250,6 +359,39 @@ def update( ) end + ## + # Update the ExecutionInstanceMetadata + # @param [Status] status + # @return [ExecutionInstance] Updated ExecutionInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + execution_instance = ExecutionInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + sid: @solution[:sid], + ) + ExecutionInstanceMetadata.new( + @version, + execution_instance, + response.headers, + response.status_code + ) + end + ## # Access the execution_context # @return [ExecutionContextList] @@ -296,6 +438,45 @@ def inspect end end + class ExecutionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionInstance] execution_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_instance, headers, status_code) + super(version, headers, status_code) + @execution_instance = execution_instance + end + + def execution + @execution_instance + end + + def to_s + "" + end + end + + class ExecutionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_instance = payload.body[key].map do |data| + ExecutionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_instance + @instance + end + end + class ExecutionPage < Page ## # Initialize the ExecutionPage @@ -324,6 +505,54 @@ def to_s '' end end + + class ExecutionPageMetadata < PageMetadata + attr_reader :execution_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_page << ExecutionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution = payload.body[key].map do |data| + ExecutionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution + @execution + end + end + class ExecutionInstance < InstanceResource ## # Initialize the ExecutionInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb b/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb index 938717892..388d72759 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb @@ -79,6 +79,32 @@ def fetch ) end + ## + # Fetch the ExecutionContextInstanceMetadata + # @return [ExecutionContextInstance] Fetched ExecutionContextInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + executionContext_instance = ExecutionContextInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + execution_sid: @solution[:execution_sid], + ) + ExecutionContextInstanceMetadata.new( + @version, + executionContext_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -95,6 +121,45 @@ def inspect end end + class ExecutionContextInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionContextInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionContextInstance] execution_context_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionContextInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_context_instance, headers, status_code) + super(version, headers, status_code) + @execution_context_instance = execution_context_instance + end + + def execution_context + @execution_context_instance + end + + def to_s + "" + end + end + + class ExecutionContextListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_context_instance = payload.body[key].map do |data| + ExecutionContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_context_instance + @instance + end + end + class ExecutionContextPage < Page ## # Initialize the ExecutionContextPage @@ -123,6 +188,54 @@ def to_s '' end end + + class ExecutionContextPageMetadata < PageMetadata + attr_reader :execution_context_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_context_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_context_page << ExecutionContextListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_context_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionContextListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_context = payload.body[key].map do |data| + ExecutionContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_context + @execution_context + end + end + class ExecutionContextInstance < InstanceResource ## # Initialize the ExecutionContextInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb b/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb index c755af3f6..6a3f2fe7c 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ExecutionStepPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ExecutionStepPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ExecutionStepInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -169,6 +191,33 @@ def fetch ) end + ## + # Fetch the ExecutionStepInstanceMetadata + # @return [ExecutionStepInstance] Fetched ExecutionStepInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + executionStep_instance = ExecutionStepInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + execution_sid: @solution[:execution_sid], + sid: @solution[:sid], + ) + ExecutionStepInstanceMetadata.new( + @version, + executionStep_instance, + response.headers, + response.status_code + ) + end + ## # Access the step_context # @return [ExecutionStepContextList] @@ -197,6 +246,45 @@ def inspect end end + class ExecutionStepInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionStepInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionStepInstance] execution_step_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionStepInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_step_instance, headers, status_code) + super(version, headers, status_code) + @execution_step_instance = execution_step_instance + end + + def execution_step + @execution_step_instance + end + + def to_s + "" + end + end + + class ExecutionStepListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step_instance = payload.body[key].map do |data| + ExecutionStepInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step_instance + @instance + end + end + class ExecutionStepPage < Page ## # Initialize the ExecutionStepPage @@ -225,6 +313,54 @@ def to_s '' end end + + class ExecutionStepPageMetadata < PageMetadata + attr_reader :execution_step_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_step_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_step_page << ExecutionStepListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_step_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionStepListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step = payload.body[key].map do |data| + ExecutionStepInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step + @execution_step + end + end + class ExecutionStepInstance < InstanceResource ## # Initialize the ExecutionStepInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb b/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb index 13cd738c3..a873fe1f2 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb @@ -82,6 +82,33 @@ def fetch ) end + ## + # Fetch the ExecutionStepContextInstanceMetadata + # @return [ExecutionStepContextInstance] Fetched ExecutionStepContextInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + executionStepContext_instance = ExecutionStepContextInstance.new( + @version, + response.body, + flow_sid: @solution[:flow_sid], + execution_sid: @solution[:execution_sid], + step_sid: @solution[:step_sid], + ) + ExecutionStepContextInstanceMetadata.new( + @version, + executionStepContext_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +125,45 @@ def inspect end end + class ExecutionStepContextInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ExecutionStepContextInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ExecutionStepContextInstance] execution_step_context_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ExecutionStepContextInstanceMetadata] The initialized instance with metadata. + def initialize(version, execution_step_context_instance, headers, status_code) + super(version, headers, status_code) + @execution_step_context_instance = execution_step_context_instance + end + + def execution_step_context + @execution_step_context_instance + end + + def to_s + "" + end + end + + class ExecutionStepContextListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step_context_instance = payload.body[key].map do |data| + ExecutionStepContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step_context_instance + @instance + end + end + class ExecutionStepContextPage < Page ## # Initialize the ExecutionStepContextPage @@ -126,6 +192,54 @@ def to_s '' end end + + class ExecutionStepContextPageMetadata < PageMetadata + attr_reader :execution_step_context_page + + def initialize(version, response, solution, limit) + super(version, response) + @execution_step_context_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @execution_step_context_page << ExecutionStepContextListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @execution_step_context_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ExecutionStepContextListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @execution_step_context = payload.body[key].map do |data| + ExecutionStepContextInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def execution_step_context + @execution_step_context + end + end + class ExecutionStepContextInstance < InstanceResource ## # Initialize the ExecutionStepContextInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow/flow_revision.rb b/lib/twilio-ruby/rest/studio/v2/flow/flow_revision.rb index 78afad403..5a5dcbe26 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow/flow_revision.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow/flow_revision.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FlowRevisionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FlowRevisionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FlowRevisionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -165,6 +187,32 @@ def fetch ) end + ## + # Fetch the FlowRevisionInstanceMetadata + # @return [FlowRevisionInstance] Fetched FlowRevisionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + flowRevision_instance = FlowRevisionInstance.new( + @version, + response.body, + sid: @solution[:sid], + revision: @solution[:revision], + ) + FlowRevisionInstanceMetadata.new( + @version, + flowRevision_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -181,6 +229,45 @@ def inspect end end + class FlowRevisionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FlowRevisionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FlowRevisionInstance] flow_revision_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FlowRevisionInstanceMetadata] The initialized instance with metadata. + def initialize(version, flow_revision_instance, headers, status_code) + super(version, headers, status_code) + @flow_revision_instance = flow_revision_instance + end + + def flow_revision + @flow_revision_instance + end + + def to_s + "" + end + end + + class FlowRevisionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow_revision_instance = payload.body[key].map do |data| + FlowRevisionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow_revision_instance + @instance + end + end + class FlowRevisionPage < Page ## # Initialize the FlowRevisionPage @@ -209,6 +296,54 @@ def to_s '' end end + + class FlowRevisionPageMetadata < PageMetadata + attr_reader :flow_revision_page + + def initialize(version, response, solution, limit) + super(version, response) + @flow_revision_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @flow_revision_page << FlowRevisionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @flow_revision_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FlowRevisionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow_revision = payload.body[key].map do |data| + FlowRevisionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow_revision + @flow_revision + end + end + class FlowRevisionInstance < InstanceResource ## # Initialize the FlowRevisionInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow/flow_test_user.rb b/lib/twilio-ruby/rest/studio/v2/flow/flow_test_user.rb index 253e30ebf..2925726c3 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow/flow_test_user.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow/flow_test_user.rb @@ -76,6 +76,31 @@ def fetch ) end + ## + # Fetch the FlowTestUserInstanceMetadata + # @return [FlowTestUserInstance] Fetched FlowTestUserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + flowTestUser_instance = FlowTestUserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FlowTestUserInstanceMetadata.new( + @version, + flowTestUser_instance, + response.headers, + response.status_code + ) + end + ## # Update the FlowTestUserInstance # @param [Array[String]] test_users List of test user identities that can test draft versions of the flow. @@ -102,6 +127,38 @@ def update( ) end + ## + # Update the FlowTestUserInstanceMetadata + # @param [Array[String]] test_users List of test user identities that can test draft versions of the flow. + # @return [FlowTestUserInstance] Updated FlowTestUserInstance + def update_with_metadata( + test_users: nil + ) + + data = Twilio::Values.of({ + 'TestUsers' => Twilio.serialize_list(test_users) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + flowTestUser_instance = FlowTestUserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FlowTestUserInstanceMetadata.new( + @version, + flowTestUser_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -118,6 +175,45 @@ def inspect end end + class FlowTestUserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FlowTestUserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FlowTestUserInstance] flow_test_user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FlowTestUserInstanceMetadata] The initialized instance with metadata. + def initialize(version, flow_test_user_instance, headers, status_code) + super(version, headers, status_code) + @flow_test_user_instance = flow_test_user_instance + end + + def flow_test_user + @flow_test_user_instance + end + + def to_s + "" + end + end + + class FlowTestUserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow_test_user_instance = payload.body[key].map do |data| + FlowTestUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow_test_user_instance + @instance + end + end + class FlowTestUserPage < Page ## # Initialize the FlowTestUserPage @@ -146,6 +242,54 @@ def to_s '' end end + + class FlowTestUserPageMetadata < PageMetadata + attr_reader :flow_test_user_page + + def initialize(version, response, solution, limit) + super(version, response) + @flow_test_user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @flow_test_user_page << FlowTestUserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @flow_test_user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FlowTestUserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow_test_user = payload.body[key].map do |data| + FlowTestUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow_test_user + @flow_test_user + end + end + class FlowTestUserInstance < InstanceResource ## # Initialize the FlowTestUserInstance diff --git a/lib/twilio-ruby/rest/studio/v2/flow_validate.rb b/lib/twilio-ruby/rest/studio/v2/flow_validate.rb index ad4904eae..35ec33eb4 100644 --- a/lib/twilio-ruby/rest/studio/v2/flow_validate.rb +++ b/lib/twilio-ruby/rest/studio/v2/flow_validate.rb @@ -64,6 +64,46 @@ def update( ) end + ## + # Update the FlowValidateInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the Flow. + # @param [Status] status + # @param [Object] definition JSON representation of flow definition. + # @param [String] commit_message Description of change made in the revision. + # @return [FlowValidateInstance] Updated FlowValidateInstance + def update_with_metadata( + friendly_name: nil, + status: nil, + definition: nil, + commit_message: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Status' => status, + 'Definition' => Twilio.serialize_object(definition), + 'CommitMessage' => commit_message, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + flowValidate_instance = FlowValidateInstance.new( + @version, + response.body, + ) + FlowValidateInstanceMetadata.new( + @version, + flowValidate_instance, + response.headers, + response.status_code + ) + end + @@ -101,6 +141,54 @@ def to_s '' end end + + class FlowValidatePageMetadata < PageMetadata + attr_reader :flow_validate_page + + def initialize(version, response, solution, limit) + super(version, response) + @flow_validate_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @flow_validate_page << FlowValidateListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @flow_validate_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FlowValidateListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @flow_validate = payload.body[key].map do |data| + FlowValidateInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def flow_validate + @flow_validate + end + end + class FlowValidateInstance < InstanceResource ## # Initialize the FlowValidateInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb b/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb index 5e8db2e8a..dfcd4ea19 100644 --- a/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb +++ b/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the EsimProfileInstanceMetadata + # @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 [Boolean] generate_matching_id When set to `true`, a value for `Eid` does not need to be provided. Instead, when the eSIM profile is reserved, a matching ID will be generated and returned via the `matching_id` property. This identifies the specific eSIM profile that can be used by any capable device to claim and download the profile. + # @param [String] eid Identifier of the eUICC that will claim the eSIM Profile. + # @return [EsimProfileInstance] Created EsimProfileInstance + def create_with_metadata( + callback_url: :unset, + callback_method: :unset, + generate_matching_id: :unset, + eid: :unset + ) + + data = Twilio::Values.of({ + 'CallbackUrl' => callback_url, + 'CallbackMethod' => callback_method, + 'GenerateMatchingId' => generate_matching_id, + 'Eid' => eid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + esimProfile_instance = EsimProfileInstance.new( + @version, + response.body, + ) + EsimProfileInstanceMetadata.new( + @version, + esimProfile_instance, + response.headers, + response.status_code + ) + end + ## # Lists EsimProfileInstance records from the API as a list. @@ -115,6 +155,34 @@ def stream(eid: :unset, sim_sid: :unset, status: :unset, limit: nil, page_size: @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EsimProfilePageMetadata records from the API as a list. + # @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/iot/supersim/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. + # @param [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 + # 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_with_metadata(eid: :unset, sim_sid: :unset, status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Eid' => eid, + 'SimSid' => sim_sid, + 'Status' => status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EsimProfilePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EsimProfileInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -213,6 +281,31 @@ def fetch ) end + ## + # Fetch the EsimProfileInstanceMetadata + # @return [EsimProfileInstance] Fetched EsimProfileInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + esimProfile_instance = EsimProfileInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EsimProfileInstanceMetadata.new( + @version, + esimProfile_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -229,6 +322,45 @@ def inspect end end + class EsimProfileInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EsimProfileInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EsimProfileInstance] esim_profile_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EsimProfileInstanceMetadata] The initialized instance with metadata. + def initialize(version, esim_profile_instance, headers, status_code) + super(version, headers, status_code) + @esim_profile_instance = esim_profile_instance + end + + def esim_profile + @esim_profile_instance + end + + def to_s + "" + end + end + + class EsimProfileListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @esim_profile_instance = payload.body[key].map do |data| + EsimProfileInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def esim_profile_instance + @instance + end + end + class EsimProfilePage < Page ## # Initialize the EsimProfilePage @@ -257,6 +389,54 @@ def to_s '' end end + + class EsimProfilePageMetadata < PageMetadata + attr_reader :esim_profile_page + + def initialize(version, response, solution, limit) + super(version, response) + @esim_profile_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @esim_profile_page << EsimProfileListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @esim_profile_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EsimProfileListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @esim_profile = payload.body[key].map do |data| + EsimProfileInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def esim_profile + @esim_profile + end + end + class EsimProfileInstance < InstanceResource ## # Initialize the EsimProfileInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/fleet.rb b/lib/twilio-ruby/rest/supersim/v1/fleet.rb index e2b4496d2..15d6ed5b0 100644 --- a/lib/twilio-ruby/rest/supersim/v1/fleet.rb +++ b/lib/twilio-ruby/rest/supersim/v1/fleet.rb @@ -79,6 +79,61 @@ def create( ) end + ## + # Create the FleetInstanceMetadata + # @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] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. + # @param [Boolean] data_enabled Defines whether SIMs in the Fleet are capable of using 2G/3G/4G/LTE/CAT-M data connectivity. Defaults to `true`. + # @param [String] data_limit The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet 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 [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`. + # @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 range; any response body will be ignored. + # @param [String] sms_commands_method A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`. + # @return [FleetInstance] Created FleetInstance + def create_with_metadata( + 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, + 'IpCommandsUrl' => ip_commands_url, + 'IpCommandsMethod' => ip_commands_method, + 'SmsCommandsEnabled' => sms_commands_enabled, + 'SmsCommandsUrl' => sms_commands_url, + 'SmsCommandsMethod' => sms_commands_method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + fleet_instance = FleetInstance.new( + @version, + response.body, + ) + FleetInstanceMetadata.new( + @version, + fleet_instance, + response.headers, + response.status_code + ) + end + ## # Lists FleetInstance records from the API as a list. @@ -122,6 +177,30 @@ def stream(network_access_profile: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FleetPageMetadata records from the API as a list. + # @param [String] network_access_profile The SID or unique name of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to. + # @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_with_metadata(network_access_profile: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'NetworkAccessProfile' => network_access_profile, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FleetPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FleetInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -216,6 +295,31 @@ def fetch ) end + ## + # Fetch the FleetInstanceMetadata + # @return [FleetInstance] Fetched FleetInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + fleet_instance = FleetInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FleetInstanceMetadata.new( + @version, + fleet_instance, + response.headers, + response.status_code + ) + end + ## # Update the FleetInstance # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. @@ -260,6 +364,56 @@ def update( ) end + ## + # Update the FleetInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. + # @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] 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 range; any response body will be ignored. + # @param [String] sms_commands_method A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`. + # @param [String] data_limit The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet 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). + # @return [FleetInstance] Updated FleetInstance + def update_with_metadata( + unique_name: :unset, + network_access_profile: :unset, + ip_commands_url: :unset, + ip_commands_method: :unset, + sms_commands_url: :unset, + sms_commands_method: :unset, + data_limit: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'NetworkAccessProfile' => network_access_profile, + 'IpCommandsUrl' => ip_commands_url, + 'IpCommandsMethod' => ip_commands_method, + 'SmsCommandsUrl' => sms_commands_url, + 'SmsCommandsMethod' => sms_commands_method, + 'DataLimit' => data_limit, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + fleet_instance = FleetInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + FleetInstanceMetadata.new( + @version, + fleet_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -276,6 +430,45 @@ def inspect end end + class FleetInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FleetInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FleetInstance] fleet_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FleetInstanceMetadata] The initialized instance with metadata. + def initialize(version, fleet_instance, headers, status_code) + super(version, headers, status_code) + @fleet_instance = fleet_instance + end + + def fleet + @fleet_instance + end + + def to_s + "" + end + end + + class FleetListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @fleet_instance = payload.body[key].map do |data| + FleetInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def fleet_instance + @instance + end + end + class FleetPage < Page ## # Initialize the FleetPage @@ -304,6 +497,54 @@ def to_s '' end end + + class FleetPageMetadata < PageMetadata + attr_reader :fleet_page + + def initialize(version, response, solution, limit) + super(version, response) + @fleet_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @fleet_page << FleetListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @fleet_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FleetListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @fleet = payload.body[key].map do |data| + FleetInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def fleet + @fleet + end + end + class FleetInstance < InstanceResource ## # Initialize the FleetInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/ip_command.rb b/lib/twilio-ruby/rest/supersim/v1/ip_command.rb index ed3f1a31a..b2350459f 100644 --- a/lib/twilio-ruby/rest/supersim/v1/ip_command.rb +++ b/lib/twilio-ruby/rest/supersim/v1/ip_command.rb @@ -70,6 +70,52 @@ def create( ) end + ## + # Create the IpCommandInstanceMetadata + # @param [String] sim The `sid` or `unique_name` of the [Super SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) to send the IP Command to. + # @param [String] payload The data that will be sent to the device. The payload cannot exceed 1300 bytes. If the PayloadType is set to text, the payload is encoded in UTF-8. If PayloadType is set to binary, the payload is encoded in Base64. + # @param [String] device_port The device port to which the IP Command will be sent. + # @param [PayloadType] payload_type + # @param [String] callback_url The URL we should call using the `callback_method` after we have sent the IP Command. + # @param [String] callback_method The HTTP method we should use to call `callback_url`. Can be `GET` or `POST`, and the default is `POST`. + # @return [IpCommandInstance] Created IpCommandInstance + def create_with_metadata( + sim: nil, + payload: nil, + device_port: nil, + payload_type: :unset, + callback_url: :unset, + callback_method: :unset + ) + + data = Twilio::Values.of({ + 'Sim' => sim, + 'Payload' => payload, + 'DevicePort' => device_port, + 'PayloadType' => payload_type, + 'CallbackUrl' => callback_url, + 'CallbackMethod' => callback_method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ipCommand_instance = IpCommandInstance.new( + @version, + response.body, + ) + IpCommandInstanceMetadata.new( + @version, + ipCommand_instance, + response.headers, + response.status_code + ) + end + ## # Lists IpCommandInstance records from the API as a list. @@ -125,6 +171,36 @@ def stream(sim: :unset, sim_iccid: :unset, status: :unset, direction: :unset, li @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists IpCommandPageMetadata records from the API as a list. + # @param [String] sim The SID or unique name of the Sim resource that IP Command was sent to or from. + # @param [String] sim_iccid The ICCID of the Sim resource that IP Command was sent to or from. + # @param [Status] status The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each. + # @param [Direction] direction The direction of the IP 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 [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_with_metadata(sim: :unset, sim_iccid: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Sim' => sim, + 'SimIccid' => sim_iccid, + 'Status' => status, + 'Direction' => direction, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + IpCommandPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields IpCommandInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -225,6 +301,31 @@ def fetch ) end + ## + # Fetch the IpCommandInstanceMetadata + # @return [IpCommandInstance] Fetched IpCommandInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ipCommand_instance = IpCommandInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + IpCommandInstanceMetadata.new( + @version, + ipCommand_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -241,6 +342,45 @@ def inspect end end + class IpCommandInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new IpCommandInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}IpCommandInstance] ip_command_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [IpCommandInstanceMetadata] The initialized instance with metadata. + def initialize(version, ip_command_instance, headers, status_code) + super(version, headers, status_code) + @ip_command_instance = ip_command_instance + end + + def ip_command + @ip_command_instance + end + + def to_s + "" + end + end + + class IpCommandListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_command_instance = payload.body[key].map do |data| + IpCommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_command_instance + @instance + end + end + class IpCommandPage < Page ## # Initialize the IpCommandPage @@ -269,6 +409,54 @@ def to_s '' end end + + class IpCommandPageMetadata < PageMetadata + attr_reader :ip_command_page + + def initialize(version, response, solution, limit) + super(version, response) + @ip_command_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @ip_command_page << IpCommandListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @ip_command_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class IpCommandListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_command = payload.body[key].map do |data| + IpCommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_command + @ip_command + end + end + class IpCommandInstance < InstanceResource ## # Initialize the IpCommandInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/network.rb b/lib/twilio-ruby/rest/supersim/v1/network.rb index 1a8493aca..5ad4a4744 100644 --- a/lib/twilio-ruby/rest/supersim/v1/network.rb +++ b/lib/twilio-ruby/rest/supersim/v1/network.rb @@ -81,6 +81,34 @@ def stream(iso_country: :unset, mcc: :unset, mnc: :unset, limit: nil, page_size: @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists NetworkPageMetadata records from the API as a list. + # @param [String] iso_country The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resources to read. + # @param [String] mcc The 'mobile country code' of a country. Network resources with this `mcc` in their `identifiers` will be read. + # @param [String] mnc The 'mobile network code' of a mobile operator network. Network resources with this `mnc` in their `identifiers` will be read. + # @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_with_metadata(iso_country: :unset, mcc: :unset, mnc: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'IsoCountry' => iso_country, + 'Mcc' => mcc, + 'Mnc' => mnc, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + NetworkPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields NetworkInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -179,6 +207,31 @@ def fetch ) end + ## + # Fetch the NetworkInstanceMetadata + # @return [NetworkInstance] Fetched NetworkInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + network_instance = NetworkInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + NetworkInstanceMetadata.new( + @version, + network_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -195,6 +248,45 @@ def inspect end end + class NetworkInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NetworkInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NetworkInstance] network_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NetworkInstanceMetadata] The initialized instance with metadata. + def initialize(version, network_instance, headers, status_code) + super(version, headers, status_code) + @network_instance = network_instance + end + + def network + @network_instance + end + + def to_s + "" + end + end + + class NetworkListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @network_instance = payload.body[key].map do |data| + NetworkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def network_instance + @instance + end + end + class NetworkPage < Page ## # Initialize the NetworkPage @@ -223,6 +315,54 @@ def to_s '' end end + + class NetworkPageMetadata < PageMetadata + attr_reader :network_page + + def initialize(version, response, solution, limit) + super(version, response) + @network_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @network_page << NetworkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @network_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NetworkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @network = payload.body[key].map do |data| + NetworkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def network + @network + end + end + class NetworkInstance < InstanceResource ## # Initialize the NetworkInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb b/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb index fa883b0cd..b5a87f664 100644 --- a/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb +++ b/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb @@ -58,6 +58,40 @@ def create( ) end + ## + # Create the NetworkAccessProfileInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. + # @param [Array[String]] networks List of Network SIDs that this Network Access Profile will allow connections to. + # @return [NetworkAccessProfileInstance] Created NetworkAccessProfileInstance + def create_with_metadata( + unique_name: :unset, + networks: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'Networks' => Twilio.serialize_list(networks) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + networkAccessProfile_instance = NetworkAccessProfileInstance.new( + @version, + response.body, + ) + NetworkAccessProfileInstanceMetadata.new( + @version, + networkAccessProfile_instance, + response.headers, + response.status_code + ) + end + ## # Lists NetworkAccessProfileInstance records from the API as a list. @@ -97,6 +131,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists NetworkAccessProfilePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + NetworkAccessProfilePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields NetworkAccessProfileInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -190,6 +246,31 @@ def fetch ) end + ## + # Fetch the NetworkAccessProfileInstanceMetadata + # @return [NetworkAccessProfileInstance] Fetched NetworkAccessProfileInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + networkAccessProfile_instance = NetworkAccessProfileInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + NetworkAccessProfileInstanceMetadata.new( + @version, + networkAccessProfile_instance, + response.headers, + response.status_code + ) + end + ## # Update the NetworkAccessProfileInstance # @param [String] unique_name The new unique name of the Network Access Profile. @@ -216,6 +297,38 @@ def update( ) end + ## + # Update the NetworkAccessProfileInstanceMetadata + # @param [String] unique_name The new unique name of the Network Access Profile. + # @return [NetworkAccessProfileInstance] Updated NetworkAccessProfileInstance + def update_with_metadata( + unique_name: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + networkAccessProfile_instance = NetworkAccessProfileInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + NetworkAccessProfileInstanceMetadata.new( + @version, + networkAccessProfile_instance, + response.headers, + response.status_code + ) + end + ## # Access the networks # @return [NetworkAccessProfileNetworkList] @@ -251,6 +364,45 @@ def inspect end end + class NetworkAccessProfileInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NetworkAccessProfileInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NetworkAccessProfileInstance] network_access_profile_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NetworkAccessProfileInstanceMetadata] The initialized instance with metadata. + def initialize(version, network_access_profile_instance, headers, status_code) + super(version, headers, status_code) + @network_access_profile_instance = network_access_profile_instance + end + + def network_access_profile + @network_access_profile_instance + end + + def to_s + "" + end + end + + class NetworkAccessProfileListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @network_access_profile_instance = payload.body[key].map do |data| + NetworkAccessProfileInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def network_access_profile_instance + @instance + end + end + class NetworkAccessProfilePage < Page ## # Initialize the NetworkAccessProfilePage @@ -279,6 +431,54 @@ def to_s '' end end + + class NetworkAccessProfilePageMetadata < PageMetadata + attr_reader :network_access_profile_page + + def initialize(version, response, solution, limit) + super(version, response) + @network_access_profile_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @network_access_profile_page << NetworkAccessProfileListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @network_access_profile_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NetworkAccessProfileListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @network_access_profile = payload.body[key].map do |data| + NetworkAccessProfileInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def network_access_profile + @network_access_profile + end + end + class NetworkAccessProfileInstance < InstanceResource ## # Initialize the NetworkAccessProfileInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb b/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb index 1ceff4674..5b94e4e78 100644 --- a/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb +++ b/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the NetworkAccessProfileNetworkInstanceMetadata + # @param [String] network The SID of the Network resource to be added to the Network Access Profile resource. + # @return [NetworkAccessProfileNetworkInstance] Created NetworkAccessProfileNetworkInstance + def create_with_metadata( + network: nil + ) + + data = Twilio::Values.of({ + 'Network' => network, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + networkAccessProfileNetwork_instance = NetworkAccessProfileNetworkInstance.new( + @version, + response.body, + network_access_profile_sid: @solution[:network_access_profile_sid], + ) + NetworkAccessProfileNetworkInstanceMetadata.new( + @version, + networkAccessProfileNetwork_instance, + response.headers, + response.status_code + ) + end + ## # Lists NetworkAccessProfileNetworkInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists NetworkAccessProfileNetworkPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + NetworkAccessProfileNetworkPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields NetworkAccessProfileNetworkInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the NetworkAccessProfileNetworkInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + networkAccessProfileNetwork_instance = NetworkAccessProfileNetworkInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + NetworkAccessProfileNetworkInstanceMetadata.new(@version, networkAccessProfileNetwork_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the NetworkAccessProfileNetworkInstanceMetadata + # @return [NetworkAccessProfileNetworkInstance] Fetched NetworkAccessProfileNetworkInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + networkAccessProfileNetwork_instance = NetworkAccessProfileNetworkInstance.new( + @version, + response.body, + network_access_profile_sid: @solution[:network_access_profile_sid], + sid: @solution[:sid], + ) + NetworkAccessProfileNetworkInstanceMetadata.new( + @version, + networkAccessProfileNetwork_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class NetworkAccessProfileNetworkInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NetworkAccessProfileNetworkInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NetworkAccessProfileNetworkInstance] network_access_profile_network_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NetworkAccessProfileNetworkInstanceMetadata] The initialized instance with metadata. + def initialize(version, network_access_profile_network_instance, headers, status_code) + super(version, headers, status_code) + @network_access_profile_network_instance = network_access_profile_network_instance + end + + def network_access_profile_network + @network_access_profile_network_instance + end + + def to_s + "" + end + end + + class NetworkAccessProfileNetworkListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @network_access_profile_network_instance = payload.body[key].map do |data| + NetworkAccessProfileNetworkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def network_access_profile_network_instance + @instance + end + end + class NetworkAccessProfileNetworkPage < Page ## # Initialize the NetworkAccessProfileNetworkPage @@ -247,6 +385,54 @@ def to_s '' end end + + class NetworkAccessProfileNetworkPageMetadata < PageMetadata + attr_reader :network_access_profile_network_page + + def initialize(version, response, solution, limit) + super(version, response) + @network_access_profile_network_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @network_access_profile_network_page << NetworkAccessProfileNetworkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @network_access_profile_network_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NetworkAccessProfileNetworkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @network_access_profile_network = payload.body[key].map do |data| + NetworkAccessProfileNetworkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def network_access_profile_network + @network_access_profile_network + end + end + class NetworkAccessProfileNetworkInstance < InstanceResource ## # Initialize the NetworkAccessProfileNetworkInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/settings_update.rb b/lib/twilio-ruby/rest/supersim/v1/settings_update.rb index 1451283d2..bfaa4b170 100644 --- a/lib/twilio-ruby/rest/supersim/v1/settings_update.rb +++ b/lib/twilio-ruby/rest/supersim/v1/settings_update.rb @@ -77,6 +77,32 @@ def stream(sim: :unset, status: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SettingsUpdatePageMetadata records from the API as a list. + # @param [String] sim Filter the Settings Updates by a Super SIM's SID or UniqueName. + # @param [Status] status Filter the Settings Updates by status. Can be `scheduled`, `in-progress`, `successful`, or `failed`. + # @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_with_metadata(sim: :unset, status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Sim' => sim, + 'Status' => status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SettingsUpdatePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SettingsUpdateInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -166,6 +192,54 @@ def to_s '' end end + + class SettingsUpdatePageMetadata < PageMetadata + attr_reader :settings_update_page + + def initialize(version, response, solution, limit) + super(version, response) + @settings_update_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @settings_update_page << SettingsUpdateListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @settings_update_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SettingsUpdateListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @settings_update = payload.body[key].map do |data| + SettingsUpdateInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def settings_update + @settings_update + end + end + class SettingsUpdateInstance < InstanceResource ## # Initialize the SettingsUpdateInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/sim.rb b/lib/twilio-ruby/rest/supersim/v1/sim.rb index b7ba11425..54cbe8b69 100644 --- a/lib/twilio-ruby/rest/supersim/v1/sim.rb +++ b/lib/twilio-ruby/rest/supersim/v1/sim.rb @@ -58,6 +58,40 @@ def create( ) end + ## + # Create the SimInstanceMetadata + # @param [String] iccid The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM to be added to your Account. + # @param [String] registration_code The 10-digit code required to claim the Super SIM for your Account. + # @return [SimInstance] Created SimInstance + def create_with_metadata( + iccid: nil, + registration_code: nil + ) + + data = Twilio::Values.of({ + 'Iccid' => iccid, + 'RegistrationCode' => registration_code, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + ) + SimInstanceMetadata.new( + @version, + sim_instance, + response.headers, + response.status_code + ) + end + ## # Lists SimInstance records from the API as a list. @@ -109,6 +143,34 @@ def stream(status: :unset, fleet: :unset, iccid: :unset, limit: nil, page_size: @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SimPageMetadata records from the API as a list. + # @param [Status] status The status of the Sim resources to read. Can be `new`, `ready`, `active`, `inactive`, or `scheduled`. + # @param [String] fleet The SID or unique name of the Fleet to which a list of Sims are assigned. + # @param [String] iccid The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with a Super SIM to filter the list by. Passing this parameter will always return a list containing zero or one SIMs. + # @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_with_metadata(status: :unset, fleet: :unset, iccid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'Fleet' => fleet, + 'Iccid' => iccid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SimPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SimInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -209,6 +271,31 @@ def fetch ) end + ## + # Fetch the SimInstanceMetadata + # @return [SimInstance] Fetched SimInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SimInstanceMetadata.new( + @version, + sim_instance, + response.headers, + response.status_code + ) + end + ## # Update the SimInstance # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. @@ -250,6 +337,53 @@ def update( ) end + ## + # Update the SimInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. + # @param [StatusUpdate] status + # @param [String] fleet The SID or unique name of the Fleet to which the SIM resource should be assigned. + # @param [String] callback_url The URL we should call using the `callback_method` after an asynchronous update has finished. + # @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] account_sid The SID of the Account to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a Subaccount of the requesting Account. Only valid when the Sim resource's status is new. + # @return [SimInstance] Updated SimInstance + def update_with_metadata( + unique_name: :unset, + status: :unset, + fleet: :unset, + callback_url: :unset, + callback_method: :unset, + account_sid: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'Status' => status, + 'Fleet' => fleet, + 'CallbackUrl' => callback_url, + 'CallbackMethod' => callback_method, + 'AccountSid' => account_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SimInstanceMetadata.new( + @version, + sim_instance, + response.headers, + response.status_code + ) + end + ## # Access the billing_periods # @return [BillingPeriodList] @@ -288,6 +422,45 @@ def inspect end end + class SimInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SimInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SimInstance] sim_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SimInstanceMetadata] The initialized instance with metadata. + def initialize(version, sim_instance, headers, status_code) + super(version, headers, status_code) + @sim_instance = sim_instance + end + + def sim + @sim_instance + end + + def to_s + "" + end + end + + class SimListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sim_instance = payload.body[key].map do |data| + SimInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sim_instance + @instance + end + end + class SimPage < Page ## # Initialize the SimPage @@ -316,6 +489,54 @@ def to_s '' end end + + class SimPageMetadata < PageMetadata + attr_reader :sim_page + + def initialize(version, response, solution, limit) + super(version, response) + @sim_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sim_page << SimListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sim_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SimListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sim = payload.body[key].map do |data| + SimInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sim + @sim + end + end + class SimInstance < InstanceResource ## # Initialize the SimInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/sim/billing_period.rb b/lib/twilio-ruby/rest/supersim/v1/sim/billing_period.rb index 7690694c0..626336369 100644 --- a/lib/twilio-ruby/rest/supersim/v1/sim/billing_period.rb +++ b/lib/twilio-ruby/rest/supersim/v1/sim/billing_period.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BillingPeriodPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BillingPeriodPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BillingPeriodInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,6 +178,54 @@ def to_s '' end end + + class BillingPeriodPageMetadata < PageMetadata + attr_reader :billing_period_page + + def initialize(version, response, solution, limit) + super(version, response) + @billing_period_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @billing_period_page << BillingPeriodListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @billing_period_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BillingPeriodListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @billing_period = payload.body[key].map do |data| + BillingPeriodInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def billing_period + @billing_period + end + end + class BillingPeriodInstance < InstanceResource ## # Initialize the BillingPeriodInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/sim/sim_ip_address.rb b/lib/twilio-ruby/rest/supersim/v1/sim/sim_ip_address.rb index 33b70172d..2d5f6f800 100644 --- a/lib/twilio-ruby/rest/supersim/v1/sim/sim_ip_address.rb +++ b/lib/twilio-ruby/rest/supersim/v1/sim/sim_ip_address.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SimIpAddressPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SimIpAddressPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SimIpAddressInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,6 +178,54 @@ def to_s '' end end + + class SimIpAddressPageMetadata < PageMetadata + attr_reader :sim_ip_address_page + + def initialize(version, response, solution, limit) + super(version, response) + @sim_ip_address_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sim_ip_address_page << SimIpAddressListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sim_ip_address_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SimIpAddressListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sim_ip_address = payload.body[key].map do |data| + SimIpAddressInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sim_ip_address + @sim_ip_address + end + end + class SimIpAddressInstance < InstanceResource ## # Initialize the SimIpAddressInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/sms_command.rb b/lib/twilio-ruby/rest/supersim/v1/sms_command.rb index 7f1512b66..1994e5376 100644 --- a/lib/twilio-ruby/rest/supersim/v1/sms_command.rb +++ b/lib/twilio-ruby/rest/supersim/v1/sms_command.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the SmsCommandInstanceMetadata + # @param [String] sim The `sid` or `unique_name` of the [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 `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 [SmsCommandInstance] Created SmsCommandInstance + def create_with_metadata( + sim: nil, + payload: nil, + callback_method: :unset, + callback_url: :unset + ) + + data = Twilio::Values.of({ + 'Sim' => sim, + 'Payload' => payload, + 'CallbackMethod' => callback_method, + 'CallbackUrl' => callback_url, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + smsCommand_instance = SmsCommandInstance.new( + @version, + response.body, + ) + SmsCommandInstanceMetadata.new( + @version, + smsCommand_instance, + response.headers, + response.status_code + ) + end + ## # Lists SmsCommandInstance records from the API as a list. @@ -115,6 +155,34 @@ def stream(sim: :unset, status: :unset, direction: :unset, limit: nil, page_size @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SmsCommandPageMetadata records from the API as a list. + # @param [String] sim The SID or unique name of the Sim resource that SMS Command was sent to or from. + # @param [Status] status The status of the SMS Command. Can be: `queued`, `sent`, `delivered`, `received` or `failed`. See the [SMS Command Status Values](https://www.twilio.com/docs/iot/supersim/api/smscommand-resource#status-values) for a description of each. + # @param [Direction] direction The direction of the SMS 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 [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_with_metadata(sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Sim' => sim, + 'Status' => status, + 'Direction' => direction, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SmsCommandPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SmsCommandInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -213,6 +281,31 @@ def fetch ) end + ## + # Fetch the SmsCommandInstanceMetadata + # @return [SmsCommandInstance] Fetched SmsCommandInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + smsCommand_instance = SmsCommandInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SmsCommandInstanceMetadata.new( + @version, + smsCommand_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -229,6 +322,45 @@ def inspect end end + class SmsCommandInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SmsCommandInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SmsCommandInstance] sms_command_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SmsCommandInstanceMetadata] The initialized instance with metadata. + def initialize(version, sms_command_instance, headers, status_code) + super(version, headers, status_code) + @sms_command_instance = sms_command_instance + end + + def sms_command + @sms_command_instance + end + + def to_s + "" + end + end + + class SmsCommandListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sms_command_instance = payload.body[key].map do |data| + SmsCommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sms_command_instance + @instance + end + end + class SmsCommandPage < Page ## # Initialize the SmsCommandPage @@ -257,6 +389,54 @@ def to_s '' end end + + class SmsCommandPageMetadata < PageMetadata + attr_reader :sms_command_page + + def initialize(version, response, solution, limit) + super(version, response) + @sms_command_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sms_command_page << SmsCommandListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sms_command_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SmsCommandListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sms_command = payload.body[key].map do |data| + SmsCommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sms_command + @sms_command + end + end + class SmsCommandInstance < InstanceResource ## # Initialize the SmsCommandInstance diff --git a/lib/twilio-ruby/rest/supersim/v1/usage_record.rb b/lib/twilio-ruby/rest/supersim/v1/usage_record.rb index 5026d2eb3..e2e6e4f89 100644 --- a/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +++ b/lib/twilio-ruby/rest/supersim/v1/usage_record.rb @@ -101,6 +101,44 @@ def stream(sim: :unset, fleet: :unset, network: :unset, iso_country: :unset, gro @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UsageRecordPageMetadata records from the API as a list. + # @param [String] sim SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM. + # @param [String] fleet SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred. + # @param [String] network SID of a Network resource. Only show UsageRecords representing usage on this network. + # @param [String] iso_country Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country. + # @param [Group] group Dimension over which to aggregate usage records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter. + # @param [Granularity] granularity Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period. + # @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 (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 + # 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_with_metadata(sim: :unset, fleet: :unset, network: :unset, iso_country: :unset, group: :unset, granularity: :unset, start_time: :unset, end_time: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Sim' => sim, + 'Fleet' => fleet, + 'Network' => network, + 'IsoCountry' => iso_country, + 'Group' => group, + 'Granularity' => granularity, + 'StartTime' => Twilio.serialize_iso8601_datetime(start_time), + 'EndTime' => Twilio.serialize_iso8601_datetime(end_time), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UsageRecordPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UsageRecordInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -202,6 +240,54 @@ def to_s '' end end + + class UsageRecordPageMetadata < PageMetadata + attr_reader :usage_record_page + + def initialize(version, response, solution, limit) + super(version, response) + @usage_record_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @usage_record_page << UsageRecordListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @usage_record_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsageRecordListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @usage_record = payload.body[key].map do |data| + UsageRecordInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def usage_record + @usage_record + end + end + class UsageRecordInstance < InstanceResource ## # Initialize the UsageRecordInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service.rb b/lib/twilio-ruby/rest/sync/v1/service.rb index b83490c0e..8ee6462df 100644 --- a/lib/twilio-ruby/rest/sync/v1/service.rb +++ b/lib/twilio-ruby/rest/sync/v1/service.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name A string that you assign to describe the resource. + # @param [String] webhook_url The URL we should call when Sync objects are manipulated. + # @param [Boolean] reachability_webhooks_enabled Whether the service instance should call `webhook_url` when client endpoints connect to Sync. The default is `false`. + # @param [Boolean] acl_enabled Whether token identities in the Service must be granted access to Sync objects by using the [Permissions](https://www.twilio.com/docs/sync/api/sync-permissions) resource. + # @param [Boolean] reachability_debouncing_enabled Whether every `endpoint_disconnected` event should occur after a configurable delay. The default is `false`, where the `endpoint_disconnected` event occurs immediately after disconnection. When `true`, intervening reconnections can prevent the `endpoint_disconnected` event. + # @param [String] reachability_debouncing_window The reachability event delay in milliseconds if `reachability_debouncing_enabled` = `true`. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before the `webhook_url` is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the call to `webhook_url`. + # @param [Boolean] webhooks_from_rest_enabled Whether the Service instance should call `webhook_url` when the REST API is used to update Sync objects. The default is `false`. + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: :unset, + webhook_url: :unset, + reachability_webhooks_enabled: :unset, + acl_enabled: :unset, + reachability_debouncing_enabled: :unset, + reachability_debouncing_window: :unset, + webhooks_from_rest_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'WebhookUrl' => webhook_url, + 'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled, + 'AclEnabled' => acl_enabled, + 'ReachabilityDebouncingEnabled' => reachability_debouncing_enabled, + 'ReachabilityDebouncingWindow' => reachability_debouncing_window, + 'WebhooksFromRestEnabled' => webhooks_from_rest_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -112,6 +161,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -198,7 +269,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -220,6 +310,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] webhook_url The URL we should call when Sync objects are manipulated. @@ -264,6 +379,56 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] webhook_url The URL we should call when Sync objects are manipulated. + # @param [String] friendly_name A string that you assign to describe the resource. + # @param [Boolean] reachability_webhooks_enabled Whether the service instance should call `webhook_url` when client endpoints connect to Sync. The default is `false`. + # @param [Boolean] acl_enabled Whether token identities in the Service must be granted access to Sync objects by using the [Permissions](https://www.twilio.com/docs/sync/api/sync-permissions) resource. + # @param [Boolean] reachability_debouncing_enabled Whether every `endpoint_disconnected` event should occur after a configurable delay. The default is `false`, where the `endpoint_disconnected` event occurs immediately after disconnection. When `true`, intervening reconnections can prevent the `endpoint_disconnected` event. + # @param [String] reachability_debouncing_window The reachability event delay in milliseconds if `reachability_debouncing_enabled` = `true`. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before the webhook is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the webhook from being called. + # @param [Boolean] webhooks_from_rest_enabled Whether the Service instance should call `webhook_url` when the REST API is used to update Sync objects. The default is `false`. + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + webhook_url: :unset, + friendly_name: :unset, + reachability_webhooks_enabled: :unset, + acl_enabled: :unset, + reachability_debouncing_enabled: :unset, + reachability_debouncing_window: :unset, + webhooks_from_rest_enabled: :unset + ) + + data = Twilio::Values.of({ + 'WebhookUrl' => webhook_url, + 'FriendlyName' => friendly_name, + 'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled, + 'AclEnabled' => acl_enabled, + 'ReachabilityDebouncingEnabled' => reachability_debouncing_enabled, + 'ReachabilityDebouncingWindow' => reachability_debouncing_window, + 'WebhooksFromRestEnabled' => webhooks_from_rest_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the sync_streams # @return [SyncStreamList] @@ -356,6 +521,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -384,6 +588,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/document.rb b/lib/twilio-ruby/rest/sync/v1/service/document.rb index af251e2d3..9148a851b 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/document.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/document.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the DocumentInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the Sync Document + # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length. + # @param [String] ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Document expires and is deleted (the Sync Document's time-to-live). + # @return [DocumentInstance] Created DocumentInstance + def create_with_metadata( + unique_name: :unset, + data: :unset, + ttl: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'Data' => Twilio.serialize_object(data), + 'Ttl' => ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + document_instance = DocumentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + DocumentInstanceMetadata.new( + @version, + document_instance, + response.headers, + response.status_code + ) + end + ## # Lists DocumentInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DocumentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DocumentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DocumentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -187,7 +247,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the DocumentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + document_instance = DocumentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + DocumentInstanceMetadata.new(@version, document_instance, response.headers, response.status_code) end ## @@ -210,6 +289,32 @@ def fetch ) end + ## + # Fetch the DocumentInstanceMetadata + # @return [DocumentInstance] Fetched DocumentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + document_instance = DocumentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + DocumentInstanceMetadata.new( + @version, + document_instance, + response.headers, + response.status_code + ) + end + ## # Update the DocumentInstance # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length. @@ -242,6 +347,44 @@ def update( ) end + ## + # Update the DocumentInstanceMetadata + # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length. + # @param [String] ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Document expires and is deleted (time-to-live). + # @param [String] if_match The If-Match HTTP request header + # @return [DocumentInstance] Updated DocumentInstance + def update_with_metadata( + data: :unset, + ttl: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'Data' => Twilio.serialize_object(data), + 'Ttl' => ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + document_instance = DocumentInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + DocumentInstanceMetadata.new( + @version, + document_instance, + response.headers, + response.status_code + ) + end + ## # Access the document_permissions # @return [DocumentPermissionList] @@ -277,6 +420,45 @@ def inspect end end + class DocumentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DocumentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DocumentInstance] document_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DocumentInstanceMetadata] The initialized instance with metadata. + def initialize(version, document_instance, headers, status_code) + super(version, headers, status_code) + @document_instance = document_instance + end + + def document + @document_instance + end + + def to_s + "" + end + end + + class DocumentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @document_instance = payload.body[key].map do |data| + DocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def document_instance + @instance + end + end + class DocumentPage < Page ## # Initialize the DocumentPage @@ -305,6 +487,54 @@ def to_s '' end end + + class DocumentPageMetadata < PageMetadata + attr_reader :document_page + + def initialize(version, response, solution, limit) + super(version, response) + @document_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @document_page << DocumentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @document_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DocumentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @document = payload.body[key].map do |data| + DocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def document + @document + end + end + class DocumentInstance < InstanceResource ## # Initialize the DocumentInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb b/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb index 3436bb43a..399812192 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DocumentPermissionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DocumentPermissionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DocumentPermissionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the DocumentPermissionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + documentPermission_instance = DocumentPermissionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + DocumentPermissionInstanceMetadata.new(@version, documentPermission_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the DocumentPermissionInstanceMetadata + # @return [DocumentPermissionInstance] Fetched DocumentPermissionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + documentPermission_instance = DocumentPermissionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + document_sid: @solution[:document_sid], + identity: @solution[:identity], + ) + DocumentPermissionInstanceMetadata.new( + @version, + documentPermission_instance, + response.headers, + response.status_code + ) + end + ## # Update the DocumentPermissionInstance # @param [Boolean] read Whether the identity can read the Sync Document. Default value is `false`. @@ -214,6 +282,46 @@ def update( ) end + ## + # Update the DocumentPermissionInstanceMetadata + # @param [Boolean] read Whether the identity can read the Sync Document. Default value is `false`. + # @param [Boolean] write Whether the identity can update the Sync Document. Default value is `false`. + # @param [Boolean] manage Whether the identity can delete the Sync Document. Default value is `false`. + # @return [DocumentPermissionInstance] Updated DocumentPermissionInstance + def update_with_metadata( + read: nil, + write: nil, + manage: nil + ) + + data = Twilio::Values.of({ + 'Read' => read, + 'Write' => write, + 'Manage' => manage, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + documentPermission_instance = DocumentPermissionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + document_sid: @solution[:document_sid], + identity: @solution[:identity], + ) + DocumentPermissionInstanceMetadata.new( + @version, + documentPermission_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -230,6 +338,45 @@ def inspect end end + class DocumentPermissionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new DocumentPermissionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}DocumentPermissionInstance] document_permission_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [DocumentPermissionInstanceMetadata] The initialized instance with metadata. + def initialize(version, document_permission_instance, headers, status_code) + super(version, headers, status_code) + @document_permission_instance = document_permission_instance + end + + def document_permission + @document_permission_instance + end + + def to_s + "" + end + end + + class DocumentPermissionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @document_permission_instance = payload.body[key].map do |data| + DocumentPermissionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def document_permission_instance + @instance + end + end + class DocumentPermissionPage < Page ## # Initialize the DocumentPermissionPage @@ -258,6 +405,54 @@ def to_s '' end end + + class DocumentPermissionPageMetadata < PageMetadata + attr_reader :document_permission_page + + def initialize(version, response, solution, limit) + super(version, response) + @document_permission_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @document_permission_page << DocumentPermissionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @document_permission_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DocumentPermissionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @document_permission = payload.body[key].map do |data| + DocumentPermissionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def document_permission + @document_permission + end + end + class DocumentPermissionInstance < InstanceResource ## # Initialize the DocumentPermissionInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb index 202ef7ef9..4b04e7aab 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the SyncListInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The `unique_name` value can be used as an alternative to the `sid` in the URL path to address the resource. + # @param [String] ttl Alias for collection_ttl. If both are provided, this value is ignored. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync List expires (time-to-live) and is deleted. + # @return [SyncListInstance] Created SyncListInstance + def create_with_metadata( + unique_name: :unset, + ttl: :unset, + collection_ttl: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'Ttl' => ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + syncList_instance = SyncListInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + SyncListInstanceMetadata.new( + @version, + syncList_instance, + response.headers, + response.status_code + ) + end + ## # Lists SyncListInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SyncListPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SyncListPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SyncListInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -188,7 +248,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SyncListInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + syncList_instance = SyncListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SyncListInstanceMetadata.new(@version, syncList_instance, response.headers, response.status_code) end ## @@ -211,6 +290,32 @@ def fetch ) end + ## + # Fetch the SyncListInstanceMetadata + # @return [SyncListInstance] Fetched SyncListInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + syncList_instance = SyncListInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SyncListInstanceMetadata.new( + @version, + syncList_instance, + response.headers, + response.status_code + ) + end + ## # Update the SyncListInstance # @param [String] ttl An alias for `collection_ttl`. If both are provided, this value is ignored. @@ -241,6 +346,42 @@ def update( ) end + ## + # Update the SyncListInstanceMetadata + # @param [String] ttl An alias for `collection_ttl`. If both are provided, this value is ignored. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync List expires (time-to-live) and is deleted. + # @return [SyncListInstance] Updated SyncListInstance + def update_with_metadata( + ttl: :unset, + collection_ttl: :unset + ) + + data = Twilio::Values.of({ + 'Ttl' => ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + syncList_instance = SyncListInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SyncListInstanceMetadata.new( + @version, + syncList_instance, + response.headers, + response.status_code + ) + end + ## # Access the sync_list_permissions # @return [SyncListPermissionList] @@ -295,6 +436,45 @@ def inspect end end + class SyncListInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SyncListInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SyncListInstance] sync_list_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SyncListInstanceMetadata] The initialized instance with metadata. + def initialize(version, sync_list_instance, headers, status_code) + super(version, headers, status_code) + @sync_list_instance = sync_list_instance + end + + def sync_list + @sync_list_instance + end + + def to_s + "" + end + end + + class SyncListListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_list_instance = payload.body[key].map do |data| + SyncListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_list_instance + @instance + end + end + class SyncListPage < Page ## # Initialize the SyncListPage @@ -323,6 +503,54 @@ def to_s '' end end + + class SyncListPageMetadata < PageMetadata + attr_reader :sync_list_page + + def initialize(version, response, solution, limit) + super(version, response) + @sync_list_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sync_list_page << SyncListListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sync_list_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SyncListListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_list = payload.body[key].map do |data| + SyncListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_list + @sync_list + end + end + class SyncListInstance < InstanceResource ## # Initialize the SyncListInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb index 9d4888bfe..00579b3a6 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb @@ -69,6 +69,48 @@ def create( ) end + ## + # Create the SyncListItemInstanceMetadata + # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB in length. + # @param [String] ttl An alias for `item_ttl`. If both parameters are provided, this value is ignored. + # @param [String] item_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item expires (time-to-live) and is deleted. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item's parent Sync List expires (time-to-live) and is deleted. + # @return [SyncListItemInstance] Created SyncListItemInstance + def create_with_metadata( + data: nil, + ttl: :unset, + item_ttl: :unset, + collection_ttl: :unset + ) + + data = Twilio::Values.of({ + 'Data' => Twilio.serialize_object(data), + 'Ttl' => ttl, + 'ItemTtl' => item_ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + syncListItem_instance = SyncListItemInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + list_sid: @solution[:list_sid], + ) + SyncListItemInstanceMetadata.new( + @version, + syncListItem_instance, + response.headers, + response.status_code + ) + end + ## # Lists SyncListItemInstance records from the API as a list. @@ -120,6 +162,34 @@ def stream(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SyncListItemPageMetadata records from the API as a list. + # @param [QueryResultOrder] order How to order the List Items returned by their `index` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. + # @param [String] from The `index` of the first Sync List Item resource to read. See also `bounds`. + # @param [QueryFromBoundType] bounds Whether to include the List Item referenced by the `from` parameter. Can be: `inclusive` to include the List Item referenced by the `from` parameter or `exclusive` to start with the next List Item. The default value is `inclusive`. + # @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_with_metadata(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + 'From' => from, + 'Bounds' => bounds, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SyncListItemPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SyncListItemInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -213,7 +283,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SyncListItemInstanceMetadata + # @param [String] if_match If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + if_match: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + syncListItem_instance = SyncListItemInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SyncListItemInstanceMetadata.new(@version, syncListItem_instance, response.headers, response.status_code) end ## @@ -237,6 +329,33 @@ def fetch ) end + ## + # Fetch the SyncListItemInstanceMetadata + # @return [SyncListItemInstance] Fetched SyncListItemInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + syncListItem_instance = SyncListItemInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + list_sid: @solution[:list_sid], + index: @solution[:index], + ) + SyncListItemInstanceMetadata.new( + @version, + syncListItem_instance, + response.headers, + response.status_code + ) + end + ## # Update the SyncListItemInstance # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB in length. @@ -276,6 +395,51 @@ def update( ) end + ## + # Update the SyncListItemInstanceMetadata + # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB in length. + # @param [String] ttl An alias for `item_ttl`. If both parameters are provided, this value is ignored. + # @param [String] item_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item expires (time-to-live) and is deleted. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item's parent Sync List expires (time-to-live) and is deleted. This parameter can only be used when the List Item's `data` or `ttl` is updated in the same request. + # @param [String] if_match If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). + # @return [SyncListItemInstance] Updated SyncListItemInstance + def update_with_metadata( + data: :unset, + ttl: :unset, + item_ttl: :unset, + collection_ttl: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'Data' => Twilio.serialize_object(data), + 'Ttl' => ttl, + 'ItemTtl' => item_ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + syncListItem_instance = SyncListItemInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + list_sid: @solution[:list_sid], + index: @solution[:index], + ) + SyncListItemInstanceMetadata.new( + @version, + syncListItem_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -292,6 +456,45 @@ def inspect end end + class SyncListItemInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SyncListItemInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SyncListItemInstance] sync_list_item_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SyncListItemInstanceMetadata] The initialized instance with metadata. + def initialize(version, sync_list_item_instance, headers, status_code) + super(version, headers, status_code) + @sync_list_item_instance = sync_list_item_instance + end + + def sync_list_item + @sync_list_item_instance + end + + def to_s + "" + end + end + + class SyncListItemListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_list_item_instance = payload.body[key].map do |data| + SyncListItemInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_list_item_instance + @instance + end + end + class SyncListItemPage < Page ## # Initialize the SyncListItemPage @@ -320,6 +523,54 @@ def to_s '' end end + + class SyncListItemPageMetadata < PageMetadata + attr_reader :sync_list_item_page + + def initialize(version, response, solution, limit) + super(version, response) + @sync_list_item_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sync_list_item_page << SyncListItemListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sync_list_item_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SyncListItemListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_list_item = payload.body[key].map do |data| + SyncListItemInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_list_item + @sync_list_item + end + end + class SyncListItemInstance < InstanceResource ## # Initialize the SyncListItemInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb index a6d0bdad4..2c47c6731 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SyncListPermissionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SyncListPermissionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SyncListPermissionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SyncListPermissionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + syncListPermission_instance = SyncListPermissionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SyncListPermissionInstanceMetadata.new(@version, syncListPermission_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the SyncListPermissionInstanceMetadata + # @return [SyncListPermissionInstance] Fetched SyncListPermissionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + syncListPermission_instance = SyncListPermissionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + list_sid: @solution[:list_sid], + identity: @solution[:identity], + ) + SyncListPermissionInstanceMetadata.new( + @version, + syncListPermission_instance, + response.headers, + response.status_code + ) + end + ## # Update the SyncListPermissionInstance # @param [Boolean] read Whether the identity can read the Sync List and its Items. Default value is `false`. @@ -214,6 +282,46 @@ def update( ) end + ## + # Update the SyncListPermissionInstanceMetadata + # @param [Boolean] read Whether the identity can read the Sync List and its Items. Default value is `false`. + # @param [Boolean] write Whether the identity can create, update, and delete Items in the Sync List. Default value is `false`. + # @param [Boolean] manage Whether the identity can delete the Sync List. Default value is `false`. + # @return [SyncListPermissionInstance] Updated SyncListPermissionInstance + def update_with_metadata( + read: nil, + write: nil, + manage: nil + ) + + data = Twilio::Values.of({ + 'Read' => read, + 'Write' => write, + 'Manage' => manage, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + syncListPermission_instance = SyncListPermissionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + list_sid: @solution[:list_sid], + identity: @solution[:identity], + ) + SyncListPermissionInstanceMetadata.new( + @version, + syncListPermission_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -230,6 +338,45 @@ def inspect end end + class SyncListPermissionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SyncListPermissionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SyncListPermissionInstance] sync_list_permission_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SyncListPermissionInstanceMetadata] The initialized instance with metadata. + def initialize(version, sync_list_permission_instance, headers, status_code) + super(version, headers, status_code) + @sync_list_permission_instance = sync_list_permission_instance + end + + def sync_list_permission + @sync_list_permission_instance + end + + def to_s + "" + end + end + + class SyncListPermissionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_list_permission_instance = payload.body[key].map do |data| + SyncListPermissionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_list_permission_instance + @instance + end + end + class SyncListPermissionPage < Page ## # Initialize the SyncListPermissionPage @@ -258,6 +405,54 @@ def to_s '' end end + + class SyncListPermissionPageMetadata < PageMetadata + attr_reader :sync_list_permission_page + + def initialize(version, response, solution, limit) + super(version, response) + @sync_list_permission_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sync_list_permission_page << SyncListPermissionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sync_list_permission_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SyncListPermissionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_list_permission = payload.body[key].map do |data| + SyncListPermissionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_list_permission + @sync_list_permission + end + end + class SyncListPermissionInstance < InstanceResource ## # Initialize the SyncListPermissionInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb index f7fbaf02e..b0d6c2a10 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the SyncMapInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. + # @param [String] ttl An alias for `collection_ttl`. If both parameters are provided, this value is ignored. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Map expires (time-to-live) and is deleted. + # @return [SyncMapInstance] Created SyncMapInstance + def create_with_metadata( + unique_name: :unset, + ttl: :unset, + collection_ttl: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'Ttl' => ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + syncMap_instance = SyncMapInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + SyncMapInstanceMetadata.new( + @version, + syncMap_instance, + response.headers, + response.status_code + ) + end + ## # Lists SyncMapInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SyncMapPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SyncMapPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SyncMapInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -188,7 +248,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SyncMapInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + syncMap_instance = SyncMapInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SyncMapInstanceMetadata.new(@version, syncMap_instance, response.headers, response.status_code) end ## @@ -211,6 +290,32 @@ def fetch ) end + ## + # Fetch the SyncMapInstanceMetadata + # @return [SyncMapInstance] Fetched SyncMapInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + syncMap_instance = SyncMapInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SyncMapInstanceMetadata.new( + @version, + syncMap_instance, + response.headers, + response.status_code + ) + end + ## # Update the SyncMapInstance # @param [String] ttl An alias for `collection_ttl`. If both parameters are provided, this value is ignored. @@ -241,6 +346,42 @@ def update( ) end + ## + # Update the SyncMapInstanceMetadata + # @param [String] ttl An alias for `collection_ttl`. If both parameters are provided, this value is ignored. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Map expires (time-to-live) and is deleted. + # @return [SyncMapInstance] Updated SyncMapInstance + def update_with_metadata( + ttl: :unset, + collection_ttl: :unset + ) + + data = Twilio::Values.of({ + 'Ttl' => ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + syncMap_instance = SyncMapInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SyncMapInstanceMetadata.new( + @version, + syncMap_instance, + response.headers, + response.status_code + ) + end + ## # Access the sync_map_items # @return [SyncMapItemList] @@ -295,6 +436,45 @@ def inspect end end + class SyncMapInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SyncMapInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SyncMapInstance] sync_map_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SyncMapInstanceMetadata] The initialized instance with metadata. + def initialize(version, sync_map_instance, headers, status_code) + super(version, headers, status_code) + @sync_map_instance = sync_map_instance + end + + def sync_map + @sync_map_instance + end + + def to_s + "" + end + end + + class SyncMapListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_map_instance = payload.body[key].map do |data| + SyncMapInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_map_instance + @instance + end + end + class SyncMapPage < Page ## # Initialize the SyncMapPage @@ -323,6 +503,54 @@ def to_s '' end end + + class SyncMapPageMetadata < PageMetadata + attr_reader :sync_map_page + + def initialize(version, response, solution, limit) + super(version, response) + @sync_map_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sync_map_page << SyncMapListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sync_map_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SyncMapListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_map = payload.body[key].map do |data| + SyncMapInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_map + @sync_map + end + end + class SyncMapInstance < InstanceResource ## # Initialize the SyncMapInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb index 651d13516..410f5ecf4 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb @@ -72,6 +72,51 @@ def create( ) end + ## + # Create the SyncMapItemInstanceMetadata + # @param [String] key The unique, user-defined key for the Map Item. Can be up to 320 characters long. + # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. + # @param [String] ttl An alias for `item_ttl`. If both parameters are provided, this value is ignored. + # @param [String] item_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item expires (time-to-live) and is deleted. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item's parent Sync Map expires (time-to-live) and is deleted. + # @return [SyncMapItemInstance] Created SyncMapItemInstance + def create_with_metadata( + key: nil, + data: nil, + ttl: :unset, + item_ttl: :unset, + collection_ttl: :unset + ) + + data = Twilio::Values.of({ + 'Key' => key, + 'Data' => Twilio.serialize_object(data), + 'Ttl' => ttl, + 'ItemTtl' => item_ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + syncMapItem_instance = SyncMapItemInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + map_sid: @solution[:map_sid], + ) + SyncMapItemInstanceMetadata.new( + @version, + syncMapItem_instance, + response.headers, + response.status_code + ) + end + ## # Lists SyncMapItemInstance records from the API as a list. @@ -123,6 +168,34 @@ def stream(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SyncMapItemPageMetadata records from the API as a list. + # @param [QueryResultOrder] order How to order the Map Items returned by their `key` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. Map Items are [ordered lexicographically](https://en.wikipedia.org/wiki/Lexicographical_order) by Item key. + # @param [String] from The `key` of the first Sync Map Item resource to read. See also `bounds`. + # @param [QueryFromBoundType] bounds Whether to include the Map Item referenced by the `from` parameter. Can be: `inclusive` to include the Map Item referenced by the `from` parameter or `exclusive` to start with the next Map Item. The default value is `inclusive`. + # @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_with_metadata(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Order' => order, + 'From' => from, + 'Bounds' => bounds, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SyncMapItemPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SyncMapItemInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -216,7 +289,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SyncMapItemInstanceMetadata + # @param [String] if_match If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + if_match: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + syncMapItem_instance = SyncMapItemInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SyncMapItemInstanceMetadata.new(@version, syncMapItem_instance, response.headers, response.status_code) end ## @@ -240,6 +335,33 @@ def fetch ) end + ## + # Fetch the SyncMapItemInstanceMetadata + # @return [SyncMapItemInstance] Fetched SyncMapItemInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + syncMapItem_instance = SyncMapItemInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + map_sid: @solution[:map_sid], + key: @solution[:key], + ) + SyncMapItemInstanceMetadata.new( + @version, + syncMapItem_instance, + response.headers, + response.status_code + ) + end + ## # Update the SyncMapItemInstance # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. @@ -279,6 +401,51 @@ def update( ) end + ## + # Update the SyncMapItemInstanceMetadata + # @param [Object] data A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. + # @param [String] ttl An alias for `item_ttl`. If both parameters are provided, this value is ignored. + # @param [String] item_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item expires (time-to-live) and is deleted. + # @param [String] collection_ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item's parent Sync Map expires (time-to-live) and is deleted. This parameter can only be used when the Map Item's `data` or `ttl` is updated in the same request. + # @param [String] if_match If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). + # @return [SyncMapItemInstance] Updated SyncMapItemInstance + def update_with_metadata( + data: :unset, + ttl: :unset, + item_ttl: :unset, + collection_ttl: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'Data' => Twilio.serialize_object(data), + 'Ttl' => ttl, + 'ItemTtl' => item_ttl, + 'CollectionTtl' => collection_ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + syncMapItem_instance = SyncMapItemInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + map_sid: @solution[:map_sid], + key: @solution[:key], + ) + SyncMapItemInstanceMetadata.new( + @version, + syncMapItem_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -295,6 +462,45 @@ def inspect end end + class SyncMapItemInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SyncMapItemInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SyncMapItemInstance] sync_map_item_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SyncMapItemInstanceMetadata] The initialized instance with metadata. + def initialize(version, sync_map_item_instance, headers, status_code) + super(version, headers, status_code) + @sync_map_item_instance = sync_map_item_instance + end + + def sync_map_item + @sync_map_item_instance + end + + def to_s + "" + end + end + + class SyncMapItemListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_map_item_instance = payload.body[key].map do |data| + SyncMapItemInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_map_item_instance + @instance + end + end + class SyncMapItemPage < Page ## # Initialize the SyncMapItemPage @@ -323,6 +529,54 @@ def to_s '' end end + + class SyncMapItemPageMetadata < PageMetadata + attr_reader :sync_map_item_page + + def initialize(version, response, solution, limit) + super(version, response) + @sync_map_item_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sync_map_item_page << SyncMapItemListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sync_map_item_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SyncMapItemListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_map_item = payload.body[key].map do |data| + SyncMapItemInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_map_item + @sync_map_item + end + end + class SyncMapItemInstance < InstanceResource ## # Initialize the SyncMapItemInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb index 308e4f527..8f38faba6 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SyncMapPermissionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SyncMapPermissionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SyncMapPermissionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SyncMapPermissionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + syncMapPermission_instance = SyncMapPermissionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SyncMapPermissionInstanceMetadata.new(@version, syncMapPermission_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the SyncMapPermissionInstanceMetadata + # @return [SyncMapPermissionInstance] Fetched SyncMapPermissionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + syncMapPermission_instance = SyncMapPermissionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + map_sid: @solution[:map_sid], + identity: @solution[:identity], + ) + SyncMapPermissionInstanceMetadata.new( + @version, + syncMapPermission_instance, + response.headers, + response.status_code + ) + end + ## # Update the SyncMapPermissionInstance # @param [Boolean] read Whether the identity can read the Sync Map and its Items. Default value is `false`. @@ -214,6 +282,46 @@ def update( ) end + ## + # Update the SyncMapPermissionInstanceMetadata + # @param [Boolean] read Whether the identity can read the Sync Map and its Items. Default value is `false`. + # @param [Boolean] write Whether the identity can create, update, and delete Items in the Sync Map. Default value is `false`. + # @param [Boolean] manage Whether the identity can delete the Sync Map. Default value is `false`. + # @return [SyncMapPermissionInstance] Updated SyncMapPermissionInstance + def update_with_metadata( + read: nil, + write: nil, + manage: nil + ) + + data = Twilio::Values.of({ + 'Read' => read, + 'Write' => write, + 'Manage' => manage, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + syncMapPermission_instance = SyncMapPermissionInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + map_sid: @solution[:map_sid], + identity: @solution[:identity], + ) + SyncMapPermissionInstanceMetadata.new( + @version, + syncMapPermission_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -230,6 +338,45 @@ def inspect end end + class SyncMapPermissionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SyncMapPermissionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SyncMapPermissionInstance] sync_map_permission_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SyncMapPermissionInstanceMetadata] The initialized instance with metadata. + def initialize(version, sync_map_permission_instance, headers, status_code) + super(version, headers, status_code) + @sync_map_permission_instance = sync_map_permission_instance + end + + def sync_map_permission + @sync_map_permission_instance + end + + def to_s + "" + end + end + + class SyncMapPermissionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_map_permission_instance = payload.body[key].map do |data| + SyncMapPermissionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_map_permission_instance + @instance + end + end + class SyncMapPermissionPage < Page ## # Initialize the SyncMapPermissionPage @@ -258,6 +405,54 @@ def to_s '' end end + + class SyncMapPermissionPageMetadata < PageMetadata + attr_reader :sync_map_permission_page + + def initialize(version, response, solution, limit) + super(version, response) + @sync_map_permission_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sync_map_permission_page << SyncMapPermissionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sync_map_permission_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SyncMapPermissionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_map_permission = payload.body[key].map do |data| + SyncMapPermissionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_map_permission + @sync_map_permission + end + end + class SyncMapPermissionInstance < InstanceResource ## # Initialize the SyncMapPermissionInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb index 9d876c5d6..8569898c4 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the SyncStreamInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The `unique_name` value can be used as an alternative to the `sid` in the URL path to address the resource. + # @param [String] ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Stream expires and is deleted (time-to-live). + # @return [SyncStreamInstance] Created SyncStreamInstance + def create_with_metadata( + unique_name: :unset, + ttl: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'Ttl' => ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + syncStream_instance = SyncStreamInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + SyncStreamInstanceMetadata.new( + @version, + syncStream_instance, + response.headers, + response.status_code + ) + end + ## # Lists SyncStreamInstance records from the API as a list. @@ -100,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SyncStreamPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SyncStreamPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SyncStreamInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SyncStreamInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + syncStream_instance = SyncStreamInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SyncStreamInstanceMetadata.new(@version, syncStream_instance, response.headers, response.status_code) end ## @@ -207,6 +283,32 @@ def fetch ) end + ## + # Fetch the SyncStreamInstanceMetadata + # @return [SyncStreamInstance] Fetched SyncStreamInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + syncStream_instance = SyncStreamInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SyncStreamInstanceMetadata.new( + @version, + syncStream_instance, + response.headers, + response.status_code + ) + end + ## # Update the SyncStreamInstance # @param [String] ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Stream expires and is deleted (time-to-live). @@ -234,6 +336,39 @@ def update( ) end + ## + # Update the SyncStreamInstanceMetadata + # @param [String] ttl How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Stream expires and is deleted (time-to-live). + # @return [SyncStreamInstance] Updated SyncStreamInstance + def update_with_metadata( + ttl: :unset + ) + + data = Twilio::Values.of({ + 'Ttl' => ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + syncStream_instance = SyncStreamInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + SyncStreamInstanceMetadata.new( + @version, + syncStream_instance, + response.headers, + response.status_code + ) + end + ## # Access the stream_messages # @return [StreamMessageList] @@ -261,6 +396,45 @@ def inspect end end + class SyncStreamInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SyncStreamInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SyncStreamInstance] sync_stream_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SyncStreamInstanceMetadata] The initialized instance with metadata. + def initialize(version, sync_stream_instance, headers, status_code) + super(version, headers, status_code) + @sync_stream_instance = sync_stream_instance + end + + def sync_stream + @sync_stream_instance + end + + def to_s + "" + end + end + + class SyncStreamListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_stream_instance = payload.body[key].map do |data| + SyncStreamInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_stream_instance + @instance + end + end + class SyncStreamPage < Page ## # Initialize the SyncStreamPage @@ -289,6 +463,54 @@ def to_s '' end end + + class SyncStreamPageMetadata < PageMetadata + attr_reader :sync_stream_page + + def initialize(version, response, solution, limit) + super(version, response) + @sync_stream_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sync_stream_page << SyncStreamListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sync_stream_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SyncStreamListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sync_stream = payload.body[key].map do |data| + SyncStreamInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sync_stream + @sync_stream + end + end + class SyncStreamInstance < InstanceResource ## # Initialize the SyncStreamInstance diff --git a/lib/twilio-ruby/rest/sync/v1/service/sync_stream/stream_message.rb b/lib/twilio-ruby/rest/sync/v1/service/sync_stream/stream_message.rb index c23a647bf..8cb7afa72 100644 --- a/lib/twilio-ruby/rest/sync/v1/service/sync_stream/stream_message.rb +++ b/lib/twilio-ruby/rest/sync/v1/service/sync_stream/stream_message.rb @@ -60,6 +60,39 @@ def create( ) end + ## + # Create the StreamMessageInstanceMetadata + # @param [Object] data A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message body. Can be up to 4 KiB in length. + # @return [StreamMessageInstance] Created StreamMessageInstance + def create_with_metadata( + data: nil + ) + + data = Twilio::Values.of({ + 'Data' => Twilio.serialize_object(data), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + streamMessage_instance = StreamMessageInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + stream_sid: @solution[:stream_sid], + ) + StreamMessageInstanceMetadata.new( + @version, + streamMessage_instance, + response.headers, + response.status_code + ) + end + @@ -97,6 +130,54 @@ def to_s '' end end + + class StreamMessagePageMetadata < PageMetadata + attr_reader :stream_message_page + + def initialize(version, response, solution, limit) + super(version, response) + @stream_message_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @stream_message_page << StreamMessageListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @stream_message_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class StreamMessageListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @stream_message = payload.body[key].map do |data| + StreamMessageInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def stream_message + @stream_message + end + end + class StreamMessageInstance < InstanceResource ## # Initialize the StreamMessageInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb index 68a430d3e..e92908f46 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb @@ -70,6 +70,52 @@ def create( ) end + ## + # Create the WorkspaceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Workspace resource. It can be up to 64 characters long. For example: `Customer Support` or `2014 Election Campaign`. + # @param [String] event_callback_url The URL we should call when an event occurs. If provided, the Workspace will publish events to this URL, for example, to collect data for reporting. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides). + # @param [String] events_filter The list of Workspace events for which to call event_callback_url. For example, if `EventsFilter=task.created, task.canceled, worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated. + # @param [Boolean] multi_task_enabled Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be created as multi-tasking. The default is `true`. Multi-tasking allows Workers to handle multiple Tasks simultaneously. When enabled (`true`), each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking). + # @param [String] template An available template name. Can be: `NONE` or `FIFO` and the default is `NONE`. Pre-configures the Workspace with the Workflow and Activities specified in the template. `NONE` will create a Workspace with only a set of default activities. `FIFO` will configure TaskRouter with a set of default activities and a single TaskQueue for first-in, first-out distribution, which can be useful when you are getting started with TaskRouter. + # @param [QueueOrder] prioritize_queue_order + # @return [WorkspaceInstance] Created WorkspaceInstance + def create_with_metadata( + friendly_name: nil, + event_callback_url: :unset, + events_filter: :unset, + multi_task_enabled: :unset, + template: :unset, + prioritize_queue_order: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'EventCallbackUrl' => event_callback_url, + 'EventsFilter' => events_filter, + 'MultiTaskEnabled' => multi_task_enabled, + 'Template' => template, + 'PrioritizeQueueOrder' => prioritize_queue_order, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + workspace_instance = WorkspaceInstance.new( + @version, + response.body, + ) + WorkspaceInstanceMetadata.new( + @version, + workspace_instance, + response.headers, + response.status_code + ) + end + ## # Lists WorkspaceInstance records from the API as a list. @@ -113,6 +159,30 @@ def stream(friendly_name: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WorkspacePageMetadata records from the API as a list. + # @param [String] friendly_name The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`. + # @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_with_metadata(friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WorkspacePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WorkspaceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -207,7 +277,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WorkspaceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + workspace_instance = WorkspaceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WorkspaceInstanceMetadata.new(@version, workspace_instance, response.headers, response.status_code) end ## @@ -229,6 +318,31 @@ def fetch ) end + ## + # Fetch the WorkspaceInstanceMetadata + # @return [WorkspaceInstance] Fetched WorkspaceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + workspace_instance = WorkspaceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + WorkspaceInstanceMetadata.new( + @version, + workspace_instance, + response.headers, + response.status_code + ) + end + ## # Update the WorkspaceInstance # @param [String] default_activity_sid The SID of the Activity that will be used when new Workers are created in the Workspace. @@ -273,6 +387,56 @@ def update( ) end + ## + # Update the WorkspaceInstanceMetadata + # @param [String] default_activity_sid The SID of the Activity that will be used when new Workers are created in the Workspace. + # @param [String] event_callback_url The URL we should call when an event occurs. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides). + # @param [String] events_filter The list of Workspace events for which to call event_callback_url. For example if `EventsFilter=task.created,task.canceled,worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated. + # @param [String] friendly_name A descriptive string that you create to describe the Workspace resource. For example: `Sales Call Center` or `Customer Support Team`. + # @param [Boolean] multi_task_enabled Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be maintained as multi-tasking. There is no default when omitting this parameter. A multi-tasking Workspace can't be updated to single-tasking unless it is not a Flex Project and another (legacy) single-tasking Workspace exists. Multi-tasking allows Workers to handle multiple Tasks simultaneously. In multi-tasking mode, each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking). + # @param [String] timeout_activity_sid The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response. + # @param [QueueOrder] prioritize_queue_order + # @return [WorkspaceInstance] Updated WorkspaceInstance + def update_with_metadata( + default_activity_sid: :unset, + event_callback_url: :unset, + events_filter: :unset, + friendly_name: :unset, + multi_task_enabled: :unset, + timeout_activity_sid: :unset, + prioritize_queue_order: :unset + ) + + data = Twilio::Values.of({ + 'DefaultActivitySid' => default_activity_sid, + 'EventCallbackUrl' => event_callback_url, + 'EventsFilter' => events_filter, + 'FriendlyName' => friendly_name, + 'MultiTaskEnabled' => multi_task_enabled, + 'TimeoutActivitySid' => timeout_activity_sid, + 'PrioritizeQueueOrder' => prioritize_queue_order, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + workspace_instance = WorkspaceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + WorkspaceInstanceMetadata.new( + @version, + workspace_instance, + response.headers, + response.status_code + ) + end + ## # Access the cumulative_statistics # @return [WorkspaceCumulativeStatisticsList] @@ -452,6 +616,45 @@ def inspect end end + class WorkspaceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkspaceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkspaceInstance] workspace_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkspaceInstanceMetadata] The initialized instance with metadata. + def initialize(version, workspace_instance, headers, status_code) + super(version, headers, status_code) + @workspace_instance = workspace_instance + end + + def workspace + @workspace_instance + end + + def to_s + "" + end + end + + class WorkspaceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace_instance = payload.body[key].map do |data| + WorkspaceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace_instance + @instance + end + end + class WorkspacePage < Page ## # Initialize the WorkspacePage @@ -480,6 +683,54 @@ def to_s '' end end + + class WorkspacePageMetadata < PageMetadata + attr_reader :workspace_page + + def initialize(version, response, solution, limit) + super(version, response) + @workspace_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workspace_page << WorkspaceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workspace_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkspaceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace = payload.body[key].map do |data| + WorkspaceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace + @workspace + end + end + class WorkspaceInstance < InstanceResource ## # Initialize the WorkspaceInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb index cd828633c..bd01c9757 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the ActivityInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`. + # @param [Boolean] available Whether the Worker should be eligible to receive a Task when it occupies the Activity. A value of `true`, `1`, or `yes` specifies the Activity is available. All other values specify that it is not. The value cannot be changed after the Activity is created. + # @return [ActivityInstance] Created ActivityInstance + def create_with_metadata( + friendly_name: nil, + available: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Available' => available, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + activity_instance = ActivityInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + ActivityInstanceMetadata.new( + @version, + activity_instance, + response.headers, + response.status_code + ) + end + ## # Lists ActivityInstance records from the API as a list. @@ -108,6 +143,32 @@ def stream(friendly_name: :unset, available: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ActivityPageMetadata records from the API as a list. + # @param [String] friendly_name The `friendly_name` of the Activity resources to read. + # @param [String] available Whether return only Activity resources that are available or unavailable. A value of `true` returns only available activities. Values of '1' or `yes` also indicate `true`. All other values represent `false` and return activities that are unavailable. + # @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_with_metadata(friendly_name: :unset, available: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Available' => available, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ActivityPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ActivityInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -195,7 +256,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ActivityInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + activity_instance = ActivityInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ActivityInstanceMetadata.new(@version, activity_instance, response.headers, response.status_code) end ## @@ -218,6 +298,32 @@ def fetch ) end + ## + # Fetch the ActivityInstanceMetadata + # @return [ActivityInstance] Fetched ActivityInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + activity_instance = ActivityInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + ActivityInstanceMetadata.new( + @version, + activity_instance, + response.headers, + response.status_code + ) + end + ## # Update the ActivityInstance # @param [String] friendly_name A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`. @@ -245,6 +351,39 @@ def update( ) end + ## + # Update the ActivityInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`. + # @return [ActivityInstance] Updated ActivityInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + activity_instance = ActivityInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + ActivityInstanceMetadata.new( + @version, + activity_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -261,6 +400,45 @@ def inspect end end + class ActivityInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ActivityInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ActivityInstance] activity_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ActivityInstanceMetadata] The initialized instance with metadata. + def initialize(version, activity_instance, headers, status_code) + super(version, headers, status_code) + @activity_instance = activity_instance + end + + def activity + @activity_instance + end + + def to_s + "" + end + end + + class ActivityListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @activity_instance = payload.body[key].map do |data| + ActivityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def activity_instance + @instance + end + end + class ActivityPage < Page ## # Initialize the ActivityPage @@ -289,6 +467,54 @@ def to_s '' end end + + class ActivityPageMetadata < PageMetadata + attr_reader :activity_page + + def initialize(version, response, solution, limit) + super(version, response) + @activity_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @activity_page << ActivityListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @activity_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ActivityListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @activity = payload.body[key].map do |data| + ActivityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def activity + @activity + end + end + class ActivityInstance < InstanceResource ## # Initialize the ActivityInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb index bc5fc4417..c6904e305 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb @@ -115,6 +115,50 @@ def stream(end_date: :unset, event_type: :unset, minutes: :unset, reservation_si @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EventPageMetadata records from the API as a list. + # @param [Time] end_date Only include Events that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] event_type The type of Events to read. Returns only Events of the type specified. + # @param [String] minutes The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted. + # @param [String] reservation_sid The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation. + # @param [Time] start_date Only include Events from on or after this date and time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Task Attributes for Events older than 30 days will be redacted. + # @param [String] task_queue_sid The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue. + # @param [String] task_sid The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task. + # @param [String] worker_sid The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker. + # @param [String] workflow_sid The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow. + # @param [String] task_channel The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel. + # @param [String] sid The SID of the Event resource to read. + # @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_with_metadata(end_date: :unset, event_type: :unset, minutes: :unset, reservation_sid: :unset, start_date: :unset, task_queue_sid: :unset, task_sid: :unset, worker_sid: :unset, workflow_sid: :unset, task_channel: :unset, sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'EventType' => event_type, + 'Minutes' => minutes, + 'ReservationSid' => reservation_sid, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'TaskQueueSid' => task_queue_sid, + 'TaskSid' => task_sid, + 'WorkerSid' => worker_sid, + 'WorkflowSid' => workflow_sid, + 'TaskChannel' => task_channel, + 'Sid' => sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EventPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EventInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -231,6 +275,32 @@ def fetch ) end + ## + # Fetch the EventInstanceMetadata + # @return [EventInstance] Fetched EventInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + event_instance = EventInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + EventInstanceMetadata.new( + @version, + event_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -247,6 +317,45 @@ def inspect end end + class EventInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EventInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EventInstance] event_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EventInstanceMetadata] The initialized instance with metadata. + def initialize(version, event_instance, headers, status_code) + super(version, headers, status_code) + @event_instance = event_instance + end + + def event + @event_instance + end + + def to_s + "" + end + end + + class EventListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event_instance = payload.body[key].map do |data| + EventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event_instance + @instance + end + end + class EventPage < Page ## # Initialize the EventPage @@ -275,6 +384,54 @@ def to_s '' end end + + class EventPageMetadata < PageMetadata + attr_reader :event_page + + def initialize(version, response, solution, limit) + super(version, response) + @event_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @event_page << EventListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @event_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EventListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @event = payload.body[key].map do |data| + EventInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def event + @event + end + end + class EventInstance < InstanceResource ## # Initialize the EventInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb index 5b556bbf4..cb0c0dbc7 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb @@ -82,6 +82,62 @@ def create( ) end + ## + # Create the TaskInstanceMetadata + # @param [String] timeout The amount of time in seconds the new task can live before being assigned. Can be up to a maximum of 2 weeks (1,209,600 seconds). The default value is 24 hours (86,400 seconds). On timeout, the `task.canceled` event will fire with description `Task TTL Exceeded`. + # @param [String] priority The priority to assign the new task and override the default. When supplied, the new Task will have this priority unless it matches a Workflow Target with a Priority set. When not supplied, the new Task will have the priority of the matching Workflow Target. Value can be 0 to 2^31^ (2,147,483,647). + # @param [String] task_channel When MultiTasking is enabled, specify the TaskChannel by passing either its `unique_name` or `sid`. Default value is `default`. + # @param [String] workflow_sid The SID of the Workflow that you would like to handle routing for the new Task. If there is only one Workflow defined for the Workspace that you are posting the new task to, this parameter is optional. + # @param [String] attributes A JSON string with the attributes of the new task. This value is passed to the Workflow's `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`. + # @param [Time] virtual_start_time The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future or before the year of 1900. + # @param [String] routing_target A SID of a Worker, Queue, or Workflow to route a Task to + # @param [String] ignore_capacity A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the `RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value of `IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID. + # @param [String] task_queue_sid The SID of the TaskQueue in which the Task belongs + # @return [TaskInstance] Created TaskInstance + def create_with_metadata( + timeout: :unset, + priority: :unset, + task_channel: :unset, + workflow_sid: :unset, + attributes: :unset, + virtual_start_time: :unset, + routing_target: :unset, + ignore_capacity: :unset, + task_queue_sid: :unset + ) + + data = Twilio::Values.of({ + 'Timeout' => timeout, + 'Priority' => priority, + 'TaskChannel' => task_channel, + 'WorkflowSid' => workflow_sid, + 'Attributes' => attributes, + 'VirtualStartTime' => Twilio.serialize_iso8601_datetime(virtual_start_time), + 'RoutingTarget' => routing_target, + 'IgnoreCapacity' => ignore_capacity, + 'TaskQueueSid' => task_queue_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + task_instance = TaskInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + TaskInstanceMetadata.new( + @version, + task_instance, + response.headers, + response.status_code + ) + end + ## # Lists TaskInstance records from the API as a list. @@ -161,6 +217,49 @@ def stream(priority: :unset, assignment_status: :unset, workflow_sid: :unset, wo @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TaskPageMetadata records from the API as a list. + # @param [String] priority The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority. + # @param [Array[String]] assignment_status The `assignment_status` of the Tasks you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`, `wrapping`, or `completed`. Returns all Tasks in the Workspace with the specified `assignment_status`. + # @param [String] workflow_sid The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID. + # @param [String] workflow_name The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name. + # @param [String] task_queue_sid The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID. + # @param [String] task_queue_name The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. + # @param [String] evaluate_task_attributes The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. + # @param [String] routing_target A SID of a Worker, Queue, or Workflow to route a Task to + # @param [String] ordering How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. + # @param [Boolean] has_addons Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. + # @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_with_metadata(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, routing_target: :unset, ordering: :unset, has_addons: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Priority' => priority, + + 'AssignmentStatus' => Twilio.serialize_list(assignment_status) { |e| e }, + 'WorkflowSid' => workflow_sid, + 'WorkflowName' => workflow_name, + 'TaskQueueSid' => task_queue_sid, + 'TaskQueueName' => task_queue_name, + 'EvaluateTaskAttributes' => evaluate_task_attributes, + 'RoutingTarget' => routing_target, + 'Ordering' => ordering, + 'HasAddons' => has_addons, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TaskPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TaskInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -269,7 +368,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TaskInstanceMetadata + # @param [String] if_match If provided, deletes this Task if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + if_match: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + task_instance = TaskInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TaskInstanceMetadata.new(@version, task_instance, response.headers, response.status_code) end ## @@ -292,6 +413,32 @@ def fetch ) end + ## + # Fetch the TaskInstanceMetadata + # @return [TaskInstance] Fetched TaskInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + task_instance = TaskInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + TaskInstanceMetadata.new( + @version, + task_instance, + response.headers, + response.status_code + ) + end + ## # Update the TaskInstance # @param [String] attributes The JSON string that describes the custom attributes of the task. @@ -336,6 +483,56 @@ def update( ) end + ## + # Update the TaskInstanceMetadata + # @param [String] attributes The JSON string that describes the custom attributes of the task. + # @param [Status] assignment_status + # @param [String] reason The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason. + # @param [String] priority The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647). + # @param [String] task_channel When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @param [Time] virtual_start_time The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future or before the year of 1900. + # @param [String] if_match If provided, applies this mutation if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). + # @return [TaskInstance] Updated TaskInstance + def update_with_metadata( + attributes: :unset, + assignment_status: :unset, + reason: :unset, + priority: :unset, + task_channel: :unset, + virtual_start_time: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'Attributes' => attributes, + 'AssignmentStatus' => assignment_status, + 'Reason' => reason, + 'Priority' => priority, + 'TaskChannel' => task_channel, + 'VirtualStartTime' => Twilio.serialize_iso8601_datetime(virtual_start_time), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + task_instance = TaskInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + TaskInstanceMetadata.new( + @version, + task_instance, + response.headers, + response.status_code + ) + end + ## # Access the reservations # @return [ReservationList] @@ -371,6 +568,45 @@ def inspect end end + class TaskInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TaskInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TaskInstance] task_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TaskInstanceMetadata] The initialized instance with metadata. + def initialize(version, task_instance, headers, status_code) + super(version, headers, status_code) + @task_instance = task_instance + end + + def task + @task_instance + end + + def to_s + "" + end + end + + class TaskListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_instance = payload.body[key].map do |data| + TaskInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_instance + @instance + end + end + class TaskPage < Page ## # Initialize the TaskPage @@ -399,6 +635,54 @@ def to_s '' end end + + class TaskPageMetadata < PageMetadata + attr_reader :task_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_page << TaskListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task = payload.body[key].map do |data| + TaskInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task + @task + end + end + class TaskInstance < InstanceResource ## # Initialize the TaskInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb index ae98db8de..c38dcd88e 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb @@ -80,6 +80,32 @@ def stream(reservation_status: :unset, worker_sid: :unset, limit: nil, page_size @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ReservationPageMetadata records from the API as a list. + # @param [Status] reservation_status Returns the list of reservations for a task with a specified ReservationStatus. Can be: `pending`, `accepted`, `rejected`, or `timeout`. + # @param [String] worker_sid The SID of the reserved Worker resource to read. + # @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_with_metadata(reservation_status: :unset, worker_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ReservationStatus' => reservation_status, + 'WorkerSid' => worker_sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ReservationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ReservationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,6 +206,33 @@ def fetch ) end + ## + # Fetch the ReservationInstanceMetadata + # @return [ReservationInstance] Fetched ReservationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + reservation_instance = ReservationInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + task_sid: @solution[:task_sid], + sid: @solution[:sid], + ) + ReservationInstanceMetadata.new( + @version, + reservation_instance, + response.headers, + response.status_code + ) + end + ## # Update the ReservationInstance # @param [Status] reservation_status @@ -369,6 +422,201 @@ def update( ) end + ## + # Update the ReservationInstanceMetadata + # @param [Status] reservation_status + # @param [String] worker_activity_sid The new worker activity SID if rejecting a reservation. + # @param [String] instruction The assignment instruction for reservation. + # @param [String] dequeue_post_work_activity_sid The SID of the Activity resource to start after executing a Dequeue instruction. + # @param [String] dequeue_from The Caller ID of the call to the worker when executing a Dequeue instruction. + # @param [String] dequeue_record Whether to record both legs of a call when executing a Dequeue instruction or which leg to record. + # @param [String] dequeue_timeout Timeout for call when executing a Dequeue instruction. + # @param [String] dequeue_to The Contact URI of the worker when executing a Dequeue instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination. + # @param [String] dequeue_status_callback_url The Callback URL for completed call event when executing a Dequeue instruction. + # @param [String] call_from The Caller ID of the outbound call when executing a Call instruction. + # @param [String] call_record Whether to record both legs of a call when executing a Call instruction or which leg to record. + # @param [String] call_timeout Timeout for call when executing a Call instruction. + # @param [String] call_to The Contact URI of the worker when executing a Call instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination. + # @param [String] call_url TwiML URI executed on answering the worker's leg as a result of the Call instruction. + # @param [String] call_status_callback_url The URL to call for the completed call event when executing a Call instruction. + # @param [Boolean] call_accept Whether to accept a reservation when executing a Call instruction. + # @param [String] redirect_call_sid The Call SID of the call parked in the queue when executing a Redirect instruction. + # @param [Boolean] redirect_accept Whether the reservation should be accepted when executing a Redirect instruction. + # @param [String] redirect_url TwiML URI to redirect the call to when executing the Redirect instruction. + # @param [String] to The Contact URI of the worker when executing a Conference instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination. + # @param [String] from The Caller ID of the call to the worker when executing a Conference instruction. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`. + # @param [Array[CallStatus]] status_callback_event The call progress events that we will send to `status_callback`. Can be: `initiated`, `ringing`, `answered`, or `completed`. + # @param [String] timeout Timeout for call when executing a Conference instruction. + # @param [Boolean] record Whether to record the participant and their conferences, including the time between conferences. The default is `false`. + # @param [Boolean] muted Whether the agent is muted in the conference. The default is `false`. + # @param [String] beep Whether to play a notification beep when the participant joins or when to play a beep. Can be: `true`, `false`, `onEnter`, or `onExit`. The default value is `true`. + # @param [Boolean] start_conference_on_enter Whether to start the conference when the participant joins, if it has not already started. The default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference. + # @param [Boolean] end_conference_on_exit Whether to end the conference when the agent leaves. + # @param [String] wait_url The URL we should call using the `wait_method` for the music to play while participants are waiting for the conference to start. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + # @param [String] wait_method The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. + # @param [Boolean] early_media Whether to allow an agent to hear the state of the outbound call, including ringing or disconnect messages. The default is `true`. + # @param [String] max_participants The maximum number of participants in the conference. Can be a positive integer from `2` to `250`. The default value is `250`. + # @param [String] conference_status_callback The URL we should call using the `conference_status_callback_method` when the conference events in `conference_status_callback_event` occur. Only the value set by the first participant to join the conference is used. Subsequent `conference_status_callback` values are ignored. + # @param [String] conference_status_callback_method The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [Array[ConferenceEvent]] conference_status_callback_event The conference status events that we will send to `conference_status_callback`. Can be: `start`, `end`, `join`, `leave`, `mute`, `hold`, `speaker`. + # @param [String] conference_record Whether to record the conference the participant is joining or when to record the conference. Can be: `true`, `false`, `record-from-start`, and `do-not-record`. The default value is `false`. + # @param [String] conference_trim How to trim the leading and trailing silence from your recorded conference audio files. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. + # @param [String] recording_channels The recording channels for the final recording. Can be: `mono` or `dual` and the default is `mono`. + # @param [String] recording_status_callback The URL that we should call using the `recording_status_callback_method` when the recording status changes. + # @param [String] recording_status_callback_method The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] conference_recording_status_callback The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. + # @param [String] conference_recording_status_callback_method The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] region The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + # @param [String] sip_auth_username The SIP username used for authentication. + # @param [String] sip_auth_password The SIP password for authentication. + # @param [Array[String]] dequeue_status_callback_event The Call progress events sent via webhooks as a result of a Dequeue instruction. + # @param [String] post_work_activity_sid The new worker activity SID after executing a Conference instruction. + # @param [SupervisorMode] supervisor_mode + # @param [String] supervisor The Supervisor SID/URI when executing the Supervise instruction. + # @param [Boolean] end_conference_on_customer_exit Whether to end the conference when the customer leaves. + # @param [Boolean] beep_on_customer_entrance Whether to play a notification beep when the customer joins. + # @param [String] jitter_buffer_size The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. + # @param [String] if_match The If-Match HTTP request header + # @return [ReservationInstance] Updated ReservationInstance + def update_with_metadata( + reservation_status: :unset, + worker_activity_sid: :unset, + instruction: :unset, + dequeue_post_work_activity_sid: :unset, + dequeue_from: :unset, + dequeue_record: :unset, + dequeue_timeout: :unset, + dequeue_to: :unset, + dequeue_status_callback_url: :unset, + call_from: :unset, + call_record: :unset, + call_timeout: :unset, + call_to: :unset, + call_url: :unset, + call_status_callback_url: :unset, + call_accept: :unset, + redirect_call_sid: :unset, + redirect_accept: :unset, + redirect_url: :unset, + to: :unset, + from: :unset, + status_callback: :unset, + status_callback_method: :unset, + status_callback_event: :unset, + timeout: :unset, + record: :unset, + muted: :unset, + beep: :unset, + start_conference_on_enter: :unset, + end_conference_on_exit: :unset, + wait_url: :unset, + wait_method: :unset, + early_media: :unset, + max_participants: :unset, + conference_status_callback: :unset, + conference_status_callback_method: :unset, + conference_status_callback_event: :unset, + conference_record: :unset, + conference_trim: :unset, + recording_channels: :unset, + recording_status_callback: :unset, + recording_status_callback_method: :unset, + conference_recording_status_callback: :unset, + conference_recording_status_callback_method: :unset, + region: :unset, + sip_auth_username: :unset, + sip_auth_password: :unset, + dequeue_status_callback_event: :unset, + post_work_activity_sid: :unset, + supervisor_mode: :unset, + supervisor: :unset, + end_conference_on_customer_exit: :unset, + beep_on_customer_entrance: :unset, + jitter_buffer_size: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'ReservationStatus' => reservation_status, + 'WorkerActivitySid' => worker_activity_sid, + 'Instruction' => instruction, + 'DequeuePostWorkActivitySid' => dequeue_post_work_activity_sid, + 'DequeueFrom' => dequeue_from, + 'DequeueRecord' => dequeue_record, + 'DequeueTimeout' => dequeue_timeout, + 'DequeueTo' => dequeue_to, + 'DequeueStatusCallbackUrl' => dequeue_status_callback_url, + 'CallFrom' => call_from, + 'CallRecord' => call_record, + 'CallTimeout' => call_timeout, + 'CallTo' => call_to, + 'CallUrl' => call_url, + 'CallStatusCallbackUrl' => call_status_callback_url, + 'CallAccept' => call_accept, + 'RedirectCallSid' => redirect_call_sid, + 'RedirectAccept' => redirect_accept, + 'RedirectUrl' => redirect_url, + 'To' => to, + 'From' => from, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'StatusCallbackEvent' => Twilio.serialize_list(status_callback_event) { |e| e }, + 'Timeout' => timeout, + 'Record' => record, + 'Muted' => muted, + 'Beep' => beep, + 'StartConferenceOnEnter' => start_conference_on_enter, + 'EndConferenceOnExit' => end_conference_on_exit, + 'WaitUrl' => wait_url, + 'WaitMethod' => wait_method, + 'EarlyMedia' => early_media, + 'MaxParticipants' => max_participants, + 'ConferenceStatusCallback' => conference_status_callback, + 'ConferenceStatusCallbackMethod' => conference_status_callback_method, + 'ConferenceStatusCallbackEvent' => Twilio.serialize_list(conference_status_callback_event) { |e| e }, + 'ConferenceRecord' => conference_record, + 'ConferenceTrim' => conference_trim, + 'RecordingChannels' => recording_channels, + 'RecordingStatusCallback' => recording_status_callback, + 'RecordingStatusCallbackMethod' => recording_status_callback_method, + 'ConferenceRecordingStatusCallback' => conference_recording_status_callback, + 'ConferenceRecordingStatusCallbackMethod' => conference_recording_status_callback_method, + 'Region' => region, + 'SipAuthUsername' => sip_auth_username, + 'SipAuthPassword' => sip_auth_password, + 'DequeueStatusCallbackEvent' => Twilio.serialize_list(dequeue_status_callback_event) { |e| e }, + 'PostWorkActivitySid' => post_work_activity_sid, + 'SupervisorMode' => supervisor_mode, + 'Supervisor' => supervisor, + 'EndConferenceOnCustomerExit' => end_conference_on_customer_exit, + 'BeepOnCustomerEntrance' => beep_on_customer_entrance, + 'JitterBufferSize' => jitter_buffer_size, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + reservation_instance = ReservationInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + task_sid: @solution[:task_sid], + sid: @solution[:sid], + ) + ReservationInstanceMetadata.new( + @version, + reservation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -385,6 +633,45 @@ def inspect end end + class ReservationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ReservationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ReservationInstance] reservation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ReservationInstanceMetadata] The initialized instance with metadata. + def initialize(version, reservation_instance, headers, status_code) + super(version, headers, status_code) + @reservation_instance = reservation_instance + end + + def reservation + @reservation_instance + end + + def to_s + "" + end + end + + class ReservationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @reservation_instance = payload.body[key].map do |data| + ReservationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def reservation_instance + @instance + end + end + class ReservationPage < Page ## # Initialize the ReservationPage @@ -413,6 +700,54 @@ def to_s '' end end + + class ReservationPageMetadata < PageMetadata + attr_reader :reservation_page + + def initialize(version, response, solution, limit) + super(version, response) + @reservation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @reservation_page << ReservationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @reservation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ReservationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @reservation = payload.body[key].map do |data| + ReservationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def reservation + @reservation + end + end + class ReservationInstance < InstanceResource ## # Initialize the ReservationInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb index 5086809c6..91831d9c9 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb @@ -64,6 +64,44 @@ def create( ) end + ## + # Create the TaskChannelInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long. + # @param [String] unique_name An application-defined string that uniquely identifies the Task Channel, such as `voice` or `sms`. + # @param [Boolean] channel_optimized_routing Whether the Task Channel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized. + # @return [TaskChannelInstance] Created TaskChannelInstance + def create_with_metadata( + friendly_name: nil, + unique_name: nil, + channel_optimized_routing: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'UniqueName' => unique_name, + 'ChannelOptimizedRouting' => channel_optimized_routing, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + taskChannel_instance = TaskChannelInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + TaskChannelInstanceMetadata.new( + @version, + taskChannel_instance, + response.headers, + response.status_code + ) + end + ## # Lists TaskChannelInstance records from the API as a list. @@ -103,6 +141,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TaskChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TaskChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TaskChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +246,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TaskChannelInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + taskChannel_instance = TaskChannelInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TaskChannelInstanceMetadata.new(@version, taskChannel_instance, response.headers, response.status_code) end ## @@ -209,6 +288,32 @@ def fetch ) end + ## + # Fetch the TaskChannelInstanceMetadata + # @return [TaskChannelInstance] Fetched TaskChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + taskChannel_instance = TaskChannelInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + TaskChannelInstanceMetadata.new( + @version, + taskChannel_instance, + response.headers, + response.status_code + ) + end + ## # Update the TaskChannelInstance # @param [String] friendly_name A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long. @@ -239,6 +344,42 @@ def update( ) end + ## + # Update the TaskChannelInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long. + # @param [Boolean] channel_optimized_routing Whether the TaskChannel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized. + # @return [TaskChannelInstance] Updated TaskChannelInstance + def update_with_metadata( + friendly_name: :unset, + channel_optimized_routing: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'ChannelOptimizedRouting' => channel_optimized_routing, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + taskChannel_instance = TaskChannelInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + TaskChannelInstanceMetadata.new( + @version, + taskChannel_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -255,6 +396,45 @@ def inspect end end + class TaskChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TaskChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TaskChannelInstance] task_channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TaskChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, task_channel_instance, headers, status_code) + super(version, headers, status_code) + @task_channel_instance = task_channel_instance + end + + def task_channel + @task_channel_instance + end + + def to_s + "" + end + end + + class TaskChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_channel_instance = payload.body[key].map do |data| + TaskChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_channel_instance + @instance + end + end + class TaskChannelPage < Page ## # Initialize the TaskChannelPage @@ -283,6 +463,54 @@ def to_s '' end end + + class TaskChannelPageMetadata < PageMetadata + attr_reader :task_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_channel_page << TaskChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_channel = payload.body[key].map do |data| + TaskChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_channel + @task_channel + end + end + class TaskChannelInstance < InstanceResource ## # Initialize the TaskChannelInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb index 91def387b..889ae1693 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb @@ -75,6 +75,53 @@ def create( ) end + ## + # Create the TaskQueueInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`. + # @param [String] target_workers A string that describes the Worker selection criteria for any Tasks that enter the TaskQueue. For example, `'\\\"language\\\" == \\\"spanish\\\"'`. The default value is `1==1`. If this value is empty, Tasks will wait in the TaskQueue until they are deleted or moved to another TaskQueue. For more information about Worker selection, see [Describing Worker selection criteria](https://www.twilio.com/docs/taskrouter/api/taskqueues#target-workers). + # @param [String] max_reserved_workers The maximum number of Workers to reserve for the assignment of a Task in the queue. Can be an integer between 1 and 50, inclusive and defaults to 1. + # @param [TaskOrder] task_order + # @param [String] reservation_activity_sid The SID of the Activity to assign Workers when a task is reserved for them. + # @param [String] assignment_activity_sid The SID of the Activity to assign Workers when a task is assigned to them. + # @return [TaskQueueInstance] Created TaskQueueInstance + def create_with_metadata( + friendly_name: nil, + target_workers: :unset, + max_reserved_workers: :unset, + task_order: :unset, + reservation_activity_sid: :unset, + assignment_activity_sid: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'TargetWorkers' => target_workers, + 'MaxReservedWorkers' => max_reserved_workers, + 'TaskOrder' => task_order, + 'ReservationActivitySid' => reservation_activity_sid, + 'AssignmentActivitySid' => assignment_activity_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + taskQueue_instance = TaskQueueInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + TaskQueueInstanceMetadata.new( + @version, + taskQueue_instance, + response.headers, + response.status_code + ) + end + ## # Lists TaskQueueInstance records from the API as a list. @@ -130,6 +177,36 @@ def stream(friendly_name: :unset, evaluate_worker_attributes: :unset, worker_sid @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TaskQueuePageMetadata records from the API as a list. + # @param [String] friendly_name The `friendly_name` of the TaskQueue resources to read. + # @param [String] evaluate_worker_attributes The attributes of the Workers to read. Returns the TaskQueues with Workers that match the attributes specified in this parameter. + # @param [String] worker_sid The SID of the Worker with the TaskQueue resources to read. + # @param [String] ordering Sorting parameter for TaskQueues + # @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_with_metadata(friendly_name: :unset, evaluate_worker_attributes: :unset, worker_sid: :unset, ordering: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'EvaluateWorkerAttributes' => evaluate_worker_attributes, + 'WorkerSid' => worker_sid, + 'Ordering' => ordering, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TaskQueuePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TaskQueueInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -238,7 +315,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TaskQueueInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + taskQueue_instance = TaskQueueInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TaskQueueInstanceMetadata.new(@version, taskQueue_instance, response.headers, response.status_code) end ## @@ -261,6 +357,32 @@ def fetch ) end + ## + # Fetch the TaskQueueInstanceMetadata + # @return [TaskQueueInstance] Fetched TaskQueueInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + taskQueue_instance = TaskQueueInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + TaskQueueInstanceMetadata.new( + @version, + taskQueue_instance, + response.headers, + response.status_code + ) + end + ## # Update the TaskQueueInstance # @param [String] friendly_name A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`. @@ -303,6 +425,54 @@ def update( ) end + ## + # Update the TaskQueueInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`. + # @param [String] target_workers A string describing the Worker selection criteria for any Tasks that enter the TaskQueue. For example '\\\"language\\\" == \\\"spanish\\\"' If no TargetWorkers parameter is provided, Tasks will wait in the queue until they are either deleted or moved to another queue. Additional examples on how to describing Worker selection criteria below. + # @param [String] reservation_activity_sid The SID of the Activity to assign Workers when a task is reserved for them. + # @param [String] assignment_activity_sid The SID of the Activity to assign Workers when a task is assigned for them. + # @param [String] max_reserved_workers The maximum number of Workers to create reservations for the assignment of a task while in the queue. Maximum of 50. + # @param [TaskOrder] task_order + # @return [TaskQueueInstance] Updated TaskQueueInstance + def update_with_metadata( + friendly_name: :unset, + target_workers: :unset, + reservation_activity_sid: :unset, + assignment_activity_sid: :unset, + max_reserved_workers: :unset, + task_order: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'TargetWorkers' => target_workers, + 'ReservationActivitySid' => reservation_activity_sid, + 'AssignmentActivitySid' => assignment_activity_sid, + 'MaxReservedWorkers' => max_reserved_workers, + 'TaskOrder' => task_order, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + taskQueue_instance = TaskQueueInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + TaskQueueInstanceMetadata.new( + @version, + taskQueue_instance, + response.headers, + response.status_code + ) + end + ## # Access the cumulative_statistics # @return [TaskQueueCumulativeStatisticsList] @@ -352,6 +522,45 @@ def inspect end end + class TaskQueueInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TaskQueueInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TaskQueueInstance] task_queue_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TaskQueueInstanceMetadata] The initialized instance with metadata. + def initialize(version, task_queue_instance, headers, status_code) + super(version, headers, status_code) + @task_queue_instance = task_queue_instance + end + + def task_queue + @task_queue_instance + end + + def to_s + "" + end + end + + class TaskQueueListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_instance = payload.body[key].map do |data| + TaskQueueInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_instance + @instance + end + end + class TaskQueuePage < Page ## # Initialize the TaskQueuePage @@ -380,6 +589,54 @@ def to_s '' end end + + class TaskQueuePageMetadata < PageMetadata + attr_reader :task_queue_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_queue_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_queue_page << TaskQueueListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_queue_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskQueueListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue = payload.body[key].map do |data| + TaskQueueInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue + @task_queue + end + end + class TaskQueueInstance < InstanceResource ## # Initialize the TaskQueueInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.rb index 58c322f35..d3879d035 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.rb @@ -54,6 +54,33 @@ def create(body: :unset ) end + ## + # Create the TaskQueueBulkRealTimeStatisticsInstanceMetadata + # @param [Object] body + # @return [TaskQueueBulkRealTimeStatisticsInstance] Created TaskQueueBulkRealTimeStatisticsInstance + def create_with_metadata(body: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: body.to_json) + taskQueueBulkRealTimeStatistics_instance = TaskQueueBulkRealTimeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + TaskQueueBulkRealTimeStatisticsInstanceMetadata.new( + @version, + taskQueueBulkRealTimeStatistics_instance, + response.headers, + response.status_code + ) + end + @@ -91,6 +118,54 @@ def to_s '' end end + + class TaskQueueBulkRealTimeStatisticsPageMetadata < PageMetadata + attr_reader :task_queue_bulk_real_time_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_queue_bulk_real_time_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_queue_bulk_real_time_statistics_page << TaskQueueBulkRealTimeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_queue_bulk_real_time_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskQueueBulkRealTimeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_bulk_real_time_statistics = payload.body[key].map do |data| + TaskQueueBulkRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_bulk_real_time_statistics + @task_queue_bulk_real_time_statistics + end + end + class TaskQueueBulkRealTimeStatisticsInstance < InstanceResource ## # Initialize the TaskQueueBulkRealTimeStatisticsInstance 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 a6585b804..b41aa56ee 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 @@ -97,6 +97,50 @@ def fetch( ) end + ## + # Fetch the TaskQueueCumulativeStatisticsInstanceMetadata + # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default is 15 minutes. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [String] task_channel Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @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. TaskRouter will calculate statistics on up to 10,000 Tasks/Reservations for any given threshold. + # @return [TaskQueueCumulativeStatisticsInstance] Fetched TaskQueueCumulativeStatisticsInstance + def fetch_with_metadata( + end_date: :unset, + minutes: :unset, + start_date: :unset, + task_channel: :unset, + split_by_wait_time: :unset + ) + + params = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'TaskChannel' => task_channel, + 'SplitByWaitTime' => split_by_wait_time, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + taskQueueCumulativeStatistics_instance = TaskQueueCumulativeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + task_queue_sid: @solution[:task_queue_sid], + ) + TaskQueueCumulativeStatisticsInstanceMetadata.new( + @version, + taskQueueCumulativeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -113,6 +157,45 @@ def inspect end end + class TaskQueueCumulativeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TaskQueueCumulativeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TaskQueueCumulativeStatisticsInstance] task_queue_cumulative_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TaskQueueCumulativeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, task_queue_cumulative_statistics_instance, headers, status_code) + super(version, headers, status_code) + @task_queue_cumulative_statistics_instance = task_queue_cumulative_statistics_instance + end + + def task_queue_cumulative_statistics + @task_queue_cumulative_statistics_instance + end + + def to_s + "" + end + end + + class TaskQueueCumulativeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_cumulative_statistics_instance = payload.body[key].map do |data| + TaskQueueCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_cumulative_statistics_instance + @instance + end + end + class TaskQueueCumulativeStatisticsPage < Page ## # Initialize the TaskQueueCumulativeStatisticsPage @@ -141,6 +224,54 @@ def to_s '' end end + + class TaskQueueCumulativeStatisticsPageMetadata < PageMetadata + attr_reader :task_queue_cumulative_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_queue_cumulative_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_queue_cumulative_statistics_page << TaskQueueCumulativeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_queue_cumulative_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskQueueCumulativeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_cumulative_statistics = payload.body[key].map do |data| + TaskQueueCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_cumulative_statistics + @task_queue_cumulative_statistics + end + end + class TaskQueueCumulativeStatisticsInstance < InstanceResource ## # Initialize the TaskQueueCumulativeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb index f7518bf6a..dff48457a 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb @@ -85,6 +85,38 @@ def fetch( ) end + ## + # Fetch the TaskQueueRealTimeStatisticsInstanceMetadata + # @param [String] task_channel The TaskChannel for which to fetch statistics. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @return [TaskQueueRealTimeStatisticsInstance] Fetched TaskQueueRealTimeStatisticsInstance + def fetch_with_metadata( + task_channel: :unset + ) + + params = Twilio::Values.of({ + 'TaskChannel' => task_channel, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + taskQueueRealTimeStatistics_instance = TaskQueueRealTimeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + task_queue_sid: @solution[:task_queue_sid], + ) + TaskQueueRealTimeStatisticsInstanceMetadata.new( + @version, + taskQueueRealTimeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -101,6 +133,45 @@ def inspect end end + class TaskQueueRealTimeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TaskQueueRealTimeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TaskQueueRealTimeStatisticsInstance] task_queue_real_time_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TaskQueueRealTimeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, task_queue_real_time_statistics_instance, headers, status_code) + super(version, headers, status_code) + @task_queue_real_time_statistics_instance = task_queue_real_time_statistics_instance + end + + def task_queue_real_time_statistics + @task_queue_real_time_statistics_instance + end + + def to_s + "" + end + end + + class TaskQueueRealTimeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_real_time_statistics_instance = payload.body[key].map do |data| + TaskQueueRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_real_time_statistics_instance + @instance + end + end + class TaskQueueRealTimeStatisticsPage < Page ## # Initialize the TaskQueueRealTimeStatisticsPage @@ -129,6 +200,54 @@ def to_s '' end end + + class TaskQueueRealTimeStatisticsPageMetadata < PageMetadata + attr_reader :task_queue_real_time_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_queue_real_time_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_queue_real_time_statistics_page << TaskQueueRealTimeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_queue_real_time_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskQueueRealTimeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_real_time_statistics = payload.body[key].map do |data| + TaskQueueRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_real_time_statistics + @task_queue_real_time_statistics + end + end + class TaskQueueRealTimeStatisticsInstance < InstanceResource ## # Initialize the TaskQueueRealTimeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb index 807e000b7..598a7366b 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb @@ -97,6 +97,50 @@ def fetch( ) end + ## + # Fetch the TaskQueueStatisticsInstanceMetadata + # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default is 15 minutes. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [String] task_channel Only calculate real-time and cumulative statistics for the specified TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @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. + # @return [TaskQueueStatisticsInstance] Fetched TaskQueueStatisticsInstance + def fetch_with_metadata( + end_date: :unset, + minutes: :unset, + start_date: :unset, + task_channel: :unset, + split_by_wait_time: :unset + ) + + params = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'TaskChannel' => task_channel, + 'SplitByWaitTime' => split_by_wait_time, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + taskQueueStatistics_instance = TaskQueueStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + task_queue_sid: @solution[:task_queue_sid], + ) + TaskQueueStatisticsInstanceMetadata.new( + @version, + taskQueueStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -113,6 +157,45 @@ def inspect end end + class TaskQueueStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TaskQueueStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TaskQueueStatisticsInstance] task_queue_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TaskQueueStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, task_queue_statistics_instance, headers, status_code) + super(version, headers, status_code) + @task_queue_statistics_instance = task_queue_statistics_instance + end + + def task_queue_statistics + @task_queue_statistics_instance + end + + def to_s + "" + end + end + + class TaskQueueStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_statistics_instance = payload.body[key].map do |data| + TaskQueueStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_statistics_instance + @instance + end + end + class TaskQueueStatisticsPage < Page ## # Initialize the TaskQueueStatisticsPage @@ -141,6 +224,54 @@ def to_s '' end end + + class TaskQueueStatisticsPageMetadata < PageMetadata + attr_reader :task_queue_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_queue_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_queue_statistics_page << TaskQueueStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_queue_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskQueueStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queue_statistics = payload.body[key].map do |data| + TaskQueueStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queue_statistics + @task_queue_statistics + end + end + class TaskQueueStatisticsInstance < InstanceResource ## # Initialize the TaskQueueStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb index 227fbc065..44819949c 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb @@ -96,6 +96,40 @@ def stream(end_date: :unset, friendly_name: :unset, minutes: :unset, start_date: @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TaskQueuesStatisticsPageMetadata records from the API as a list. + # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] friendly_name The `friendly_name` of the TaskQueue statistics to read. + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default is 15 minutes. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [String] task_channel Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @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. + # @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_with_metadata(end_date: :unset, friendly_name: :unset, minutes: :unset, start_date: :unset, task_channel: :unset, split_by_wait_time: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'FriendlyName' => friendly_name, + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'TaskChannel' => task_channel, + 'SplitByWaitTime' => split_by_wait_time, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TaskQueuesStatisticsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TaskQueuesStatisticsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,6 +227,54 @@ def to_s '' end end + + class TaskQueuesStatisticsPageMetadata < PageMetadata + attr_reader :task_queues_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @task_queues_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @task_queues_statistics_page << TaskQueuesStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @task_queues_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TaskQueuesStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @task_queues_statistics = payload.body[key].map do |data| + TaskQueuesStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def task_queues_statistics + @task_queues_statistics + end + end + class TaskQueuesStatisticsInstance < InstanceResource ## # Initialize the TaskQueuesStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb index d03cba45f..af4c50500 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb @@ -65,6 +65,44 @@ def create( ) end + ## + # Create the WorkerInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the new Worker. It can be up to 64 characters long. + # @param [String] activity_sid The SID of a valid Activity that will describe the new Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information. If not provided, the new Worker's initial state is the `default_activity_sid` configured on the Workspace. + # @param [String] attributes A valid JSON string that describes the new Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}. + # @return [WorkerInstance] Created WorkerInstance + def create_with_metadata( + friendly_name: nil, + activity_sid: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'ActivitySid' => activity_sid, + 'Attributes' => attributes, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + worker_instance = WorkerInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkerInstanceMetadata.new( + @version, + worker_instance, + response.headers, + response.status_code + ) + end + ## # Lists WorkerInstance records from the API as a list. @@ -136,6 +174,44 @@ def stream(activity_name: :unset, activity_sid: :unset, available: :unset, frien @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WorkerPageMetadata records from the API as a list. + # @param [String] activity_name The `activity_name` of the Worker resources to read. + # @param [String] activity_sid The `activity_sid` of the Worker resources to read. + # @param [String] available Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available. + # @param [String] friendly_name The `friendly_name` of the Worker resources to read. + # @param [String] target_workers_expression Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name` + # @param [String] task_queue_name The `friendly_name` of the TaskQueue that the Workers to read are eligible for. + # @param [String] task_queue_sid The SID of the TaskQueue that the Workers to read are eligible for. + # @param [String] ordering Sorting parameter for Workers + # @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_with_metadata(activity_name: :unset, activity_sid: :unset, available: :unset, friendly_name: :unset, target_workers_expression: :unset, task_queue_name: :unset, task_queue_sid: :unset, ordering: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ActivityName' => activity_name, + 'ActivitySid' => activity_sid, + 'Available' => available, + 'FriendlyName' => friendly_name, + 'TargetWorkersExpression' => target_workers_expression, + 'TaskQueueName' => task_queue_name, + 'TaskQueueSid' => task_queue_sid, + 'Ordering' => ordering, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WorkerPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WorkerInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -249,7 +325,29 @@ def delete( - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WorkerInstanceMetadata + # @param [String] if_match The If-Match HTTP request header + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata( + if_match: :unset + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + worker_instance = WorkerInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WorkerInstanceMetadata.new(@version, worker_instance, response.headers, response.status_code) end ## @@ -272,6 +370,32 @@ def fetch ) end + ## + # Fetch the WorkerInstanceMetadata + # @return [WorkerInstance] Fetched WorkerInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + worker_instance = WorkerInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + WorkerInstanceMetadata.new( + @version, + worker_instance, + response.headers, + response.status_code + ) + end + ## # Update the WorkerInstance # @param [String] activity_sid The SID of a valid Activity that will describe the Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information. @@ -310,6 +434,50 @@ def update( ) end + ## + # Update the WorkerInstanceMetadata + # @param [String] activity_sid The SID of a valid Activity that will describe the Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information. + # @param [String] attributes The JSON string that describes the Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}. + # @param [String] friendly_name A descriptive string that you create to describe the Worker. It can be up to 64 characters long. + # @param [Boolean] reject_pending_reservations Whether to reject the Worker's pending reservations. This option is only valid if the Worker's new [Activity](https://www.twilio.com/docs/taskrouter/api/activity) resource has its `availability` property set to `False`. + # @param [String] if_match The If-Match HTTP request header + # @return [WorkerInstance] Updated WorkerInstance + def update_with_metadata( + activity_sid: :unset, + attributes: :unset, + friendly_name: :unset, + reject_pending_reservations: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'ActivitySid' => activity_sid, + 'Attributes' => attributes, + 'FriendlyName' => friendly_name, + 'RejectPendingReservations' => reject_pending_reservations, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + worker_instance = WorkerInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + WorkerInstanceMetadata.new( + @version, + worker_instance, + response.headers, + response.status_code + ) + end + ## # Access the reservations # @return [ReservationList] @@ -397,6 +565,45 @@ def inspect end end + class WorkerInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkerInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkerInstance] worker_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkerInstanceMetadata] The initialized instance with metadata. + def initialize(version, worker_instance, headers, status_code) + super(version, headers, status_code) + @worker_instance = worker_instance + end + + def worker + @worker_instance + end + + def to_s + "" + end + end + + class WorkerListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @worker_instance = payload.body[key].map do |data| + WorkerInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def worker_instance + @instance + end + end + class WorkerPage < Page ## # Initialize the WorkerPage @@ -425,6 +632,54 @@ def to_s '' end end + + class WorkerPageMetadata < PageMetadata + attr_reader :worker_page + + def initialize(version, response, solution, limit) + super(version, response) + @worker_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @worker_page << WorkerListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @worker_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkerListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @worker = payload.body[key].map do |data| + WorkerInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def worker + @worker + end + end + class WorkerInstance < InstanceResource ## # Initialize the WorkerInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb index 728431259..5cffd4ea9 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb @@ -76,6 +76,30 @@ def stream(reservation_status: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ReservationPageMetadata records from the API as a list. + # @param [Status] reservation_status Returns the list of reservations for a worker with a specified ReservationStatus. Can be: `pending`, `accepted`, `rejected`, `timeout`, `canceled`, or `rescinded`. + # @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_with_metadata(reservation_status: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ReservationStatus' => reservation_status, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ReservationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ReservationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -174,6 +198,33 @@ def fetch ) end + ## + # Fetch the ReservationInstanceMetadata + # @return [ReservationInstance] Fetched ReservationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + reservation_instance = ReservationInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + worker_sid: @solution[:worker_sid], + sid: @solution[:sid], + ) + ReservationInstanceMetadata.new( + @version, + reservation_instance, + response.headers, + response.status_code + ) + end + ## # Update the ReservationInstance # @param [Status] reservation_status @@ -357,6 +408,195 @@ def update( ) end + ## + # Update the ReservationInstanceMetadata + # @param [Status] reservation_status + # @param [String] worker_activity_sid The new worker activity SID if rejecting a reservation. + # @param [String] instruction The assignment instruction for the reservation. + # @param [String] dequeue_post_work_activity_sid The SID of the Activity resource to start after executing a Dequeue instruction. + # @param [String] dequeue_from The caller ID of the call to the worker when executing a Dequeue instruction. + # @param [String] dequeue_record Whether to record both legs of a call when executing a Dequeue instruction or which leg to record. + # @param [String] dequeue_timeout The timeout for call when executing a Dequeue instruction. + # @param [String] dequeue_to The contact URI of the worker when executing a Dequeue instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination. + # @param [String] dequeue_status_callback_url The callback URL for completed call event when executing a Dequeue instruction. + # @param [String] call_from The Caller ID of the outbound call when executing a Call instruction. + # @param [String] call_record Whether to record both legs of a call when executing a Call instruction. + # @param [String] call_timeout The timeout for a call when executing a Call instruction. + # @param [String] call_to The contact URI of the worker when executing a Call instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination. + # @param [String] call_url TwiML URI executed on answering the worker's leg as a result of the Call instruction. + # @param [String] call_status_callback_url The URL to call for the completed call event when executing a Call instruction. + # @param [Boolean] call_accept Whether to accept a reservation when executing a Call instruction. + # @param [String] redirect_call_sid The Call SID of the call parked in the queue when executing a Redirect instruction. + # @param [Boolean] redirect_accept Whether the reservation should be accepted when executing a Redirect instruction. + # @param [String] redirect_url TwiML URI to redirect the call to when executing the Redirect instruction. + # @param [String] to The Contact URI of the worker when executing a Conference instruction. Can be the URI of the Twilio Client, the SIP URI for Programmable SIP, or the [E.164](https://www.twilio.com/docs/glossary/what-e164) formatted phone number, depending on the destination. + # @param [String] from The caller ID of the call to the worker when executing a Conference instruction. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`. + # @param [Array[CallStatus]] status_callback_event The call progress events that we will send to `status_callback`. Can be: `initiated`, `ringing`, `answered`, or `completed`. + # @param [String] timeout The timeout for a call when executing a Conference instruction. + # @param [Boolean] record Whether to record the participant and their conferences, including the time between conferences. Can be `true` or `false` and the default is `false`. + # @param [Boolean] muted Whether the agent is muted in the conference. Defaults to `false`. + # @param [String] beep Whether to play a notification beep when the participant joins or when to play a beep. Can be: `true`, `false`, `onEnter`, or `onExit`. The default value is `true`. + # @param [Boolean] start_conference_on_enter Whether to start the conference when the participant joins, if it has not already started. Can be: `true` or `false` and the default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference. + # @param [Boolean] end_conference_on_exit Whether to end the conference when the agent leaves. + # @param [String] wait_url The URL we should call using the `wait_method` for the music to play while participants are waiting for the conference to start. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + # @param [String] wait_method The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. + # @param [Boolean] early_media Whether to allow an agent to hear the state of the outbound call, including ringing or disconnect messages. The default is `true`. + # @param [String] max_participants The maximum number of participants allowed in the conference. Can be a positive integer from `2` to `250`. The default value is `250`. + # @param [String] conference_status_callback The URL we should call using the `conference_status_callback_method` when the conference events in `conference_status_callback_event` occur. Only the value set by the first participant to join the conference is used. Subsequent `conference_status_callback` values are ignored. + # @param [String] conference_status_callback_method The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [Array[ConferenceEvent]] conference_status_callback_event The conference status events that we will send to `conference_status_callback`. Can be: `start`, `end`, `join`, `leave`, `mute`, `hold`, `speaker`. + # @param [String] conference_record Whether to record the conference the participant is joining or when to record the conference. Can be: `true`, `false`, `record-from-start`, and `do-not-record`. The default value is `false`. + # @param [String] conference_trim Whether to trim leading and trailing silence from your recorded conference audio files. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. + # @param [String] recording_channels The recording channels for the final recording. Can be: `mono` or `dual` and the default is `mono`. + # @param [String] recording_status_callback The URL that we should call using the `recording_status_callback_method` when the recording status changes. + # @param [String] recording_status_callback_method The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] conference_recording_status_callback The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. + # @param [String] conference_recording_status_callback_method The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. + # @param [String] region The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + # @param [String] sip_auth_username The SIP username used for authentication. + # @param [String] sip_auth_password The SIP password for authentication. + # @param [Array[String]] dequeue_status_callback_event The call progress events sent via webhooks as a result of a Dequeue instruction. + # @param [String] post_work_activity_sid The new worker activity SID after executing a Conference instruction. + # @param [Boolean] end_conference_on_customer_exit Whether to end the conference when the customer leaves. + # @param [Boolean] beep_on_customer_entrance Whether to play a notification beep when the customer joins. + # @param [String] jitter_buffer_size The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. + # @param [String] if_match The If-Match HTTP request header + # @return [ReservationInstance] Updated ReservationInstance + def update_with_metadata( + reservation_status: :unset, + worker_activity_sid: :unset, + instruction: :unset, + dequeue_post_work_activity_sid: :unset, + dequeue_from: :unset, + dequeue_record: :unset, + dequeue_timeout: :unset, + dequeue_to: :unset, + dequeue_status_callback_url: :unset, + call_from: :unset, + call_record: :unset, + call_timeout: :unset, + call_to: :unset, + call_url: :unset, + call_status_callback_url: :unset, + call_accept: :unset, + redirect_call_sid: :unset, + redirect_accept: :unset, + redirect_url: :unset, + to: :unset, + from: :unset, + status_callback: :unset, + status_callback_method: :unset, + status_callback_event: :unset, + timeout: :unset, + record: :unset, + muted: :unset, + beep: :unset, + start_conference_on_enter: :unset, + end_conference_on_exit: :unset, + wait_url: :unset, + wait_method: :unset, + early_media: :unset, + max_participants: :unset, + conference_status_callback: :unset, + conference_status_callback_method: :unset, + conference_status_callback_event: :unset, + conference_record: :unset, + conference_trim: :unset, + recording_channels: :unset, + recording_status_callback: :unset, + recording_status_callback_method: :unset, + conference_recording_status_callback: :unset, + conference_recording_status_callback_method: :unset, + region: :unset, + sip_auth_username: :unset, + sip_auth_password: :unset, + dequeue_status_callback_event: :unset, + post_work_activity_sid: :unset, + end_conference_on_customer_exit: :unset, + beep_on_customer_entrance: :unset, + jitter_buffer_size: :unset, + if_match: :unset + ) + + data = Twilio::Values.of({ + 'ReservationStatus' => reservation_status, + 'WorkerActivitySid' => worker_activity_sid, + 'Instruction' => instruction, + 'DequeuePostWorkActivitySid' => dequeue_post_work_activity_sid, + 'DequeueFrom' => dequeue_from, + 'DequeueRecord' => dequeue_record, + 'DequeueTimeout' => dequeue_timeout, + 'DequeueTo' => dequeue_to, + 'DequeueStatusCallbackUrl' => dequeue_status_callback_url, + 'CallFrom' => call_from, + 'CallRecord' => call_record, + 'CallTimeout' => call_timeout, + 'CallTo' => call_to, + 'CallUrl' => call_url, + 'CallStatusCallbackUrl' => call_status_callback_url, + 'CallAccept' => call_accept, + 'RedirectCallSid' => redirect_call_sid, + 'RedirectAccept' => redirect_accept, + 'RedirectUrl' => redirect_url, + 'To' => to, + 'From' => from, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'StatusCallbackEvent' => Twilio.serialize_list(status_callback_event) { |e| e }, + 'Timeout' => timeout, + 'Record' => record, + 'Muted' => muted, + 'Beep' => beep, + 'StartConferenceOnEnter' => start_conference_on_enter, + 'EndConferenceOnExit' => end_conference_on_exit, + 'WaitUrl' => wait_url, + 'WaitMethod' => wait_method, + 'EarlyMedia' => early_media, + 'MaxParticipants' => max_participants, + 'ConferenceStatusCallback' => conference_status_callback, + 'ConferenceStatusCallbackMethod' => conference_status_callback_method, + 'ConferenceStatusCallbackEvent' => Twilio.serialize_list(conference_status_callback_event) { |e| e }, + 'ConferenceRecord' => conference_record, + 'ConferenceTrim' => conference_trim, + 'RecordingChannels' => recording_channels, + 'RecordingStatusCallback' => recording_status_callback, + 'RecordingStatusCallbackMethod' => recording_status_callback_method, + 'ConferenceRecordingStatusCallback' => conference_recording_status_callback, + 'ConferenceRecordingStatusCallbackMethod' => conference_recording_status_callback_method, + 'Region' => region, + 'SipAuthUsername' => sip_auth_username, + 'SipAuthPassword' => sip_auth_password, + 'DequeueStatusCallbackEvent' => Twilio.serialize_list(dequeue_status_callback_event) { |e| e }, + 'PostWorkActivitySid' => post_work_activity_sid, + 'EndConferenceOnCustomerExit' => end_conference_on_customer_exit, + 'BeepOnCustomerEntrance' => beep_on_customer_entrance, + 'JitterBufferSize' => jitter_buffer_size, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + reservation_instance = ReservationInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + worker_sid: @solution[:worker_sid], + sid: @solution[:sid], + ) + ReservationInstanceMetadata.new( + @version, + reservation_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -373,6 +613,45 @@ def inspect end end + class ReservationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ReservationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ReservationInstance] reservation_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ReservationInstanceMetadata] The initialized instance with metadata. + def initialize(version, reservation_instance, headers, status_code) + super(version, headers, status_code) + @reservation_instance = reservation_instance + end + + def reservation + @reservation_instance + end + + def to_s + "" + end + end + + class ReservationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @reservation_instance = payload.body[key].map do |data| + ReservationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def reservation_instance + @instance + end + end + class ReservationPage < Page ## # Initialize the ReservationPage @@ -401,6 +680,54 @@ def to_s '' end end + + class ReservationPageMetadata < PageMetadata + attr_reader :reservation_page + + def initialize(version, response, solution, limit) + super(version, response) + @reservation_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @reservation_page << ReservationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @reservation_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ReservationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @reservation = payload.body[key].map do |data| + ReservationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def reservation + @reservation + end + end + class ReservationInstance < InstanceResource ## # Initialize the ReservationInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb index 1d8068a25..733f9510c 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WorkerChannelPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WorkerChannelPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WorkerChannelInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +190,33 @@ def fetch ) end + ## + # Fetch the WorkerChannelInstanceMetadata + # @return [WorkerChannelInstance] Fetched WorkerChannelInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + workerChannel_instance = WorkerChannelInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + worker_sid: @solution[:worker_sid], + sid: @solution[:sid], + ) + WorkerChannelInstanceMetadata.new( + @version, + workerChannel_instance, + response.headers, + response.status_code + ) + end + ## # Update the WorkerChannelInstance # @param [String] capacity The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created. @@ -199,6 +248,43 @@ def update( ) end + ## + # Update the WorkerChannelInstanceMetadata + # @param [String] capacity The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created. + # @param [Boolean] available Whether the WorkerChannel is available. Set to `false` to prevent the Worker from receiving any new Tasks of this TaskChannel type. + # @return [WorkerChannelInstance] Updated WorkerChannelInstance + def update_with_metadata( + capacity: :unset, + available: :unset + ) + + data = Twilio::Values.of({ + 'Capacity' => capacity, + 'Available' => available, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + workerChannel_instance = WorkerChannelInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + worker_sid: @solution[:worker_sid], + sid: @solution[:sid], + ) + WorkerChannelInstanceMetadata.new( + @version, + workerChannel_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -215,6 +301,45 @@ def inspect end end + class WorkerChannelInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkerChannelInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkerChannelInstance] worker_channel_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkerChannelInstanceMetadata] The initialized instance with metadata. + def initialize(version, worker_channel_instance, headers, status_code) + super(version, headers, status_code) + @worker_channel_instance = worker_channel_instance + end + + def worker_channel + @worker_channel_instance + end + + def to_s + "" + end + end + + class WorkerChannelListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @worker_channel_instance = payload.body[key].map do |data| + WorkerChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def worker_channel_instance + @instance + end + end + class WorkerChannelPage < Page ## # Initialize the WorkerChannelPage @@ -243,6 +368,54 @@ def to_s '' end end + + class WorkerChannelPageMetadata < PageMetadata + attr_reader :worker_channel_page + + def initialize(version, response, solution, limit) + super(version, response) + @worker_channel_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @worker_channel_page << WorkerChannelListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @worker_channel_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkerChannelListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @worker_channel = payload.body[key].map do |data| + WorkerChannelInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def worker_channel + @worker_channel + end + end + class WorkerChannelInstance < InstanceResource ## # Initialize the WorkerChannelInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb index ca574a233..cf5337335 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb @@ -94,6 +94,47 @@ def fetch( ) end + ## + # Fetch the WorkerStatisticsInstanceMetadata + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [Time] end_date Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] task_channel Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @return [WorkerStatisticsInstance] Fetched WorkerStatisticsInstance + def fetch_with_metadata( + minutes: :unset, + start_date: :unset, + end_date: :unset, + task_channel: :unset + ) + + params = Twilio::Values.of({ + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'TaskChannel' => task_channel, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workerStatistics_instance = WorkerStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + worker_sid: @solution[:worker_sid], + ) + WorkerStatisticsInstanceMetadata.new( + @version, + workerStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -110,6 +151,45 @@ def inspect end end + class WorkerStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkerStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkerStatisticsInstance] worker_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkerStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, worker_statistics_instance, headers, status_code) + super(version, headers, status_code) + @worker_statistics_instance = worker_statistics_instance + end + + def worker_statistics + @worker_statistics_instance + end + + def to_s + "" + end + end + + class WorkerStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @worker_statistics_instance = payload.body[key].map do |data| + WorkerStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def worker_statistics_instance + @instance + end + end + class WorkerStatisticsPage < Page ## # Initialize the WorkerStatisticsPage @@ -138,6 +218,54 @@ def to_s '' end end + + class WorkerStatisticsPageMetadata < PageMetadata + attr_reader :worker_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @worker_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @worker_statistics_page << WorkerStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @worker_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkerStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @worker_statistics = payload.body[key].map do |data| + WorkerStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def worker_statistics + @worker_statistics + end + end + class WorkerStatisticsInstance < InstanceResource ## # Initialize the WorkerStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.rb index 64c606ab9..1375ef6ce 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.rb @@ -92,6 +92,46 @@ def fetch( ) end + ## + # Fetch the WorkersCumulativeStatisticsInstanceMetadata + # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [String] task_channel Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @return [WorkersCumulativeStatisticsInstance] Fetched WorkersCumulativeStatisticsInstance + def fetch_with_metadata( + end_date: :unset, + minutes: :unset, + start_date: :unset, + task_channel: :unset + ) + + params = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'TaskChannel' => task_channel, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workersCumulativeStatistics_instance = WorkersCumulativeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkersCumulativeStatisticsInstanceMetadata.new( + @version, + workersCumulativeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -108,6 +148,45 @@ def inspect end end + class WorkersCumulativeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkersCumulativeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkersCumulativeStatisticsInstance] workers_cumulative_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkersCumulativeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workers_cumulative_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workers_cumulative_statistics_instance = workers_cumulative_statistics_instance + end + + def workers_cumulative_statistics + @workers_cumulative_statistics_instance + end + + def to_s + "" + end + end + + class WorkersCumulativeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workers_cumulative_statistics_instance = payload.body[key].map do |data| + WorkersCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workers_cumulative_statistics_instance + @instance + end + end + class WorkersCumulativeStatisticsPage < Page ## # Initialize the WorkersCumulativeStatisticsPage @@ -136,6 +215,54 @@ def to_s '' end end + + class WorkersCumulativeStatisticsPageMetadata < PageMetadata + attr_reader :workers_cumulative_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workers_cumulative_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workers_cumulative_statistics_page << WorkersCumulativeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workers_cumulative_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkersCumulativeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workers_cumulative_statistics = payload.body[key].map do |data| + WorkersCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workers_cumulative_statistics + @workers_cumulative_statistics + end + end + class WorkersCumulativeStatisticsInstance < InstanceResource ## # Initialize the WorkersCumulativeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb index e5104b1c2..b84ea718c 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb @@ -83,6 +83,37 @@ def fetch( ) end + ## + # Fetch the WorkersRealTimeStatisticsInstanceMetadata + # @param [String] task_channel Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @return [WorkersRealTimeStatisticsInstance] Fetched WorkersRealTimeStatisticsInstance + def fetch_with_metadata( + task_channel: :unset + ) + + params = Twilio::Values.of({ + 'TaskChannel' => task_channel, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workersRealTimeStatistics_instance = WorkersRealTimeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkersRealTimeStatisticsInstanceMetadata.new( + @version, + workersRealTimeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -99,6 +130,45 @@ def inspect end end + class WorkersRealTimeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkersRealTimeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkersRealTimeStatisticsInstance] workers_real_time_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkersRealTimeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workers_real_time_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workers_real_time_statistics_instance = workers_real_time_statistics_instance + end + + def workers_real_time_statistics + @workers_real_time_statistics_instance + end + + def to_s + "" + end + end + + class WorkersRealTimeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workers_real_time_statistics_instance = payload.body[key].map do |data| + WorkersRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workers_real_time_statistics_instance + @instance + end + end + class WorkersRealTimeStatisticsPage < Page ## # Initialize the WorkersRealTimeStatisticsPage @@ -127,6 +197,54 @@ def to_s '' end end + + class WorkersRealTimeStatisticsPageMetadata < PageMetadata + attr_reader :workers_real_time_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workers_real_time_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workers_real_time_statistics_page << WorkersRealTimeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workers_real_time_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkersRealTimeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workers_real_time_statistics = payload.body[key].map do |data| + WorkersRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workers_real_time_statistics + @workers_real_time_statistics + end + end + class WorkersRealTimeStatisticsInstance < InstanceResource ## # Initialize the WorkersRealTimeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb index 3a450bb8b..9dd365efb 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb @@ -101,6 +101,55 @@ def fetch( ) end + ## + # Fetch the WorkersStatisticsInstanceMetadata + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] task_queue_sid The SID of the TaskQueue for which to fetch Worker statistics. + # @param [String] task_queue_name The `friendly_name` of the TaskQueue for which to fetch Worker statistics. + # @param [String] friendly_name Only include Workers with `friendly_name` values that match this parameter. + # @param [String] task_channel Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @return [WorkersStatisticsInstance] Fetched WorkersStatisticsInstance + def fetch_with_metadata( + minutes: :unset, + start_date: :unset, + end_date: :unset, + task_queue_sid: :unset, + task_queue_name: :unset, + friendly_name: :unset, + task_channel: :unset + ) + + params = Twilio::Values.of({ + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'TaskQueueSid' => task_queue_sid, + 'TaskQueueName' => task_queue_name, + 'FriendlyName' => friendly_name, + 'TaskChannel' => task_channel, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workersStatistics_instance = WorkersStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkersStatisticsInstanceMetadata.new( + @version, + workersStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -117,6 +166,45 @@ def inspect end end + class WorkersStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkersStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkersStatisticsInstance] workers_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkersStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workers_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workers_statistics_instance = workers_statistics_instance + end + + def workers_statistics + @workers_statistics_instance + end + + def to_s + "" + end + end + + class WorkersStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workers_statistics_instance = payload.body[key].map do |data| + WorkersStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workers_statistics_instance + @instance + end + end + class WorkersStatisticsPage < Page ## # Initialize the WorkersStatisticsPage @@ -145,6 +233,54 @@ def to_s '' end end + + class WorkersStatisticsPageMetadata < PageMetadata + attr_reader :workers_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workers_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workers_statistics_page << WorkersStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workers_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkersStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workers_statistics = payload.body[key].map do |data| + WorkersStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workers_statistics + @workers_statistics + end + end + class WorkersStatisticsInstance < InstanceResource ## # Initialize the WorkersStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb index 932135822..7609807f0 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb @@ -70,6 +70,50 @@ def create( ) end + ## + # Create the WorkflowInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`. + # @param [String] configuration A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information. + # @param [String] assignment_callback_url The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details. + # @param [String] fallback_assignment_callback_url The URL that we should call when a call to the `assignment_callback_url` fails. + # @param [String] task_reservation_timeout How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`. + # @return [WorkflowInstance] Created WorkflowInstance + def create_with_metadata( + friendly_name: nil, + configuration: nil, + assignment_callback_url: :unset, + fallback_assignment_callback_url: :unset, + task_reservation_timeout: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Configuration' => configuration, + 'AssignmentCallbackUrl' => assignment_callback_url, + 'FallbackAssignmentCallbackUrl' => fallback_assignment_callback_url, + 'TaskReservationTimeout' => task_reservation_timeout, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + workflow_instance = WorkflowInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkflowInstanceMetadata.new( + @version, + workflow_instance, + response.headers, + response.status_code + ) + end + ## # Lists WorkflowInstance records from the API as a list. @@ -113,6 +157,30 @@ def stream(friendly_name: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WorkflowPageMetadata records from the API as a list. + # @param [String] friendly_name The `friendly_name` of the Workflow resources to read. + # @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_with_metadata(friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WorkflowPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WorkflowInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -201,7 +269,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WorkflowInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + workflow_instance = WorkflowInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WorkflowInstanceMetadata.new(@version, workflow_instance, response.headers, response.status_code) end ## @@ -224,6 +311,32 @@ def fetch ) end + ## + # Fetch the WorkflowInstanceMetadata + # @return [WorkflowInstance] Fetched WorkflowInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + workflow_instance = WorkflowInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + WorkflowInstanceMetadata.new( + @version, + workflow_instance, + response.headers, + response.status_code + ) + end + ## # Update the WorkflowInstance # @param [String] friendly_name A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`. @@ -266,6 +379,54 @@ def update( ) end + ## + # Update the WorkflowInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`. + # @param [String] assignment_callback_url The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details. + # @param [String] fallback_assignment_callback_url The URL that we should call when a call to the `assignment_callback_url` fails. + # @param [String] configuration A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information. + # @param [String] task_reservation_timeout How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`. + # @param [String] re_evaluate_tasks Whether or not to re-evaluate Tasks. The default is `false`, which means Tasks in the Workflow will not be processed through the assignment loop again. + # @return [WorkflowInstance] Updated WorkflowInstance + def update_with_metadata( + friendly_name: :unset, + assignment_callback_url: :unset, + fallback_assignment_callback_url: :unset, + configuration: :unset, + task_reservation_timeout: :unset, + re_evaluate_tasks: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'AssignmentCallbackUrl' => assignment_callback_url, + 'FallbackAssignmentCallbackUrl' => fallback_assignment_callback_url, + 'Configuration' => configuration, + 'TaskReservationTimeout' => task_reservation_timeout, + 'ReEvaluateTasks' => re_evaluate_tasks, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + workflow_instance = WorkflowInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + sid: @solution[:sid], + ) + WorkflowInstanceMetadata.new( + @version, + workflow_instance, + response.headers, + response.status_code + ) + end + ## # Access the statistics # @return [WorkflowStatisticsList] @@ -315,6 +476,45 @@ def inspect end end + class WorkflowInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkflowInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkflowInstance] workflow_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkflowInstanceMetadata] The initialized instance with metadata. + def initialize(version, workflow_instance, headers, status_code) + super(version, headers, status_code) + @workflow_instance = workflow_instance + end + + def workflow + @workflow_instance + end + + def to_s + "" + end + end + + class WorkflowListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow_instance = payload.body[key].map do |data| + WorkflowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow_instance + @instance + end + end + class WorkflowPage < Page ## # Initialize the WorkflowPage @@ -343,6 +543,54 @@ def to_s '' end end + + class WorkflowPageMetadata < PageMetadata + attr_reader :workflow_page + + def initialize(version, response, solution, limit) + super(version, response) + @workflow_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workflow_page << WorkflowListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workflow_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkflowListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow = payload.body[key].map do |data| + WorkflowInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow + @workflow + end + end + class WorkflowInstance < InstanceResource ## # Initialize the WorkflowInstance 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 9f090b016..b60aeb7ea 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 @@ -97,6 +97,50 @@ def fetch( ) end + ## + # Fetch the WorkflowCumulativeStatisticsInstanceMetadata + # @param [Time] end_date Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [String] task_channel Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @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. 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. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold. + # @return [WorkflowCumulativeStatisticsInstance] Fetched WorkflowCumulativeStatisticsInstance + def fetch_with_metadata( + end_date: :unset, + minutes: :unset, + start_date: :unset, + task_channel: :unset, + split_by_wait_time: :unset + ) + + params = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'TaskChannel' => task_channel, + 'SplitByWaitTime' => split_by_wait_time, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workflowCumulativeStatistics_instance = WorkflowCumulativeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + workflow_sid: @solution[:workflow_sid], + ) + WorkflowCumulativeStatisticsInstanceMetadata.new( + @version, + workflowCumulativeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -113,6 +157,45 @@ def inspect end end + class WorkflowCumulativeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkflowCumulativeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkflowCumulativeStatisticsInstance] workflow_cumulative_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkflowCumulativeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workflow_cumulative_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workflow_cumulative_statistics_instance = workflow_cumulative_statistics_instance + end + + def workflow_cumulative_statistics + @workflow_cumulative_statistics_instance + end + + def to_s + "" + end + end + + class WorkflowCumulativeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow_cumulative_statistics_instance = payload.body[key].map do |data| + WorkflowCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow_cumulative_statistics_instance + @instance + end + end + class WorkflowCumulativeStatisticsPage < Page ## # Initialize the WorkflowCumulativeStatisticsPage @@ -141,6 +224,54 @@ def to_s '' end end + + class WorkflowCumulativeStatisticsPageMetadata < PageMetadata + attr_reader :workflow_cumulative_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workflow_cumulative_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workflow_cumulative_statistics_page << WorkflowCumulativeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workflow_cumulative_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkflowCumulativeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow_cumulative_statistics = payload.body[key].map do |data| + WorkflowCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow_cumulative_statistics + @workflow_cumulative_statistics + end + end + class WorkflowCumulativeStatisticsInstance < InstanceResource ## # Initialize the WorkflowCumulativeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb index fa0dbddf2..9720c2990 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb @@ -85,6 +85,38 @@ def fetch( ) end + ## + # Fetch the WorkflowRealTimeStatisticsInstanceMetadata + # @param [String] task_channel Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @return [WorkflowRealTimeStatisticsInstance] Fetched WorkflowRealTimeStatisticsInstance + def fetch_with_metadata( + task_channel: :unset + ) + + params = Twilio::Values.of({ + 'TaskChannel' => task_channel, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workflowRealTimeStatistics_instance = WorkflowRealTimeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + workflow_sid: @solution[:workflow_sid], + ) + WorkflowRealTimeStatisticsInstanceMetadata.new( + @version, + workflowRealTimeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -101,6 +133,45 @@ def inspect end end + class WorkflowRealTimeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkflowRealTimeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkflowRealTimeStatisticsInstance] workflow_real_time_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkflowRealTimeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workflow_real_time_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workflow_real_time_statistics_instance = workflow_real_time_statistics_instance + end + + def workflow_real_time_statistics + @workflow_real_time_statistics_instance + end + + def to_s + "" + end + end + + class WorkflowRealTimeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow_real_time_statistics_instance = payload.body[key].map do |data| + WorkflowRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow_real_time_statistics_instance + @instance + end + end + class WorkflowRealTimeStatisticsPage < Page ## # Initialize the WorkflowRealTimeStatisticsPage @@ -129,6 +200,54 @@ def to_s '' end end + + class WorkflowRealTimeStatisticsPageMetadata < PageMetadata + attr_reader :workflow_real_time_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workflow_real_time_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workflow_real_time_statistics_page << WorkflowRealTimeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workflow_real_time_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkflowRealTimeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow_real_time_statistics = payload.body[key].map do |data| + WorkflowRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow_real_time_statistics + @workflow_real_time_statistics + end + end + class WorkflowRealTimeStatisticsInstance < InstanceResource ## # Initialize the WorkflowRealTimeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb index 6e52d3a6e..6a719515e 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb @@ -97,6 +97,50 @@ def fetch( ) end + ## + # Fetch the WorkflowStatisticsInstanceMetadata + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] task_channel Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @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. 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. + # @return [WorkflowStatisticsInstance] Fetched WorkflowStatisticsInstance + def fetch_with_metadata( + minutes: :unset, + start_date: :unset, + end_date: :unset, + task_channel: :unset, + split_by_wait_time: :unset + ) + + params = Twilio::Values.of({ + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'TaskChannel' => task_channel, + 'SplitByWaitTime' => split_by_wait_time, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workflowStatistics_instance = WorkflowStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + workflow_sid: @solution[:workflow_sid], + ) + WorkflowStatisticsInstanceMetadata.new( + @version, + workflowStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -113,6 +157,45 @@ def inspect end end + class WorkflowStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkflowStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkflowStatisticsInstance] workflow_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkflowStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workflow_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workflow_statistics_instance = workflow_statistics_instance + end + + def workflow_statistics + @workflow_statistics_instance + end + + def to_s + "" + end + end + + class WorkflowStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow_statistics_instance = payload.body[key].map do |data| + WorkflowStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow_statistics_instance + @instance + end + end + class WorkflowStatisticsPage < Page ## # Initialize the WorkflowStatisticsPage @@ -141,6 +224,54 @@ def to_s '' end end + + class WorkflowStatisticsPageMetadata < PageMetadata + attr_reader :workflow_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workflow_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workflow_statistics_page << WorkflowStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workflow_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkflowStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workflow_statistics = payload.body[key].map do |data| + WorkflowStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workflow_statistics + @workflow_statistics + end + end + class WorkflowStatisticsInstance < InstanceResource ## # Initialize the WorkflowStatisticsInstance 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 833f7d2ef..c5f9c731f 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 @@ -94,6 +94,49 @@ def fetch( ) end + ## + # Fetch the WorkspaceCumulativeStatisticsInstanceMetadata + # @param [Time] end_date Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [String] task_channel Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @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. 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. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold. + # @return [WorkspaceCumulativeStatisticsInstance] Fetched WorkspaceCumulativeStatisticsInstance + def fetch_with_metadata( + end_date: :unset, + minutes: :unset, + start_date: :unset, + task_channel: :unset, + split_by_wait_time: :unset + ) + + params = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'TaskChannel' => task_channel, + 'SplitByWaitTime' => split_by_wait_time, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workspaceCumulativeStatistics_instance = WorkspaceCumulativeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkspaceCumulativeStatisticsInstanceMetadata.new( + @version, + workspaceCumulativeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -110,6 +153,45 @@ def inspect end end + class WorkspaceCumulativeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkspaceCumulativeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkspaceCumulativeStatisticsInstance] workspace_cumulative_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkspaceCumulativeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workspace_cumulative_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workspace_cumulative_statistics_instance = workspace_cumulative_statistics_instance + end + + def workspace_cumulative_statistics + @workspace_cumulative_statistics_instance + end + + def to_s + "" + end + end + + class WorkspaceCumulativeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace_cumulative_statistics_instance = payload.body[key].map do |data| + WorkspaceCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace_cumulative_statistics_instance + @instance + end + end + class WorkspaceCumulativeStatisticsPage < Page ## # Initialize the WorkspaceCumulativeStatisticsPage @@ -138,6 +220,54 @@ def to_s '' end end + + class WorkspaceCumulativeStatisticsPageMetadata < PageMetadata + attr_reader :workspace_cumulative_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workspace_cumulative_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workspace_cumulative_statistics_page << WorkspaceCumulativeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workspace_cumulative_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkspaceCumulativeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace_cumulative_statistics = payload.body[key].map do |data| + WorkspaceCumulativeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace_cumulative_statistics + @workspace_cumulative_statistics + end + end + class WorkspaceCumulativeStatisticsInstance < InstanceResource ## # Initialize the WorkspaceCumulativeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb index 060ab24d9..74094d8c6 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb @@ -82,6 +82,37 @@ def fetch( ) end + ## + # Fetch the WorkspaceRealTimeStatisticsInstanceMetadata + # @param [String] task_channel Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @return [WorkspaceRealTimeStatisticsInstance] Fetched WorkspaceRealTimeStatisticsInstance + def fetch_with_metadata( + task_channel: :unset + ) + + params = Twilio::Values.of({ + 'TaskChannel' => task_channel, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workspaceRealTimeStatistics_instance = WorkspaceRealTimeStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkspaceRealTimeStatisticsInstanceMetadata.new( + @version, + workspaceRealTimeStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -98,6 +129,45 @@ def inspect end end + class WorkspaceRealTimeStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkspaceRealTimeStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkspaceRealTimeStatisticsInstance] workspace_real_time_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkspaceRealTimeStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workspace_real_time_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workspace_real_time_statistics_instance = workspace_real_time_statistics_instance + end + + def workspace_real_time_statistics + @workspace_real_time_statistics_instance + end + + def to_s + "" + end + end + + class WorkspaceRealTimeStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace_real_time_statistics_instance = payload.body[key].map do |data| + WorkspaceRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace_real_time_statistics_instance + @instance + end + end + class WorkspaceRealTimeStatisticsPage < Page ## # Initialize the WorkspaceRealTimeStatisticsPage @@ -126,6 +196,54 @@ def to_s '' end end + + class WorkspaceRealTimeStatisticsPageMetadata < PageMetadata + attr_reader :workspace_real_time_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workspace_real_time_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workspace_real_time_statistics_page << WorkspaceRealTimeStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workspace_real_time_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkspaceRealTimeStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace_real_time_statistics = payload.body[key].map do |data| + WorkspaceRealTimeStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace_real_time_statistics + @workspace_real_time_statistics + end + end + class WorkspaceRealTimeStatisticsInstance < InstanceResource ## # Initialize the WorkspaceRealTimeStatisticsInstance diff --git a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb index a633fbd52..2a3252f98 100644 --- a/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb +++ b/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb @@ -94,6 +94,49 @@ def fetch( ) end + ## + # Fetch the WorkspaceStatisticsInstanceMetadata + # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. + # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. + # @param [String] task_channel Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. + # @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. 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. + # @return [WorkspaceStatisticsInstance] Fetched WorkspaceStatisticsInstance + def fetch_with_metadata( + minutes: :unset, + start_date: :unset, + end_date: :unset, + task_channel: :unset, + split_by_wait_time: :unset + ) + + params = Twilio::Values.of({ + 'Minutes' => minutes, + 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), + 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), + 'TaskChannel' => task_channel, + 'SplitByWaitTime' => split_by_wait_time, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + workspaceStatistics_instance = WorkspaceStatisticsInstance.new( + @version, + response.body, + workspace_sid: @solution[:workspace_sid], + ) + WorkspaceStatisticsInstanceMetadata.new( + @version, + workspaceStatistics_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -110,6 +153,45 @@ def inspect end end + class WorkspaceStatisticsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WorkspaceStatisticsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WorkspaceStatisticsInstance] workspace_statistics_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WorkspaceStatisticsInstanceMetadata] The initialized instance with metadata. + def initialize(version, workspace_statistics_instance, headers, status_code) + super(version, headers, status_code) + @workspace_statistics_instance = workspace_statistics_instance + end + + def workspace_statistics + @workspace_statistics_instance + end + + def to_s + "" + end + end + + class WorkspaceStatisticsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace_statistics_instance = payload.body[key].map do |data| + WorkspaceStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace_statistics_instance + @instance + end + end + class WorkspaceStatisticsPage < Page ## # Initialize the WorkspaceStatisticsPage @@ -138,6 +220,54 @@ def to_s '' end end + + class WorkspaceStatisticsPageMetadata < PageMetadata + attr_reader :workspace_statistics_page + + def initialize(version, response, solution, limit) + super(version, response) + @workspace_statistics_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @workspace_statistics_page << WorkspaceStatisticsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @workspace_statistics_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WorkspaceStatisticsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @workspace_statistics = payload.body[key].map do |data| + WorkspaceStatisticsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def workspace_statistics + @workspace_statistics + end + end + class WorkspaceStatisticsInstance < InstanceResource ## # Initialize the WorkspaceStatisticsInstance diff --git a/lib/twilio-ruby/rest/trunking/v1/trunk.rb b/lib/twilio-ruby/rest/trunking/v1/trunk.rb index 6bfcec123..c1666c302 100644 --- a/lib/twilio-ruby/rest/trunking/v1/trunk.rb +++ b/lib/twilio-ruby/rest/trunking/v1/trunk.rb @@ -76,6 +76,58 @@ def create( ) end + ## + # Create the TrunkInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] domain_name The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and `-` and must end with `pstn.twilio.com`. See [Termination Settings](https://www.twilio.com/docs/sip-trunking#termination) for more information. + # @param [String] disaster_recovery_url The URL we should call using the `disaster_recovery_method` if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See [Disaster Recovery](https://www.twilio.com/docs/sip-trunking#disaster-recovery) for more information. + # @param [String] disaster_recovery_method The HTTP method we should use to call the `disaster_recovery_url`. Can be: `GET` or `POST`. + # @param [TransferSetting] transfer_mode + # @param [Boolean] secure Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See [Secure Trunking](https://www.twilio.com/docs/sip-trunking#securetrunking) for more information. + # @param [Boolean] cnam_lookup_enabled Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information. + # @param [TransferCallerId] transfer_caller_id + # @return [TrunkInstance] Created TrunkInstance + def create_with_metadata( + friendly_name: :unset, + domain_name: :unset, + disaster_recovery_url: :unset, + disaster_recovery_method: :unset, + transfer_mode: :unset, + secure: :unset, + cnam_lookup_enabled: :unset, + transfer_caller_id: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DomainName' => domain_name, + 'DisasterRecoveryUrl' => disaster_recovery_url, + 'DisasterRecoveryMethod' => disaster_recovery_method, + 'TransferMode' => transfer_mode, + 'Secure' => secure, + 'CnamLookupEnabled' => cnam_lookup_enabled, + 'TransferCallerId' => transfer_caller_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + trunk_instance = TrunkInstance.new( + @version, + response.body, + ) + TrunkInstanceMetadata.new( + @version, + trunk_instance, + response.headers, + response.status_code + ) + end + ## # Lists TrunkInstance records from the API as a list. @@ -115,6 +167,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TrunkPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TrunkPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TrunkInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -202,7 +276,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TrunkInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + trunk_instance = TrunkInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TrunkInstanceMetadata.new(@version, trunk_instance, response.headers, response.status_code) end ## @@ -224,6 +317,31 @@ def fetch ) end + ## + # Fetch the TrunkInstanceMetadata + # @return [TrunkInstance] Fetched TrunkInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + trunk_instance = TrunkInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + TrunkInstanceMetadata.new( + @version, + trunk_instance, + response.headers, + response.status_code + ) + end + ## # Update the TrunkInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. @@ -271,6 +389,59 @@ def update( ) end + ## + # Update the TrunkInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] domain_name The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and `-` and must end with `pstn.twilio.com`. See [Termination Settings](https://www.twilio.com/docs/sip-trunking#termination) for more information. + # @param [String] disaster_recovery_url The URL we should call using the `disaster_recovery_method` if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See [Disaster Recovery](https://www.twilio.com/docs/sip-trunking#disaster-recovery) for more information. + # @param [String] disaster_recovery_method The HTTP method we should use to call the `disaster_recovery_url`. Can be: `GET` or `POST`. + # @param [TransferSetting] transfer_mode + # @param [Boolean] secure Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See [Secure Trunking](https://www.twilio.com/docs/sip-trunking#securetrunking) for more information. + # @param [Boolean] cnam_lookup_enabled Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information. + # @param [TransferCallerId] transfer_caller_id + # @return [TrunkInstance] Updated TrunkInstance + def update_with_metadata( + friendly_name: :unset, + domain_name: :unset, + disaster_recovery_url: :unset, + disaster_recovery_method: :unset, + transfer_mode: :unset, + secure: :unset, + cnam_lookup_enabled: :unset, + transfer_caller_id: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'DomainName' => domain_name, + 'DisasterRecoveryUrl' => disaster_recovery_url, + 'DisasterRecoveryMethod' => disaster_recovery_method, + 'TransferMode' => transfer_mode, + 'Secure' => secure, + 'CnamLookupEnabled' => cnam_lookup_enabled, + 'TransferCallerId' => transfer_caller_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + trunk_instance = TrunkInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + TrunkInstanceMetadata.new( + @version, + trunk_instance, + response.headers, + response.status_code + ) + end + ## # Access the recordings # @return [RecordingList] @@ -373,6 +544,45 @@ def inspect end end + class TrunkInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TrunkInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TrunkInstance] trunk_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TrunkInstanceMetadata] The initialized instance with metadata. + def initialize(version, trunk_instance, headers, status_code) + super(version, headers, status_code) + @trunk_instance = trunk_instance + end + + def trunk + @trunk_instance + end + + def to_s + "" + end + end + + class TrunkListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trunk_instance = payload.body[key].map do |data| + TrunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trunk_instance + @instance + end + end + class TrunkPage < Page ## # Initialize the TrunkPage @@ -401,6 +611,54 @@ def to_s '' end end + + class TrunkPageMetadata < PageMetadata + attr_reader :trunk_page + + def initialize(version, response, solution, limit) + super(version, response) + @trunk_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @trunk_page << TrunkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @trunk_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TrunkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trunk = payload.body[key].map do |data| + TrunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trunk + @trunk + end + end + class TrunkInstance < InstanceResource ## # Initialize the TrunkInstance diff --git a/lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb b/lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb index 3c34a1336..57882fb2e 100644 --- a/lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb +++ b/lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the CredentialListInstanceMetadata + # @param [String] credential_list_sid The SID of the [Credential List](https://www.twilio.com/docs/voice/sip/api/sip-credentiallist-resource) that you want to associate with the trunk. Once associated, we will authenticate access to the trunk against this list. + # @return [CredentialListInstance] Created CredentialListInstance + def create_with_metadata( + credential_list_sid: nil + ) + + data = Twilio::Values.of({ + 'CredentialListSid' => credential_list_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + credentialList_instance = CredentialListInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + ) + CredentialListInstanceMetadata.new( + @version, + credentialList_instance, + response.headers, + response.status_code + ) + end + ## # Lists CredentialListInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CredentialListPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CredentialListPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CredentialListInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CredentialListInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + credentialList_instance = CredentialListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CredentialListInstanceMetadata.new(@version, credentialList_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the CredentialListInstanceMetadata + # @return [CredentialListInstance] Fetched CredentialListInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + credentialList_instance = CredentialListInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + sid: @solution[:sid], + ) + CredentialListInstanceMetadata.new( + @version, + credentialList_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class CredentialListInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CredentialListInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CredentialListInstance] credential_list_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CredentialListInstanceMetadata] The initialized instance with metadata. + def initialize(version, credential_list_instance, headers, status_code) + super(version, headers, status_code) + @credential_list_instance = credential_list_instance + end + + def credential_list + @credential_list_instance + end + + def to_s + "" + end + end + + class CredentialListListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_list_instance = payload.body[key].map do |data| + CredentialListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_list_instance + @instance + end + end + class CredentialListPage < Page ## # Initialize the CredentialListPage @@ -247,6 +385,54 @@ def to_s '' end end + + class CredentialListPageMetadata < PageMetadata + attr_reader :credential_list_page + + def initialize(version, response, solution, limit) + super(version, response) + @credential_list_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @credential_list_page << CredentialListListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @credential_list_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CredentialListListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @credential_list = payload.body[key].map do |data| + CredentialListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def credential_list + @credential_list + end + end + class CredentialListInstance < InstanceResource ## # Initialize the CredentialListInstance diff --git a/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb b/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb index 41094983a..4afae4704 100644 --- a/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb +++ b/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the IpAccessControlListInstanceMetadata + # @param [String] ip_access_control_list_sid The SID of the [IP Access Control List](https://www.twilio.com/docs/voice/sip/api/sip-ipaccesscontrollist-resource) that you want to associate with the trunk. + # @return [IpAccessControlListInstance] Created IpAccessControlListInstance + def create_with_metadata( + ip_access_control_list_sid: nil + ) + + data = Twilio::Values.of({ + 'IpAccessControlListSid' => ip_access_control_list_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ipAccessControlList_instance = IpAccessControlListInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + ) + IpAccessControlListInstanceMetadata.new( + @version, + ipAccessControlList_instance, + response.headers, + response.status_code + ) + end + ## # Lists IpAccessControlListInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists IpAccessControlListPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + IpAccessControlListPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields IpAccessControlListInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the IpAccessControlListInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + ipAccessControlList_instance = IpAccessControlListInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IpAccessControlListInstanceMetadata.new(@version, ipAccessControlList_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the IpAccessControlListInstanceMetadata + # @return [IpAccessControlListInstance] Fetched IpAccessControlListInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ipAccessControlList_instance = IpAccessControlListInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + sid: @solution[:sid], + ) + IpAccessControlListInstanceMetadata.new( + @version, + ipAccessControlList_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class IpAccessControlListInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new IpAccessControlListInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}IpAccessControlListInstance] ip_access_control_list_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [IpAccessControlListInstanceMetadata] The initialized instance with metadata. + def initialize(version, ip_access_control_list_instance, headers, status_code) + super(version, headers, status_code) + @ip_access_control_list_instance = ip_access_control_list_instance + end + + def ip_access_control_list + @ip_access_control_list_instance + end + + def to_s + "" + end + end + + class IpAccessControlListListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_access_control_list_instance = payload.body[key].map do |data| + IpAccessControlListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_access_control_list_instance + @instance + end + end + class IpAccessControlListPage < Page ## # Initialize the IpAccessControlListPage @@ -247,6 +385,54 @@ def to_s '' end end + + class IpAccessControlListPageMetadata < PageMetadata + attr_reader :ip_access_control_list_page + + def initialize(version, response, solution, limit) + super(version, response) + @ip_access_control_list_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @ip_access_control_list_page << IpAccessControlListListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @ip_access_control_list_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class IpAccessControlListListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_access_control_list = payload.body[key].map do |data| + IpAccessControlListInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_access_control_list + @ip_access_control_list + end + end + class IpAccessControlListInstance < InstanceResource ## # Initialize the IpAccessControlListInstance diff --git a/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb b/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb index 40776154a..b6f150dbb 100644 --- a/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb +++ b/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb @@ -70,6 +70,50 @@ def create( ) end + ## + # Create the OriginationUrlInstanceMetadata + # @param [String] weight The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority. + # @param [String] priority The relative importance of the URI. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI. + # @param [Boolean] enabled Whether the URL is enabled. The default is `true`. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] sip_url The SIP address you want Twilio to route your Origination calls to. This must be a `sip:` schema. + # @return [OriginationUrlInstance] Created OriginationUrlInstance + def create_with_metadata( + weight: nil, + priority: nil, + enabled: nil, + friendly_name: nil, + sip_url: nil + ) + + data = Twilio::Values.of({ + 'Weight' => weight, + 'Priority' => priority, + 'Enabled' => enabled, + 'FriendlyName' => friendly_name, + 'SipUrl' => sip_url, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + originationUrl_instance = OriginationUrlInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + ) + OriginationUrlInstanceMetadata.new( + @version, + originationUrl_instance, + response.headers, + response.status_code + ) + end + ## # Lists OriginationUrlInstance records from the API as a list. @@ -109,6 +153,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists OriginationUrlPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + OriginationUrlPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields OriginationUrlInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -192,7 +258,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the OriginationUrlInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + originationUrl_instance = OriginationUrlInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + OriginationUrlInstanceMetadata.new(@version, originationUrl_instance, response.headers, response.status_code) end ## @@ -215,6 +300,32 @@ def fetch ) end + ## + # Fetch the OriginationUrlInstanceMetadata + # @return [OriginationUrlInstance] Fetched OriginationUrlInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + originationUrl_instance = OriginationUrlInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + sid: @solution[:sid], + ) + OriginationUrlInstanceMetadata.new( + @version, + originationUrl_instance, + response.headers, + response.status_code + ) + end + ## # Update the OriginationUrlInstance # @param [String] weight The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority. @@ -254,6 +365,51 @@ def update( ) end + ## + # Update the OriginationUrlInstanceMetadata + # @param [String] weight The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority. + # @param [String] priority The relative importance of the URI. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI. + # @param [Boolean] enabled Whether the URL is enabled. The default is `true`. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 64 characters long. + # @param [String] sip_url The SIP address you want Twilio to route your Origination calls to. This must be a `sip:` schema. `sips` is NOT supported. + # @return [OriginationUrlInstance] Updated OriginationUrlInstance + def update_with_metadata( + weight: :unset, + priority: :unset, + enabled: :unset, + friendly_name: :unset, + sip_url: :unset + ) + + data = Twilio::Values.of({ + 'Weight' => weight, + 'Priority' => priority, + 'Enabled' => enabled, + 'FriendlyName' => friendly_name, + 'SipUrl' => sip_url, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + originationUrl_instance = OriginationUrlInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + sid: @solution[:sid], + ) + OriginationUrlInstanceMetadata.new( + @version, + originationUrl_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -270,6 +426,45 @@ def inspect end end + class OriginationUrlInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new OriginationUrlInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}OriginationUrlInstance] origination_url_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [OriginationUrlInstanceMetadata] The initialized instance with metadata. + def initialize(version, origination_url_instance, headers, status_code) + super(version, headers, status_code) + @origination_url_instance = origination_url_instance + end + + def origination_url + @origination_url_instance + end + + def to_s + "" + end + end + + class OriginationUrlListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @origination_url_instance = payload.body[key].map do |data| + OriginationUrlInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def origination_url_instance + @instance + end + end + class OriginationUrlPage < Page ## # Initialize the OriginationUrlPage @@ -298,6 +493,54 @@ def to_s '' end end + + class OriginationUrlPageMetadata < PageMetadata + attr_reader :origination_url_page + + def initialize(version, response, solution, limit) + super(version, response) + @origination_url_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @origination_url_page << OriginationUrlListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @origination_url_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class OriginationUrlListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @origination_url = payload.body[key].map do |data| + OriginationUrlInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def origination_url + @origination_url + end + end + class OriginationUrlInstance < InstanceResource ## # Initialize the OriginationUrlInstance diff --git a/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb b/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb index 73b0f113f..7b2e161cc 100644 --- a/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb +++ b/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the PhoneNumberInstanceMetadata + # @param [String] phone_number_sid The SID of the [Incoming Phone Number](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource) that you want to associate with the trunk. + # @return [PhoneNumberInstance] Created PhoneNumberInstance + def create_with_metadata( + phone_number_sid: nil + ) + + data = Twilio::Values.of({ + 'PhoneNumberSid' => phone_number_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Lists PhoneNumberInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PhoneNumberPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PhoneNumberPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PhoneNumberInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -180,7 +234,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the PhoneNumberInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + PhoneNumberInstanceMetadata.new(@version, phoneNumber_instance, response.headers, response.status_code) end ## @@ -203,6 +276,32 @@ def fetch ) end + ## + # Fetch the PhoneNumberInstanceMetadata + # @return [PhoneNumberInstance] Fetched PhoneNumberInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + phoneNumber_instance = PhoneNumberInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + sid: @solution[:sid], + ) + PhoneNumberInstanceMetadata.new( + @version, + phoneNumber_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -219,6 +318,45 @@ def inspect end end + class PhoneNumberInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PhoneNumberInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PhoneNumberInstance] phone_number_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PhoneNumberInstanceMetadata] The initialized instance with metadata. + def initialize(version, phone_number_instance, headers, status_code) + super(version, headers, status_code) + @phone_number_instance = phone_number_instance + end + + def phone_number + @phone_number_instance + end + + def to_s + "" + end + end + + class PhoneNumberListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number_instance = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number_instance + @instance + end + end + class PhoneNumberPage < Page ## # Initialize the PhoneNumberPage @@ -247,6 +385,54 @@ def to_s '' end end + + class PhoneNumberPageMetadata < PageMetadata + attr_reader :phone_number_page + + def initialize(version, response, solution, limit) + super(version, response) + @phone_number_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @phone_number_page << PhoneNumberListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @phone_number_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PhoneNumberListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @phone_number = payload.body[key].map do |data| + PhoneNumberInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def phone_number + @phone_number + end + end + class PhoneNumberInstance < InstanceResource ## # Initialize the PhoneNumberInstance diff --git a/lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb b/lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb index 418bc456e..32451e436 100644 --- a/lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb +++ b/lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb @@ -76,6 +76,31 @@ def fetch ) end + ## + # Fetch the RecordingInstanceMetadata + # @return [RecordingInstance] Fetched RecordingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Update the RecordingInstance # @param [RecordingMode] mode @@ -105,6 +130,41 @@ def update( ) end + ## + # Update the RecordingInstanceMetadata + # @param [RecordingMode] mode + # @param [RecordingTrim] trim + # @return [RecordingInstance] Updated RecordingInstance + def update_with_metadata( + mode: :unset, + trim: :unset + ) + + data = Twilio::Values.of({ + 'Mode' => mode, + 'Trim' => trim, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + trunk_sid: @solution[:trunk_sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -121,6 +181,45 @@ def inspect end end + class RecordingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RecordingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RecordingInstance] recording_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RecordingInstanceMetadata] The initialized instance with metadata. + def initialize(version, recording_instance, headers, status_code) + super(version, headers, status_code) + @recording_instance = recording_instance + end + + def recording + @recording_instance + end + + def to_s + "" + end + end + + class RecordingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_instance = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_instance + @instance + end + end + class RecordingPage < Page ## # Initialize the RecordingPage @@ -149,6 +248,54 @@ def to_s '' end end + + class RecordingPageMetadata < PageMetadata + attr_reader :recording_page + + def initialize(version, response, solution, limit) + super(version, response) + @recording_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @recording_page << RecordingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @recording_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording + @recording + end + end + class RecordingInstance < InstanceResource ## # Initialize the RecordingInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/compliance_inquiries.rb b/lib/twilio-ruby/rest/trusthub/v1/compliance_inquiries.rb index a27af3395..27fa8086f 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/compliance_inquiries.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/compliance_inquiries.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the ComplianceInquiriesInstanceMetadata + # @param [String] notification_email The email address that approval status updates will be sent to. If not specified, the email address associated with your primary customer profile will be used. + # @param [String] theme_set_id Theme id for styling the inquiry form. + # @param [String] primary_profile_sid The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. + # @return [ComplianceInquiriesInstance] Created ComplianceInquiriesInstance + def create_with_metadata( + notification_email: :unset, + theme_set_id: :unset, + primary_profile_sid: :unset + ) + + data = Twilio::Values.of({ + 'NotificationEmail' => notification_email, + 'ThemeSetId' => theme_set_id, + 'PrimaryProfileSid' => primary_profile_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + complianceInquiries_instance = ComplianceInquiriesInstance.new( + @version, + response.body, + ) + ComplianceInquiriesInstanceMetadata.new( + @version, + complianceInquiries_instance, + response.headers, + response.status_code + ) + end + @@ -115,6 +152,41 @@ def update( ) end + ## + # Update the ComplianceInquiriesInstanceMetadata + # @param [String] primary_profile_sid The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile. + # @param [String] theme_set_id Theme id for styling the inquiry form. + # @return [ComplianceInquiriesInstance] Updated ComplianceInquiriesInstance + def update_with_metadata( + primary_profile_sid: nil, + theme_set_id: :unset + ) + + data = Twilio::Values.of({ + 'PrimaryProfileSid' => primary_profile_sid, + 'ThemeSetId' => theme_set_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + complianceInquiries_instance = ComplianceInquiriesInstance.new( + @version, + response.body, + customer_id: @solution[:customer_id], + ) + ComplianceInquiriesInstanceMetadata.new( + @version, + complianceInquiries_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -131,6 +203,45 @@ def inspect end end + class ComplianceInquiriesInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ComplianceInquiriesInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ComplianceInquiriesInstance] compliance_inquiries_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ComplianceInquiriesInstanceMetadata] The initialized instance with metadata. + def initialize(version, compliance_inquiries_instance, headers, status_code) + super(version, headers, status_code) + @compliance_inquiries_instance = compliance_inquiries_instance + end + + def compliance_inquiries + @compliance_inquiries_instance + end + + def to_s + "" + end + end + + class ComplianceInquiriesListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @compliance_inquiries_instance = payload.body[key].map do |data| + ComplianceInquiriesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def compliance_inquiries_instance + @instance + end + end + class ComplianceInquiriesPage < Page ## # Initialize the ComplianceInquiriesPage @@ -159,6 +270,54 @@ def to_s '' end end + + class ComplianceInquiriesPageMetadata < PageMetadata + attr_reader :compliance_inquiries_page + + def initialize(version, response, solution, limit) + super(version, response) + @compliance_inquiries_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @compliance_inquiries_page << ComplianceInquiriesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @compliance_inquiries_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ComplianceInquiriesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @compliance_inquiries = payload.body[key].map do |data| + ComplianceInquiriesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def compliance_inquiries + @compliance_inquiries + end + end + class ComplianceInquiriesInstance < InstanceResource ## # Initialize the ComplianceInquiriesInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/compliance_registration_inquiries.rb b/lib/twilio-ruby/rest/trusthub/v1/compliance_registration_inquiries.rb index 8b9c3fe33..9391d79f2 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/compliance_registration_inquiries.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/compliance_registration_inquiries.rb @@ -169,6 +169,151 @@ def create( ) end + ## + # Create the ComplianceRegistrationInquiriesInstanceMetadata + # @param [EndUserType] end_user_type + # @param [PhoneNumberType] phone_number_type + # @param [BusinessIdentityType] business_identity_type + # @param [BusinessRegistrationAuthority] business_registration_authority + # @param [String] business_legal_name he name of the business or organization using the Tollfree number. + # @param [String] notification_email he email address to receive the notification about the verification result. + # @param [Boolean] accepted_notification_receipt The email address to receive the notification about the verification result. + # @param [String] business_registration_number Business registration number of the business + # @param [String] business_website_url The URL of the business website + # @param [String] friendly_name Friendly name for your business information + # @param [String] authorized_representative1_first_name First name of the authorized representative + # @param [String] authorized_representative1_last_name Last name of the authorized representative + # @param [String] authorized_representative1_phone Phone number of the authorized representative + # @param [String] authorized_representative1_email Email address of the authorized representative + # @param [String] authorized_representative1_date_of_birth Birthdate of the authorized representative + # @param [String] address_street Street address of the business + # @param [String] address_street_secondary Street address of the business + # @param [String] address_city City of the business + # @param [String] address_subdivision State or province of the business + # @param [String] address_postal_code Postal code of the business + # @param [String] address_country_code Country code of the business + # @param [String] emergency_address_street Street address of the business + # @param [String] emergency_address_street_secondary Street address of the business + # @param [String] emergency_address_city City of the business + # @param [String] emergency_address_subdivision State or province of the business + # @param [String] emergency_address_postal_code Postal code of the business + # @param [String] emergency_address_country_code Country code of the business + # @param [Boolean] use_address_as_emergency_address Use the business address as the emergency address + # @param [String] file_name The name of the verification document to upload + # @param [String] file The verification document to upload + # @param [String] first_name The first name of the Individual User. + # @param [String] last_name The last name of the Individual User. + # @param [String] date_of_birth The date of birth of the Individual User. + # @param [String] individual_email The email address of the Individual User. + # @param [String] individual_phone The phone number of the Individual User. + # @param [Boolean] is_isv_embed Indicates if the inquiry is being started from an ISV embedded component. + # @param [String] isv_registering_for_self_or_tenant Indicates if the isv registering for self or tenant. + # @param [String] status_callback_url The url we call to inform you of bundle changes. + # @param [String] theme_set_id Theme id for styling the inquiry form. + # @return [ComplianceRegistrationInquiriesInstance] Created ComplianceRegistrationInquiriesInstance + def create_with_metadata( + end_user_type: nil, + phone_number_type: nil, + business_identity_type: :unset, + business_registration_authority: :unset, + business_legal_name: :unset, + notification_email: :unset, + accepted_notification_receipt: :unset, + business_registration_number: :unset, + business_website_url: :unset, + friendly_name: :unset, + authorized_representative1_first_name: :unset, + authorized_representative1_last_name: :unset, + authorized_representative1_phone: :unset, + authorized_representative1_email: :unset, + authorized_representative1_date_of_birth: :unset, + address_street: :unset, + address_street_secondary: :unset, + address_city: :unset, + address_subdivision: :unset, + address_postal_code: :unset, + address_country_code: :unset, + emergency_address_street: :unset, + emergency_address_street_secondary: :unset, + emergency_address_city: :unset, + emergency_address_subdivision: :unset, + emergency_address_postal_code: :unset, + emergency_address_country_code: :unset, + use_address_as_emergency_address: :unset, + file_name: :unset, + file: :unset, + first_name: :unset, + last_name: :unset, + date_of_birth: :unset, + individual_email: :unset, + individual_phone: :unset, + is_isv_embed: :unset, + isv_registering_for_self_or_tenant: :unset, + status_callback_url: :unset, + theme_set_id: :unset + ) + + data = Twilio::Values.of({ + 'EndUserType' => end_user_type, + 'PhoneNumberType' => phone_number_type, + 'BusinessIdentityType' => business_identity_type, + 'BusinessRegistrationAuthority' => business_registration_authority, + 'BusinessLegalName' => business_legal_name, + 'NotificationEmail' => notification_email, + 'AcceptedNotificationReceipt' => accepted_notification_receipt, + 'BusinessRegistrationNumber' => business_registration_number, + 'BusinessWebsiteUrl' => business_website_url, + 'FriendlyName' => friendly_name, + 'AuthorizedRepresentative1FirstName' => authorized_representative1_first_name, + 'AuthorizedRepresentative1LastName' => authorized_representative1_last_name, + 'AuthorizedRepresentative1Phone' => authorized_representative1_phone, + 'AuthorizedRepresentative1Email' => authorized_representative1_email, + 'AuthorizedRepresentative1DateOfBirth' => authorized_representative1_date_of_birth, + 'AddressStreet' => address_street, + 'AddressStreetSecondary' => address_street_secondary, + 'AddressCity' => address_city, + 'AddressSubdivision' => address_subdivision, + 'AddressPostalCode' => address_postal_code, + 'AddressCountryCode' => address_country_code, + 'EmergencyAddressStreet' => emergency_address_street, + 'EmergencyAddressStreetSecondary' => emergency_address_street_secondary, + 'EmergencyAddressCity' => emergency_address_city, + 'EmergencyAddressSubdivision' => emergency_address_subdivision, + 'EmergencyAddressPostalCode' => emergency_address_postal_code, + 'EmergencyAddressCountryCode' => emergency_address_country_code, + 'UseAddressAsEmergencyAddress' => use_address_as_emergency_address, + 'FileName' => file_name, + 'File' => file, + 'FirstName' => first_name, + 'LastName' => last_name, + 'DateOfBirth' => date_of_birth, + 'IndividualEmail' => individual_email, + 'IndividualPhone' => individual_phone, + 'IsIsvEmbed' => is_isv_embed, + 'IsvRegisteringForSelfOrTenant' => isv_registering_for_self_or_tenant, + 'StatusCallbackUrl' => status_callback_url, + 'ThemeSetId' => theme_set_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + complianceRegistrationInquiries_instance = ComplianceRegistrationInquiriesInstance.new( + @version, + response.body, + ) + ComplianceRegistrationInquiriesInstanceMetadata.new( + @version, + complianceRegistrationInquiries_instance, + response.headers, + response.status_code + ) + end + @@ -223,6 +368,41 @@ def update( ) end + ## + # Update the ComplianceRegistrationInquiriesInstanceMetadata + # @param [Boolean] is_isv_embed Indicates if the inquiry is being started from an ISV embedded component. + # @param [String] theme_set_id Theme id for styling the inquiry form. + # @return [ComplianceRegistrationInquiriesInstance] Updated ComplianceRegistrationInquiriesInstance + def update_with_metadata( + is_isv_embed: :unset, + theme_set_id: :unset + ) + + data = Twilio::Values.of({ + 'IsIsvEmbed' => is_isv_embed, + 'ThemeSetId' => theme_set_id, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + complianceRegistrationInquiries_instance = ComplianceRegistrationInquiriesInstance.new( + @version, + response.body, + registration_id: @solution[:registration_id], + ) + ComplianceRegistrationInquiriesInstanceMetadata.new( + @version, + complianceRegistrationInquiries_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -239,6 +419,45 @@ def inspect end end + class ComplianceRegistrationInquiriesInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ComplianceRegistrationInquiriesInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ComplianceRegistrationInquiriesInstance] compliance_registration_inquiries_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ComplianceRegistrationInquiriesInstanceMetadata] The initialized instance with metadata. + def initialize(version, compliance_registration_inquiries_instance, headers, status_code) + super(version, headers, status_code) + @compliance_registration_inquiries_instance = compliance_registration_inquiries_instance + end + + def compliance_registration_inquiries + @compliance_registration_inquiries_instance + end + + def to_s + "" + end + end + + class ComplianceRegistrationInquiriesListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @compliance_registration_inquiries_instance = payload.body[key].map do |data| + ComplianceRegistrationInquiriesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def compliance_registration_inquiries_instance + @instance + end + end + class ComplianceRegistrationInquiriesPage < Page ## # Initialize the ComplianceRegistrationInquiriesPage @@ -267,6 +486,54 @@ def to_s '' end end + + class ComplianceRegistrationInquiriesPageMetadata < PageMetadata + attr_reader :compliance_registration_inquiries_page + + def initialize(version, response, solution, limit) + super(version, response) + @compliance_registration_inquiries_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @compliance_registration_inquiries_page << ComplianceRegistrationInquiriesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @compliance_registration_inquiries_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ComplianceRegistrationInquiriesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @compliance_registration_inquiries = payload.body[key].map do |data| + ComplianceRegistrationInquiriesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def compliance_registration_inquiries + @compliance_registration_inquiries + end + end + class ComplianceRegistrationInquiriesInstance < InstanceResource ## # Initialize the ComplianceRegistrationInquiriesInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/compliance_tollfree_inquiries.rb b/lib/twilio-ruby/rest/trusthub/v1/compliance_tollfree_inquiries.rb index ade76b44c..5f4b6f717 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/compliance_tollfree_inquiries.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/compliance_tollfree_inquiries.rb @@ -160,6 +160,142 @@ def create( ) end + ## + # Create the ComplianceTollfreeInquiriesInstanceMetadata + # @param [String] tollfree_phone_number The Tollfree phone number to be verified + # @param [String] notification_email The email address to receive the notification about the verification result. + # @param [String] customer_profile_sid The Customer Profile Sid associated with the Account. + # @param [String] business_name The name of the business or organization using the Tollfree number. + # @param [String] business_website The website of the business or organization using the Tollfree number. + # @param [Array[String]] use_case_categories The category of the use case for the Tollfree Number. List as many are applicable.. + # @param [String] use_case_summary Use this to further explain how messaging is used by the business or organization. + # @param [String] production_message_sample An example of message content, i.e. a sample message. + # @param [Array[String]] opt_in_image_urls Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL. + # @param [OptInType] opt_in_type + # @param [String] message_volume Estimate monthly volume of messages from the Tollfree Number. + # @param [String] business_street_address The address of the business or organization using the Tollfree number. + # @param [String] business_street_address2 The address of the business or organization using the Tollfree number. + # @param [String] business_city The city of the business or organization using the Tollfree number. + # @param [String] business_state_province_region The state/province/region of the business or organization using the Tollfree number. + # @param [String] business_postal_code The postal code of the business or organization using the Tollfree number. + # @param [String] business_country The country of the business or organization using the Tollfree number. + # @param [String] additional_information Additional information to be provided for verification. + # @param [String] business_contact_first_name The first name of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_last_name The last name of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_email The email address of the contact for the business or organization using the Tollfree number. + # @param [String] business_contact_phone The phone number of the contact for the business or organization using the Tollfree number. + # @param [String] theme_set_id Theme id for styling the inquiry form. + # @param [Boolean] skip_messaging_use_case Skip the messaging use case screen of the inquiry form. + # @param [String] business_registration_number The Business Registration Number of the business or organization. + # @param [String] business_registration_authority The Business Registration Authority of the business or organization. + # @param [String] business_registration_country The Business Registration Country of the business or organization. + # @param [BusinessType] business_type + # @param [String] doing_business_as Trade name, sub entity, or downstream business name of business being submitted for verification. + # @param [String] opt_in_confirmation_message The confirmation message sent to users when they opt in to receive messages. + # @param [String] help_message_sample A sample help message provided to users. + # @param [String] privacy_policy_url The URL to the privacy policy for the business or organization. + # @param [String] terms_and_conditions_url The URL to the terms and conditions for the business or organization. + # @param [Boolean] age_gated_content Indicates if the content is age gated. + # @param [String] external_reference_id A legally recognized business registration number. + # @param [Array[String]] opt_in_keywords List of keywords that users can text in to opt in to receive messages. + # @return [ComplianceTollfreeInquiriesInstance] Created ComplianceTollfreeInquiriesInstance + def create_with_metadata( + tollfree_phone_number: nil, + notification_email: nil, + customer_profile_sid: :unset, + business_name: :unset, + business_website: :unset, + use_case_categories: :unset, + use_case_summary: :unset, + production_message_sample: :unset, + opt_in_image_urls: :unset, + opt_in_type: :unset, + message_volume: :unset, + business_street_address: :unset, + business_street_address2: :unset, + business_city: :unset, + business_state_province_region: :unset, + business_postal_code: :unset, + business_country: :unset, + additional_information: :unset, + business_contact_first_name: :unset, + business_contact_last_name: :unset, + business_contact_email: :unset, + business_contact_phone: :unset, + theme_set_id: :unset, + skip_messaging_use_case: :unset, + business_registration_number: :unset, + business_registration_authority: :unset, + business_registration_country: :unset, + business_type: :unset, + doing_business_as: :unset, + opt_in_confirmation_message: :unset, + help_message_sample: :unset, + privacy_policy_url: :unset, + terms_and_conditions_url: :unset, + age_gated_content: :unset, + external_reference_id: :unset, + opt_in_keywords: :unset + ) + + data = Twilio::Values.of({ + 'TollfreePhoneNumber' => tollfree_phone_number, + 'NotificationEmail' => notification_email, + 'CustomerProfileSid' => customer_profile_sid, + 'BusinessName' => business_name, + 'BusinessWebsite' => business_website, + 'UseCaseCategories' => Twilio.serialize_list(use_case_categories) { |e| e }, + 'UseCaseSummary' => use_case_summary, + 'ProductionMessageSample' => production_message_sample, + 'OptInImageUrls' => Twilio.serialize_list(opt_in_image_urls) { |e| e }, + 'OptInType' => opt_in_type, + 'MessageVolume' => message_volume, + 'BusinessStreetAddress' => business_street_address, + 'BusinessStreetAddress2' => business_street_address2, + 'BusinessCity' => business_city, + 'BusinessStateProvinceRegion' => business_state_province_region, + 'BusinessPostalCode' => business_postal_code, + 'BusinessCountry' => business_country, + 'AdditionalInformation' => additional_information, + 'BusinessContactFirstName' => business_contact_first_name, + 'BusinessContactLastName' => business_contact_last_name, + 'BusinessContactEmail' => business_contact_email, + 'BusinessContactPhone' => business_contact_phone, + 'ThemeSetId' => theme_set_id, + 'SkipMessagingUseCase' => skip_messaging_use_case, + 'BusinessRegistrationNumber' => business_registration_number, + 'BusinessRegistrationAuthority' => business_registration_authority, + 'BusinessRegistrationCountry' => business_registration_country, + 'BusinessType' => business_type, + 'DoingBusinessAs' => doing_business_as, + 'OptInConfirmationMessage' => opt_in_confirmation_message, + 'HelpMessageSample' => help_message_sample, + 'PrivacyPolicyUrl' => privacy_policy_url, + 'TermsAndConditionsUrl' => terms_and_conditions_url, + 'AgeGatedContent' => age_gated_content, + 'ExternalReferenceId' => external_reference_id, + 'OptInKeywords' => Twilio.serialize_list(opt_in_keywords) { |e| e }, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + complianceTollfreeInquiries_instance = ComplianceTollfreeInquiriesInstance.new( + @version, + response.body, + ) + ComplianceTollfreeInquiriesInstanceMetadata.new( + @version, + complianceTollfreeInquiries_instance, + response.headers, + response.status_code + ) + end + @@ -197,6 +333,54 @@ def to_s '' end end + + class ComplianceTollfreeInquiriesPageMetadata < PageMetadata + attr_reader :compliance_tollfree_inquiries_page + + def initialize(version, response, solution, limit) + super(version, response) + @compliance_tollfree_inquiries_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @compliance_tollfree_inquiries_page << ComplianceTollfreeInquiriesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @compliance_tollfree_inquiries_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ComplianceTollfreeInquiriesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @compliance_tollfree_inquiries = payload.body[key].map do |data| + ComplianceTollfreeInquiriesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def compliance_tollfree_inquiries + @compliance_tollfree_inquiries + end + end + class ComplianceTollfreeInquiriesInstance < InstanceResource ## # Initialize the ComplianceTollfreeInquiriesInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles.rb b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles.rb index fe79bcc61..ec7964c06 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the CustomerProfilesInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] email The email address that will receive updates when the Customer-Profile resource changes status. + # @param [String] policy_sid The unique string of a policy that is associated to the Customer-Profile resource. + # @param [String] status_callback The URL we call to inform your application of status changes. + # @return [CustomerProfilesInstance] Created CustomerProfilesInstance + def create_with_metadata( + friendly_name: nil, + email: nil, + policy_sid: nil, + status_callback: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Email' => email, + 'PolicySid' => policy_sid, + 'StatusCallback' => status_callback, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + customerProfiles_instance = CustomerProfilesInstance.new( + @version, + response.body, + ) + CustomerProfilesInstanceMetadata.new( + @version, + customerProfiles_instance, + response.headers, + response.status_code + ) + end + ## # Lists CustomerProfilesInstance records from the API as a list. @@ -115,6 +155,34 @@ def stream(status: :unset, friendly_name: :unset, policy_sid: :unset, limit: nil @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CustomerProfilesPageMetadata records from the API as a list. + # @param [Status] status The verification status of the Customer-Profile resource. + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] policy_sid The unique string of a policy that is associated to the Customer-Profile resource. + # @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_with_metadata(status: :unset, friendly_name: :unset, policy_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'FriendlyName' => friendly_name, + 'PolicySid' => policy_sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CustomerProfilesPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CustomerProfilesInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -206,7 +274,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CustomerProfilesInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + customerProfiles_instance = CustomerProfilesInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CustomerProfilesInstanceMetadata.new(@version, customerProfiles_instance, response.headers, response.status_code) end ## @@ -228,6 +315,31 @@ def fetch ) end + ## + # Fetch the CustomerProfilesInstanceMetadata + # @return [CustomerProfilesInstance] Fetched CustomerProfilesInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + customerProfiles_instance = CustomerProfilesInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CustomerProfilesInstanceMetadata.new( + @version, + customerProfiles_instance, + response.headers, + response.status_code + ) + end + ## # Update the CustomerProfilesInstance # @param [Status] status @@ -263,6 +375,47 @@ def update( ) end + ## + # Update the CustomerProfilesInstanceMetadata + # @param [Status] status + # @param [String] status_callback The URL we call to inform your application of status changes. + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] email The email address that will receive updates when the Customer-Profile resource changes status. + # @return [CustomerProfilesInstance] Updated CustomerProfilesInstance + def update_with_metadata( + status: :unset, + status_callback: :unset, + friendly_name: :unset, + email: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'StatusCallback' => status_callback, + 'FriendlyName' => friendly_name, + 'Email' => email, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + customerProfiles_instance = CustomerProfilesInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CustomerProfilesInstanceMetadata.new( + @version, + customerProfiles_instance, + response.headers, + response.status_code + ) + end + ## # Access the customer_profiles_channel_endpoint_assignment # @return [CustomerProfilesChannelEndpointAssignmentList] @@ -336,6 +489,45 @@ def inspect end end + class CustomerProfilesInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CustomerProfilesInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CustomerProfilesInstance] customer_profiles_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CustomerProfilesInstanceMetadata] The initialized instance with metadata. + def initialize(version, customer_profiles_instance, headers, status_code) + super(version, headers, status_code) + @customer_profiles_instance = customer_profiles_instance + end + + def customer_profiles + @customer_profiles_instance + end + + def to_s + "" + end + end + + class CustomerProfilesListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles_instance = payload.body[key].map do |data| + CustomerProfilesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles_instance + @instance + end + end + class CustomerProfilesPage < Page ## # Initialize the CustomerProfilesPage @@ -364,6 +556,54 @@ def to_s '' end end + + class CustomerProfilesPageMetadata < PageMetadata + attr_reader :customer_profiles_page + + def initialize(version, response, solution, limit) + super(version, response) + @customer_profiles_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @customer_profiles_page << CustomerProfilesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @customer_profiles_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CustomerProfilesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles = payload.body[key].map do |data| + CustomerProfilesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles + @customer_profiles + end + end + class CustomerProfilesInstance < InstanceResource ## # Initialize the CustomerProfilesInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.rb b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.rb index 29a0d44db..aa4bd7bd6 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the CustomerProfilesChannelEndpointAssignmentInstanceMetadata + # @param [String] channel_endpoint_type The type of channel endpoint. eg: phone-number + # @param [String] channel_endpoint_sid The SID of an channel endpoint + # @return [CustomerProfilesChannelEndpointAssignmentInstance] Created CustomerProfilesChannelEndpointAssignmentInstance + def create_with_metadata( + channel_endpoint_type: nil, + channel_endpoint_sid: nil + ) + + data = Twilio::Values.of({ + 'ChannelEndpointType' => channel_endpoint_type, + 'ChannelEndpointSid' => channel_endpoint_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + customerProfilesChannelEndpointAssignment_instance = CustomerProfilesChannelEndpointAssignmentInstance.new( + @version, + response.body, + customer_profile_sid: @solution[:customer_profile_sid], + ) + CustomerProfilesChannelEndpointAssignmentInstanceMetadata.new( + @version, + customerProfilesChannelEndpointAssignment_instance, + response.headers, + response.status_code + ) + end + ## # Lists CustomerProfilesChannelEndpointAssignmentInstance records from the API as a list. @@ -108,6 +143,32 @@ def stream(channel_endpoint_sid: :unset, channel_endpoint_sids: :unset, limit: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CustomerProfilesChannelEndpointAssignmentPageMetadata records from the API as a list. + # @param [String] channel_endpoint_sid The SID of an channel endpoint + # @param [String] channel_endpoint_sids comma separated list of channel endpoint sids + # @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_with_metadata(channel_endpoint_sid: :unset, channel_endpoint_sids: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ChannelEndpointSid' => channel_endpoint_sid, + 'ChannelEndpointSids' => channel_endpoint_sids, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CustomerProfilesChannelEndpointAssignmentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CustomerProfilesChannelEndpointAssignmentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -195,7 +256,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CustomerProfilesChannelEndpointAssignmentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + customerProfilesChannelEndpointAssignment_instance = CustomerProfilesChannelEndpointAssignmentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CustomerProfilesChannelEndpointAssignmentInstanceMetadata.new(@version, customerProfilesChannelEndpointAssignment_instance, response.headers, response.status_code) end ## @@ -218,6 +298,32 @@ def fetch ) end + ## + # Fetch the CustomerProfilesChannelEndpointAssignmentInstanceMetadata + # @return [CustomerProfilesChannelEndpointAssignmentInstance] Fetched CustomerProfilesChannelEndpointAssignmentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + customerProfilesChannelEndpointAssignment_instance = CustomerProfilesChannelEndpointAssignmentInstance.new( + @version, + response.body, + customer_profile_sid: @solution[:customer_profile_sid], + sid: @solution[:sid], + ) + CustomerProfilesChannelEndpointAssignmentInstanceMetadata.new( + @version, + customerProfilesChannelEndpointAssignment_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -234,6 +340,45 @@ def inspect end end + class CustomerProfilesChannelEndpointAssignmentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CustomerProfilesChannelEndpointAssignmentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CustomerProfilesChannelEndpointAssignmentInstance] customer_profiles_channel_endpoint_assignment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CustomerProfilesChannelEndpointAssignmentInstanceMetadata] The initialized instance with metadata. + def initialize(version, customer_profiles_channel_endpoint_assignment_instance, headers, status_code) + super(version, headers, status_code) + @customer_profiles_channel_endpoint_assignment_instance = customer_profiles_channel_endpoint_assignment_instance + end + + def customer_profiles_channel_endpoint_assignment + @customer_profiles_channel_endpoint_assignment_instance + end + + def to_s + "" + end + end + + class CustomerProfilesChannelEndpointAssignmentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles_channel_endpoint_assignment_instance = payload.body[key].map do |data| + CustomerProfilesChannelEndpointAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles_channel_endpoint_assignment_instance + @instance + end + end + class CustomerProfilesChannelEndpointAssignmentPage < Page ## # Initialize the CustomerProfilesChannelEndpointAssignmentPage @@ -262,6 +407,54 @@ def to_s '' end end + + class CustomerProfilesChannelEndpointAssignmentPageMetadata < PageMetadata + attr_reader :customer_profiles_channel_endpoint_assignment_page + + def initialize(version, response, solution, limit) + super(version, response) + @customer_profiles_channel_endpoint_assignment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @customer_profiles_channel_endpoint_assignment_page << CustomerProfilesChannelEndpointAssignmentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @customer_profiles_channel_endpoint_assignment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CustomerProfilesChannelEndpointAssignmentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles_channel_endpoint_assignment = payload.body[key].map do |data| + CustomerProfilesChannelEndpointAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles_channel_endpoint_assignment + @customer_profiles_channel_endpoint_assignment + end + end + class CustomerProfilesChannelEndpointAssignmentInstance < InstanceResource ## # Initialize the CustomerProfilesChannelEndpointAssignmentInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.rb b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.rb index 0efed392d..2aeb19441 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the CustomerProfilesEntityAssignmentsInstanceMetadata + # @param [String] object_sid The SID of an object bag that holds information of the different items. + # @return [CustomerProfilesEntityAssignmentsInstance] Created CustomerProfilesEntityAssignmentsInstance + def create_with_metadata( + object_sid: nil + ) + + data = Twilio::Values.of({ + 'ObjectSid' => object_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + customerProfilesEntityAssignments_instance = CustomerProfilesEntityAssignmentsInstance.new( + @version, + response.body, + customer_profile_sid: @solution[:customer_profile_sid], + ) + CustomerProfilesEntityAssignmentsInstanceMetadata.new( + @version, + customerProfilesEntityAssignments_instance, + response.headers, + response.status_code + ) + end + ## # Lists CustomerProfilesEntityAssignmentsInstance records from the API as a list. @@ -101,6 +133,30 @@ def stream(object_type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CustomerProfilesEntityAssignmentsPageMetadata records from the API as a list. + # @param [String] object_type A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. + # @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_with_metadata(object_type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ObjectType' => object_type, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CustomerProfilesEntityAssignmentsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CustomerProfilesEntityAssignmentsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +242,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CustomerProfilesEntityAssignmentsInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + customerProfilesEntityAssignments_instance = CustomerProfilesEntityAssignmentsInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CustomerProfilesEntityAssignmentsInstanceMetadata.new(@version, customerProfilesEntityAssignments_instance, response.headers, response.status_code) end ## @@ -209,6 +284,32 @@ def fetch ) end + ## + # Fetch the CustomerProfilesEntityAssignmentsInstanceMetadata + # @return [CustomerProfilesEntityAssignmentsInstance] Fetched CustomerProfilesEntityAssignmentsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + customerProfilesEntityAssignments_instance = CustomerProfilesEntityAssignmentsInstance.new( + @version, + response.body, + customer_profile_sid: @solution[:customer_profile_sid], + sid: @solution[:sid], + ) + CustomerProfilesEntityAssignmentsInstanceMetadata.new( + @version, + customerProfilesEntityAssignments_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -225,6 +326,45 @@ def inspect end end + class CustomerProfilesEntityAssignmentsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CustomerProfilesEntityAssignmentsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CustomerProfilesEntityAssignmentsInstance] customer_profiles_entity_assignments_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CustomerProfilesEntityAssignmentsInstanceMetadata] The initialized instance with metadata. + def initialize(version, customer_profiles_entity_assignments_instance, headers, status_code) + super(version, headers, status_code) + @customer_profiles_entity_assignments_instance = customer_profiles_entity_assignments_instance + end + + def customer_profiles_entity_assignments + @customer_profiles_entity_assignments_instance + end + + def to_s + "" + end + end + + class CustomerProfilesEntityAssignmentsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles_entity_assignments_instance = payload.body[key].map do |data| + CustomerProfilesEntityAssignmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles_entity_assignments_instance + @instance + end + end + class CustomerProfilesEntityAssignmentsPage < Page ## # Initialize the CustomerProfilesEntityAssignmentsPage @@ -253,6 +393,54 @@ def to_s '' end end + + class CustomerProfilesEntityAssignmentsPageMetadata < PageMetadata + attr_reader :customer_profiles_entity_assignments_page + + def initialize(version, response, solution, limit) + super(version, response) + @customer_profiles_entity_assignments_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @customer_profiles_entity_assignments_page << CustomerProfilesEntityAssignmentsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @customer_profiles_entity_assignments_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CustomerProfilesEntityAssignmentsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles_entity_assignments = payload.body[key].map do |data| + CustomerProfilesEntityAssignmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles_entity_assignments + @customer_profiles_entity_assignments + end + end + class CustomerProfilesEntityAssignmentsInstance < InstanceResource ## # Initialize the CustomerProfilesEntityAssignmentsInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.rb b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.rb index ab5ef43ba..825422706 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the CustomerProfilesEvaluationsInstanceMetadata + # @param [String] policy_sid The unique string of a policy that is associated to the customer_profile resource. + # @return [CustomerProfilesEvaluationsInstance] Created CustomerProfilesEvaluationsInstance + def create_with_metadata( + policy_sid: nil + ) + + data = Twilio::Values.of({ + 'PolicySid' => policy_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + customerProfilesEvaluations_instance = CustomerProfilesEvaluationsInstance.new( + @version, + response.body, + customer_profile_sid: @solution[:customer_profile_sid], + ) + CustomerProfilesEvaluationsInstanceMetadata.new( + @version, + customerProfilesEvaluations_instance, + response.headers, + response.status_code + ) + end + ## # Lists CustomerProfilesEvaluationsInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CustomerProfilesEvaluationsPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CustomerProfilesEvaluationsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CustomerProfilesEvaluationsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -191,6 +245,32 @@ def fetch ) end + ## + # Fetch the CustomerProfilesEvaluationsInstanceMetadata + # @return [CustomerProfilesEvaluationsInstance] Fetched CustomerProfilesEvaluationsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + customerProfilesEvaluations_instance = CustomerProfilesEvaluationsInstance.new( + @version, + response.body, + customer_profile_sid: @solution[:customer_profile_sid], + sid: @solution[:sid], + ) + CustomerProfilesEvaluationsInstanceMetadata.new( + @version, + customerProfilesEvaluations_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -207,6 +287,45 @@ def inspect end end + class CustomerProfilesEvaluationsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CustomerProfilesEvaluationsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CustomerProfilesEvaluationsInstance] customer_profiles_evaluations_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CustomerProfilesEvaluationsInstanceMetadata] The initialized instance with metadata. + def initialize(version, customer_profiles_evaluations_instance, headers, status_code) + super(version, headers, status_code) + @customer_profiles_evaluations_instance = customer_profiles_evaluations_instance + end + + def customer_profiles_evaluations + @customer_profiles_evaluations_instance + end + + def to_s + "" + end + end + + class CustomerProfilesEvaluationsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles_evaluations_instance = payload.body[key].map do |data| + CustomerProfilesEvaluationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles_evaluations_instance + @instance + end + end + class CustomerProfilesEvaluationsPage < Page ## # Initialize the CustomerProfilesEvaluationsPage @@ -235,6 +354,54 @@ def to_s '' end end + + class CustomerProfilesEvaluationsPageMetadata < PageMetadata + attr_reader :customer_profiles_evaluations_page + + def initialize(version, response, solution, limit) + super(version, response) + @customer_profiles_evaluations_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @customer_profiles_evaluations_page << CustomerProfilesEvaluationsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @customer_profiles_evaluations_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CustomerProfilesEvaluationsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @customer_profiles_evaluations = payload.body[key].map do |data| + CustomerProfilesEvaluationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def customer_profiles_evaluations + @customer_profiles_evaluations + end + end + class CustomerProfilesEvaluationsInstance < InstanceResource ## # Initialize the CustomerProfilesEvaluationsInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/end_user.rb b/lib/twilio-ruby/rest/trusthub/v1/end_user.rb index ae55bd355..7a09e4463 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/end_user.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/end_user.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the EndUserInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] type The type of end user of the Bundle resource - can be `individual` or `business`. + # @param [Object] attributes The set of parameters that are the attributes of the End User resource which are derived End User Types. + # @return [EndUserInstance] Created EndUserInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + ) + EndUserInstanceMetadata.new( + @version, + endUser_instance, + response.headers, + response.status_code + ) + end + ## # Lists EndUserInstance records from the API as a list. @@ -100,6 +137,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EndUserPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EndUserPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EndUserInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the EndUserInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + EndUserInstanceMetadata.new(@version, endUser_instance, response.headers, response.status_code) end ## @@ -204,6 +282,31 @@ def fetch ) end + ## + # Fetch the EndUserInstanceMetadata + # @return [EndUserInstance] Fetched EndUserInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EndUserInstanceMetadata.new( + @version, + endUser_instance, + response.headers, + response.status_code + ) + end + ## # Update the EndUserInstance # @param [String] friendly_name The string that you assigned to describe the resource. @@ -233,6 +336,41 @@ def update( ) end + ## + # Update the EndUserInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [Object] attributes The set of parameters that are the attributes of the End User resource which are derived End User Types. + # @return [EndUserInstance] Updated EndUserInstance + def update_with_metadata( + friendly_name: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + endUser_instance = EndUserInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EndUserInstanceMetadata.new( + @version, + endUser_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -249,6 +387,45 @@ def inspect end end + class EndUserInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EndUserInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EndUserInstance] end_user_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EndUserInstanceMetadata] The initialized instance with metadata. + def initialize(version, end_user_instance, headers, status_code) + super(version, headers, status_code) + @end_user_instance = end_user_instance + end + + def end_user + @end_user_instance + end + + def to_s + "" + end + end + + class EndUserListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user_instance = payload.body[key].map do |data| + EndUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user_instance + @instance + end + end + class EndUserPage < Page ## # Initialize the EndUserPage @@ -277,6 +454,54 @@ def to_s '' end end + + class EndUserPageMetadata < PageMetadata + attr_reader :end_user_page + + def initialize(version, response, solution, limit) + super(version, response) + @end_user_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @end_user_page << EndUserListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @end_user_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EndUserListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user = payload.body[key].map do |data| + EndUserInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user + @end_user + end + end + class EndUserInstance < InstanceResource ## # Initialize the EndUserInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/end_user_type.rb b/lib/twilio-ruby/rest/trusthub/v1/end_user_type.rb index e4995c24e..05bc7433b 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/end_user_type.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/end_user_type.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EndUserTypePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EndUserTypePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EndUserTypeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -161,6 +183,31 @@ def fetch ) end + ## + # Fetch the EndUserTypeInstanceMetadata + # @return [EndUserTypeInstance] Fetched EndUserTypeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + endUserType_instance = EndUserTypeInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + EndUserTypeInstanceMetadata.new( + @version, + endUserType_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -177,6 +224,45 @@ def inspect end end + class EndUserTypeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EndUserTypeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EndUserTypeInstance] end_user_type_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EndUserTypeInstanceMetadata] The initialized instance with metadata. + def initialize(version, end_user_type_instance, headers, status_code) + super(version, headers, status_code) + @end_user_type_instance = end_user_type_instance + end + + def end_user_type + @end_user_type_instance + end + + def to_s + "" + end + end + + class EndUserTypeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user_type_instance = payload.body[key].map do |data| + EndUserTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user_type_instance + @instance + end + end + class EndUserTypePage < Page ## # Initialize the EndUserTypePage @@ -205,6 +291,54 @@ def to_s '' end end + + class EndUserTypePageMetadata < PageMetadata + attr_reader :end_user_type_page + + def initialize(version, response, solution, limit) + super(version, response) + @end_user_type_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @end_user_type_page << EndUserTypeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @end_user_type_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EndUserTypeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @end_user_type = payload.body[key].map do |data| + EndUserTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def end_user_type + @end_user_type + end + end + class EndUserTypeInstance < InstanceResource ## # Initialize the EndUserTypeInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/policies.rb b/lib/twilio-ruby/rest/trusthub/v1/policies.rb index 2ab455d2b..9b52df09a 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/policies.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/policies.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PoliciesPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PoliciesPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PoliciesInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -161,6 +183,31 @@ def fetch ) end + ## + # Fetch the PoliciesInstanceMetadata + # @return [PoliciesInstance] Fetched PoliciesInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + policies_instance = PoliciesInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + PoliciesInstanceMetadata.new( + @version, + policies_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -177,6 +224,45 @@ def inspect end end + class PoliciesInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PoliciesInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PoliciesInstance] policies_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PoliciesInstanceMetadata] The initialized instance with metadata. + def initialize(version, policies_instance, headers, status_code) + super(version, headers, status_code) + @policies_instance = policies_instance + end + + def policies + @policies_instance + end + + def to_s + "" + end + end + + class PoliciesListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @policies_instance = payload.body[key].map do |data| + PoliciesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def policies_instance + @instance + end + end + class PoliciesPage < Page ## # Initialize the PoliciesPage @@ -205,6 +291,54 @@ def to_s '' end end + + class PoliciesPageMetadata < PageMetadata + attr_reader :policies_page + + def initialize(version, response, solution, limit) + super(version, response) + @policies_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @policies_page << PoliciesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @policies_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PoliciesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @policies = payload.body[key].map do |data| + PoliciesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def policies + @policies + end + end + class PoliciesInstance < InstanceResource ## # Initialize the PoliciesInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/supporting_document.rb b/lib/twilio-ruby/rest/trusthub/v1/supporting_document.rb index c04b8f98a..f63aa64a9 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/supporting_document.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/supporting_document.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the SupportingDocumentInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] type The type of the Supporting Document. + # @param [Object] attributes The set of parameters that are the attributes of the Supporting Documents resource which are derived Supporting Document Types. + # @return [SupportingDocumentInstance] Created SupportingDocumentInstance + def create_with_metadata( + friendly_name: nil, + type: nil, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Type' => type, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + ) + SupportingDocumentInstanceMetadata.new( + @version, + supportingDocument_instance, + response.headers, + response.status_code + ) + end + ## # Lists SupportingDocumentInstance records from the API as a list. @@ -100,6 +137,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SupportingDocumentPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SupportingDocumentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SupportingDocumentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SupportingDocumentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SupportingDocumentInstanceMetadata.new(@version, supportingDocument_instance, response.headers, response.status_code) end ## @@ -204,6 +282,31 @@ def fetch ) end + ## + # Fetch the SupportingDocumentInstanceMetadata + # @return [SupportingDocumentInstance] Fetched SupportingDocumentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SupportingDocumentInstanceMetadata.new( + @version, + supportingDocument_instance, + response.headers, + response.status_code + ) + end + ## # Update the SupportingDocumentInstance # @param [String] friendly_name The string that you assigned to describe the resource. @@ -233,6 +336,41 @@ def update( ) end + ## + # Update the SupportingDocumentInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [Object] attributes The set of parameters that are the attributes of the Supporting Document resource which are derived Supporting Document Types. + # @return [SupportingDocumentInstance] Updated SupportingDocumentInstance + def update_with_metadata( + friendly_name: :unset, + attributes: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Attributes' => Twilio.serialize_object(attributes), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + supportingDocument_instance = SupportingDocumentInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SupportingDocumentInstanceMetadata.new( + @version, + supportingDocument_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -249,6 +387,45 @@ def inspect end end + class SupportingDocumentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SupportingDocumentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SupportingDocumentInstance] supporting_document_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SupportingDocumentInstanceMetadata] The initialized instance with metadata. + def initialize(version, supporting_document_instance, headers, status_code) + super(version, headers, status_code) + @supporting_document_instance = supporting_document_instance + end + + def supporting_document + @supporting_document_instance + end + + def to_s + "" + end + end + + class SupportingDocumentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document_instance = payload.body[key].map do |data| + SupportingDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document_instance + @instance + end + end + class SupportingDocumentPage < Page ## # Initialize the SupportingDocumentPage @@ -277,6 +454,54 @@ def to_s '' end end + + class SupportingDocumentPageMetadata < PageMetadata + attr_reader :supporting_document_page + + def initialize(version, response, solution, limit) + super(version, response) + @supporting_document_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @supporting_document_page << SupportingDocumentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @supporting_document_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SupportingDocumentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document = payload.body[key].map do |data| + SupportingDocumentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document + @supporting_document + end + end + class SupportingDocumentInstance < InstanceResource ## # Initialize the SupportingDocumentInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/supporting_document_type.rb b/lib/twilio-ruby/rest/trusthub/v1/supporting_document_type.rb index 4d5206a3a..babd297f3 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/supporting_document_type.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/supporting_document_type.rb @@ -69,6 +69,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SupportingDocumentTypePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SupportingDocumentTypePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SupportingDocumentTypeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -161,6 +183,31 @@ def fetch ) end + ## + # Fetch the SupportingDocumentTypeInstanceMetadata + # @return [SupportingDocumentTypeInstance] Fetched SupportingDocumentTypeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + supportingDocumentType_instance = SupportingDocumentTypeInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SupportingDocumentTypeInstanceMetadata.new( + @version, + supportingDocumentType_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -177,6 +224,45 @@ def inspect end end + class SupportingDocumentTypeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SupportingDocumentTypeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SupportingDocumentTypeInstance] supporting_document_type_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SupportingDocumentTypeInstanceMetadata] The initialized instance with metadata. + def initialize(version, supporting_document_type_instance, headers, status_code) + super(version, headers, status_code) + @supporting_document_type_instance = supporting_document_type_instance + end + + def supporting_document_type + @supporting_document_type_instance + end + + def to_s + "" + end + end + + class SupportingDocumentTypeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document_type_instance = payload.body[key].map do |data| + SupportingDocumentTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document_type_instance + @instance + end + end + class SupportingDocumentTypePage < Page ## # Initialize the SupportingDocumentTypePage @@ -205,6 +291,54 @@ def to_s '' end end + + class SupportingDocumentTypePageMetadata < PageMetadata + attr_reader :supporting_document_type_page + + def initialize(version, response, solution, limit) + super(version, response) + @supporting_document_type_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @supporting_document_type_page << SupportingDocumentTypeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @supporting_document_type_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SupportingDocumentTypeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @supporting_document_type = payload.body[key].map do |data| + SupportingDocumentTypeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def supporting_document_type + @supporting_document_type + end + end + class SupportingDocumentTypeInstance < InstanceResource ## # Initialize the SupportingDocumentTypeInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/trust_products.rb b/lib/twilio-ruby/rest/trusthub/v1/trust_products.rb index a876462a9..084a229ed 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/trust_products.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/trust_products.rb @@ -64,6 +64,46 @@ def create( ) end + ## + # Create the TrustProductsInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] email The email address that will receive updates when the Trust Product resource changes status. + # @param [String] policy_sid The unique string of a policy that is associated to the Trust Product resource. + # @param [String] status_callback The URL we call to inform your application of status changes. + # @return [TrustProductsInstance] Created TrustProductsInstance + def create_with_metadata( + friendly_name: nil, + email: nil, + policy_sid: nil, + status_callback: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Email' => email, + 'PolicySid' => policy_sid, + 'StatusCallback' => status_callback, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + trustProducts_instance = TrustProductsInstance.new( + @version, + response.body, + ) + TrustProductsInstanceMetadata.new( + @version, + trustProducts_instance, + response.headers, + response.status_code + ) + end + ## # Lists TrustProductsInstance records from the API as a list. @@ -115,6 +155,34 @@ def stream(status: :unset, friendly_name: :unset, policy_sid: :unset, limit: nil @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TrustProductsPageMetadata records from the API as a list. + # @param [Status] status The verification status of the Trust Product resource. + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] policy_sid The unique string of a policy that is associated to the Trust Product resource. + # @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_with_metadata(status: :unset, friendly_name: :unset, policy_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'FriendlyName' => friendly_name, + 'PolicySid' => policy_sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TrustProductsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TrustProductsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -206,7 +274,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TrustProductsInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + trustProducts_instance = TrustProductsInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TrustProductsInstanceMetadata.new(@version, trustProducts_instance, response.headers, response.status_code) end ## @@ -228,6 +315,31 @@ def fetch ) end + ## + # Fetch the TrustProductsInstanceMetadata + # @return [TrustProductsInstance] Fetched TrustProductsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + trustProducts_instance = TrustProductsInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + TrustProductsInstanceMetadata.new( + @version, + trustProducts_instance, + response.headers, + response.status_code + ) + end + ## # Update the TrustProductsInstance # @param [Status] status @@ -263,6 +375,47 @@ def update( ) end + ## + # Update the TrustProductsInstanceMetadata + # @param [Status] status + # @param [String] status_callback The URL we call to inform your application of status changes. + # @param [String] friendly_name The string that you assigned to describe the resource. + # @param [String] email The email address that will receive updates when the Trust Product resource changes status. + # @return [TrustProductsInstance] Updated TrustProductsInstance + def update_with_metadata( + status: :unset, + status_callback: :unset, + friendly_name: :unset, + email: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'StatusCallback' => status_callback, + 'FriendlyName' => friendly_name, + 'Email' => email, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + trustProducts_instance = TrustProductsInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + TrustProductsInstanceMetadata.new( + @version, + trustProducts_instance, + response.headers, + response.status_code + ) + end + ## # Access the trust_products_channel_endpoint_assignment # @return [TrustProductsChannelEndpointAssignmentList] @@ -336,6 +489,45 @@ def inspect end end + class TrustProductsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TrustProductsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TrustProductsInstance] trust_products_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TrustProductsInstanceMetadata] The initialized instance with metadata. + def initialize(version, trust_products_instance, headers, status_code) + super(version, headers, status_code) + @trust_products_instance = trust_products_instance + end + + def trust_products + @trust_products_instance + end + + def to_s + "" + end + end + + class TrustProductsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products_instance = payload.body[key].map do |data| + TrustProductsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products_instance + @instance + end + end + class TrustProductsPage < Page ## # Initialize the TrustProductsPage @@ -364,6 +556,54 @@ def to_s '' end end + + class TrustProductsPageMetadata < PageMetadata + attr_reader :trust_products_page + + def initialize(version, response, solution, limit) + super(version, response) + @trust_products_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @trust_products_page << TrustProductsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @trust_products_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TrustProductsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products = payload.body[key].map do |data| + TrustProductsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products + @trust_products + end + end + class TrustProductsInstance < InstanceResource ## # Initialize the TrustProductsInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.rb b/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.rb index 29effd9a8..6d8cf893e 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the TrustProductsChannelEndpointAssignmentInstanceMetadata + # @param [String] channel_endpoint_type The type of channel endpoint. eg: phone-number + # @param [String] channel_endpoint_sid The SID of an channel endpoint + # @return [TrustProductsChannelEndpointAssignmentInstance] Created TrustProductsChannelEndpointAssignmentInstance + def create_with_metadata( + channel_endpoint_type: nil, + channel_endpoint_sid: nil + ) + + data = Twilio::Values.of({ + 'ChannelEndpointType' => channel_endpoint_type, + 'ChannelEndpointSid' => channel_endpoint_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + trustProductsChannelEndpointAssignment_instance = TrustProductsChannelEndpointAssignmentInstance.new( + @version, + response.body, + trust_product_sid: @solution[:trust_product_sid], + ) + TrustProductsChannelEndpointAssignmentInstanceMetadata.new( + @version, + trustProductsChannelEndpointAssignment_instance, + response.headers, + response.status_code + ) + end + ## # Lists TrustProductsChannelEndpointAssignmentInstance records from the API as a list. @@ -108,6 +143,32 @@ def stream(channel_endpoint_sid: :unset, channel_endpoint_sids: :unset, limit: n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TrustProductsChannelEndpointAssignmentPageMetadata records from the API as a list. + # @param [String] channel_endpoint_sid The SID of an channel endpoint + # @param [String] channel_endpoint_sids comma separated list of channel endpoint sids + # @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_with_metadata(channel_endpoint_sid: :unset, channel_endpoint_sids: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ChannelEndpointSid' => channel_endpoint_sid, + 'ChannelEndpointSids' => channel_endpoint_sids, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TrustProductsChannelEndpointAssignmentPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TrustProductsChannelEndpointAssignmentInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -195,7 +256,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TrustProductsChannelEndpointAssignmentInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + trustProductsChannelEndpointAssignment_instance = TrustProductsChannelEndpointAssignmentInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TrustProductsChannelEndpointAssignmentInstanceMetadata.new(@version, trustProductsChannelEndpointAssignment_instance, response.headers, response.status_code) end ## @@ -218,6 +298,32 @@ def fetch ) end + ## + # Fetch the TrustProductsChannelEndpointAssignmentInstanceMetadata + # @return [TrustProductsChannelEndpointAssignmentInstance] Fetched TrustProductsChannelEndpointAssignmentInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + trustProductsChannelEndpointAssignment_instance = TrustProductsChannelEndpointAssignmentInstance.new( + @version, + response.body, + trust_product_sid: @solution[:trust_product_sid], + sid: @solution[:sid], + ) + TrustProductsChannelEndpointAssignmentInstanceMetadata.new( + @version, + trustProductsChannelEndpointAssignment_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -234,6 +340,45 @@ def inspect end end + class TrustProductsChannelEndpointAssignmentInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TrustProductsChannelEndpointAssignmentInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TrustProductsChannelEndpointAssignmentInstance] trust_products_channel_endpoint_assignment_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TrustProductsChannelEndpointAssignmentInstanceMetadata] The initialized instance with metadata. + def initialize(version, trust_products_channel_endpoint_assignment_instance, headers, status_code) + super(version, headers, status_code) + @trust_products_channel_endpoint_assignment_instance = trust_products_channel_endpoint_assignment_instance + end + + def trust_products_channel_endpoint_assignment + @trust_products_channel_endpoint_assignment_instance + end + + def to_s + "" + end + end + + class TrustProductsChannelEndpointAssignmentListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products_channel_endpoint_assignment_instance = payload.body[key].map do |data| + TrustProductsChannelEndpointAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products_channel_endpoint_assignment_instance + @instance + end + end + class TrustProductsChannelEndpointAssignmentPage < Page ## # Initialize the TrustProductsChannelEndpointAssignmentPage @@ -262,6 +407,54 @@ def to_s '' end end + + class TrustProductsChannelEndpointAssignmentPageMetadata < PageMetadata + attr_reader :trust_products_channel_endpoint_assignment_page + + def initialize(version, response, solution, limit) + super(version, response) + @trust_products_channel_endpoint_assignment_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @trust_products_channel_endpoint_assignment_page << TrustProductsChannelEndpointAssignmentListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @trust_products_channel_endpoint_assignment_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TrustProductsChannelEndpointAssignmentListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products_channel_endpoint_assignment = payload.body[key].map do |data| + TrustProductsChannelEndpointAssignmentInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products_channel_endpoint_assignment + @trust_products_channel_endpoint_assignment + end + end + class TrustProductsChannelEndpointAssignmentInstance < InstanceResource ## # Initialize the TrustProductsChannelEndpointAssignmentInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_entity_assignments.rb b/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_entity_assignments.rb index c3cb85a60..a4d9d6d09 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_entity_assignments.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_entity_assignments.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the TrustProductsEntityAssignmentsInstanceMetadata + # @param [String] object_sid The SID of an object bag that holds information of the different items. + # @return [TrustProductsEntityAssignmentsInstance] Created TrustProductsEntityAssignmentsInstance + def create_with_metadata( + object_sid: nil + ) + + data = Twilio::Values.of({ + 'ObjectSid' => object_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + trustProductsEntityAssignments_instance = TrustProductsEntityAssignmentsInstance.new( + @version, + response.body, + trust_product_sid: @solution[:trust_product_sid], + ) + TrustProductsEntityAssignmentsInstanceMetadata.new( + @version, + trustProductsEntityAssignments_instance, + response.headers, + response.status_code + ) + end + ## # Lists TrustProductsEntityAssignmentsInstance records from the API as a list. @@ -101,6 +133,30 @@ def stream(object_type: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TrustProductsEntityAssignmentsPageMetadata records from the API as a list. + # @param [String] object_type A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. + # @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_with_metadata(object_type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'ObjectType' => object_type, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TrustProductsEntityAssignmentsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TrustProductsEntityAssignmentsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +242,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the TrustProductsEntityAssignmentsInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + trustProductsEntityAssignments_instance = TrustProductsEntityAssignmentsInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + TrustProductsEntityAssignmentsInstanceMetadata.new(@version, trustProductsEntityAssignments_instance, response.headers, response.status_code) end ## @@ -209,6 +284,32 @@ def fetch ) end + ## + # Fetch the TrustProductsEntityAssignmentsInstanceMetadata + # @return [TrustProductsEntityAssignmentsInstance] Fetched TrustProductsEntityAssignmentsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + trustProductsEntityAssignments_instance = TrustProductsEntityAssignmentsInstance.new( + @version, + response.body, + trust_product_sid: @solution[:trust_product_sid], + sid: @solution[:sid], + ) + TrustProductsEntityAssignmentsInstanceMetadata.new( + @version, + trustProductsEntityAssignments_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -225,6 +326,45 @@ def inspect end end + class TrustProductsEntityAssignmentsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TrustProductsEntityAssignmentsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TrustProductsEntityAssignmentsInstance] trust_products_entity_assignments_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TrustProductsEntityAssignmentsInstanceMetadata] The initialized instance with metadata. + def initialize(version, trust_products_entity_assignments_instance, headers, status_code) + super(version, headers, status_code) + @trust_products_entity_assignments_instance = trust_products_entity_assignments_instance + end + + def trust_products_entity_assignments + @trust_products_entity_assignments_instance + end + + def to_s + "" + end + end + + class TrustProductsEntityAssignmentsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products_entity_assignments_instance = payload.body[key].map do |data| + TrustProductsEntityAssignmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products_entity_assignments_instance + @instance + end + end + class TrustProductsEntityAssignmentsPage < Page ## # Initialize the TrustProductsEntityAssignmentsPage @@ -253,6 +393,54 @@ def to_s '' end end + + class TrustProductsEntityAssignmentsPageMetadata < PageMetadata + attr_reader :trust_products_entity_assignments_page + + def initialize(version, response, solution, limit) + super(version, response) + @trust_products_entity_assignments_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @trust_products_entity_assignments_page << TrustProductsEntityAssignmentsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @trust_products_entity_assignments_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TrustProductsEntityAssignmentsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products_entity_assignments = payload.body[key].map do |data| + TrustProductsEntityAssignmentsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products_entity_assignments + @trust_products_entity_assignments + end + end + class TrustProductsEntityAssignmentsInstance < InstanceResource ## # Initialize the TrustProductsEntityAssignmentsInstance diff --git a/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_evaluations.rb b/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_evaluations.rb index f708adf52..f88e3e0d0 100644 --- a/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_evaluations.rb +++ b/lib/twilio-ruby/rest/trusthub/v1/trust_products/trust_products_evaluations.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the TrustProductsEvaluationsInstanceMetadata + # @param [String] policy_sid The unique string of a policy that is associated to the customer_profile resource. + # @return [TrustProductsEvaluationsInstance] Created TrustProductsEvaluationsInstance + def create_with_metadata( + policy_sid: nil + ) + + data = Twilio::Values.of({ + 'PolicySid' => policy_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + trustProductsEvaluations_instance = TrustProductsEvaluationsInstance.new( + @version, + response.body, + trust_product_sid: @solution[:trust_product_sid], + ) + TrustProductsEvaluationsInstanceMetadata.new( + @version, + trustProductsEvaluations_instance, + response.headers, + response.status_code + ) + end + ## # Lists TrustProductsEvaluationsInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TrustProductsEvaluationsPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TrustProductsEvaluationsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TrustProductsEvaluationsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -191,6 +245,32 @@ def fetch ) end + ## + # Fetch the TrustProductsEvaluationsInstanceMetadata + # @return [TrustProductsEvaluationsInstance] Fetched TrustProductsEvaluationsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + trustProductsEvaluations_instance = TrustProductsEvaluationsInstance.new( + @version, + response.body, + trust_product_sid: @solution[:trust_product_sid], + sid: @solution[:sid], + ) + TrustProductsEvaluationsInstanceMetadata.new( + @version, + trustProductsEvaluations_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -207,6 +287,45 @@ def inspect end end + class TrustProductsEvaluationsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TrustProductsEvaluationsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TrustProductsEvaluationsInstance] trust_products_evaluations_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TrustProductsEvaluationsInstanceMetadata] The initialized instance with metadata. + def initialize(version, trust_products_evaluations_instance, headers, status_code) + super(version, headers, status_code) + @trust_products_evaluations_instance = trust_products_evaluations_instance + end + + def trust_products_evaluations + @trust_products_evaluations_instance + end + + def to_s + "" + end + end + + class TrustProductsEvaluationsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products_evaluations_instance = payload.body[key].map do |data| + TrustProductsEvaluationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products_evaluations_instance + @instance + end + end + class TrustProductsEvaluationsPage < Page ## # Initialize the TrustProductsEvaluationsPage @@ -235,6 +354,54 @@ def to_s '' end end + + class TrustProductsEvaluationsPageMetadata < PageMetadata + attr_reader :trust_products_evaluations_page + + def initialize(version, response, solution, limit) + super(version, response) + @trust_products_evaluations_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @trust_products_evaluations_page << TrustProductsEvaluationsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @trust_products_evaluations_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TrustProductsEvaluationsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @trust_products_evaluations = payload.body[key].map do |data| + TrustProductsEvaluationsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def trust_products_evaluations + @trust_products_evaluations + end + end + class TrustProductsEvaluationsInstance < InstanceResource ## # Initialize the TrustProductsEvaluationsInstance diff --git a/lib/twilio-ruby/rest/verify/v2/form.rb b/lib/twilio-ruby/rest/verify/v2/form.rb index 310a88b14..281cdaee9 100644 --- a/lib/twilio-ruby/rest/verify/v2/form.rb +++ b/lib/twilio-ruby/rest/verify/v2/form.rb @@ -74,6 +74,31 @@ def fetch ) end + ## + # Fetch the FormInstanceMetadata + # @return [FormInstance] Fetched FormInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + form_instance = FormInstance.new( + @version, + response.body, + form_type: @solution[:form_type], + ) + FormInstanceMetadata.new( + @version, + form_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -90,6 +115,45 @@ def inspect end end + class FormInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FormInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FormInstance] form_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FormInstanceMetadata] The initialized instance with metadata. + def initialize(version, form_instance, headers, status_code) + super(version, headers, status_code) + @form_instance = form_instance + end + + def form + @form_instance + end + + def to_s + "" + end + end + + class FormListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @form_instance = payload.body[key].map do |data| + FormInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def form_instance + @instance + end + end + class FormPage < Page ## # Initialize the FormPage @@ -118,6 +182,54 @@ def to_s '' end end + + class FormPageMetadata < PageMetadata + attr_reader :form_page + + def initialize(version, response, solution, limit) + super(version, response) + @form_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @form_page << FormListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @form_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FormListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @form = payload.body[key].map do |data| + FormInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def form + @form + end + end + class FormInstance < InstanceResource ## # Initialize the FormInstance diff --git a/lib/twilio-ruby/rest/verify/v2/safelist.rb b/lib/twilio-ruby/rest/verify/v2/safelist.rb index 4dbebfd10..3256c6507 100644 --- a/lib/twilio-ruby/rest/verify/v2/safelist.rb +++ b/lib/twilio-ruby/rest/verify/v2/safelist.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the SafelistInstanceMetadata + # @param [String] phone_number The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + # @return [SafelistInstance] Created SafelistInstance + def create_with_metadata( + phone_number: nil + ) + + data = Twilio::Values.of({ + 'PhoneNumber' => phone_number, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + safelist_instance = SafelistInstance.new( + @version, + response.body, + ) + SafelistInstanceMetadata.new( + @version, + safelist_instance, + response.headers, + response.status_code + ) + end + @@ -89,7 +120,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SafelistInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + safelist_instance = SafelistInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SafelistInstanceMetadata.new(@version, safelist_instance, response.headers, response.status_code) end ## @@ -111,6 +161,31 @@ def fetch ) end + ## + # Fetch the SafelistInstanceMetadata + # @return [SafelistInstance] Fetched SafelistInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + safelist_instance = SafelistInstance.new( + @version, + response.body, + phone_number: @solution[:phone_number], + ) + SafelistInstanceMetadata.new( + @version, + safelist_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -127,6 +202,45 @@ def inspect end end + class SafelistInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SafelistInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SafelistInstance] safelist_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SafelistInstanceMetadata] The initialized instance with metadata. + def initialize(version, safelist_instance, headers, status_code) + super(version, headers, status_code) + @safelist_instance = safelist_instance + end + + def safelist + @safelist_instance + end + + def to_s + "" + end + end + + class SafelistListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @safelist_instance = payload.body[key].map do |data| + SafelistInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def safelist_instance + @instance + end + end + class SafelistPage < Page ## # Initialize the SafelistPage @@ -155,6 +269,54 @@ def to_s '' end end + + class SafelistPageMetadata < PageMetadata + attr_reader :safelist_page + + def initialize(version, response, solution, limit) + super(version, response) + @safelist_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @safelist_page << SafelistListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @safelist_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SafelistListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @safelist = payload.body[key].map do |data| + SafelistInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def safelist + @safelist + end + end + class SafelistInstance < InstanceResource ## # Initialize the SafelistInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service.rb b/lib/twilio-ruby/rest/verify/v2/service.rb index 8d5dde3a0..c160fb623 100644 --- a/lib/twilio-ruby/rest/verify/v2/service.rb +++ b/lib/twilio-ruby/rest/verify/v2/service.rb @@ -130,6 +130,112 @@ def create( ) end + ## + # Create the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** + # @param [String] code_length The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. + # @param [Boolean] lookup_enabled Whether to perform a lookup with each verification started and return info about the phone number. + # @param [Boolean] skip_sms_to_landlines Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. + # @param [Boolean] dtmf_input_required Whether to ask the user to press a number before delivering the verify code in a phone call. + # @param [String] tts_name The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. + # @param [Boolean] psd2_enabled Whether to pass PSD2 transaction parameters when starting a verification. + # @param [Boolean] do_not_share_warning_enabled Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share this code with anyone; our employees will never ask for the code` + # @param [Boolean] custom_code_enabled Whether to allow sending verifications with a custom code instead of a randomly generated one. + # @param [Boolean] push_include_date Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. This timestamp value is the same one as the one found in `date_created`, please use that one instead. + # @param [String] push_apn_credential_sid Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) + # @param [String] push_fcm_credential_sid Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) + # @param [String] totp_issuer Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI. Defaults to the service friendly name if not provided. + # @param [String] totp_time_step Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds + # @param [String] totp_code_length Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 + # @param [String] totp_skew Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 + # @param [String] default_template_sid The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + # @param [String] whatsapp_msg_service_sid The SID of the Messaging Service containing WhatsApp Sender(s) that Verify will use to send WhatsApp messages to your users. + # @param [String] whatsapp_from The number to use as the WhatsApp Sender that Verify will use to send WhatsApp messages to your users.This WhatsApp Sender must be associated with a Messaging Service SID. + # @param [String] passkeys_relying_party_id The Relying Party ID for Passkeys. This is the domain of your application, e.g. `example.com`. It is used to identify your application when creating Passkeys. + # @param [String] passkeys_relying_party_name The Relying Party Name for Passkeys. This is the name of your application, e.g. `Example App`. It is used to identify your application when creating Passkeys. + # @param [String] passkeys_relying_party_origins The Relying Party Origins for Passkeys. This is the origin of your application, e.g. `login.example.com,www.example.com`. It is used to identify your application when creating Passkeys, it can have multiple origins split by `,`. + # @param [String] passkeys_authenticator_attachment The Authenticator Attachment for Passkeys. This is the type of authenticator that will be used to create Passkeys. It can be empty or it can have the values `platform`, `cross-platform` or `any`. + # @param [String] passkeys_discoverable_credentials Indicates whether credentials must be discoverable by the authenticator. It can be empty or it can have the values `required`, `preferred` or `discouraged`. + # @param [String] passkeys_user_verification The User Verification for Passkeys. This is the type of user verification that will be used to create Passkeys. It can be empty or it can have the values `required`, `preferred` or `discouraged`. + # @param [Boolean] verify_event_subscription_enabled Whether to allow verifications from the service to reach the stream-events sinks if configured + # @return [ServiceInstance] Created ServiceInstance + def create_with_metadata( + friendly_name: nil, + code_length: :unset, + lookup_enabled: :unset, + skip_sms_to_landlines: :unset, + dtmf_input_required: :unset, + tts_name: :unset, + psd2_enabled: :unset, + do_not_share_warning_enabled: :unset, + custom_code_enabled: :unset, + push_include_date: :unset, + push_apn_credential_sid: :unset, + push_fcm_credential_sid: :unset, + totp_issuer: :unset, + totp_time_step: :unset, + totp_code_length: :unset, + totp_skew: :unset, + default_template_sid: :unset, + whatsapp_msg_service_sid: :unset, + whatsapp_from: :unset, + passkeys_relying_party_id: :unset, + passkeys_relying_party_name: :unset, + passkeys_relying_party_origins: :unset, + passkeys_authenticator_attachment: :unset, + passkeys_discoverable_credentials: :unset, + passkeys_user_verification: :unset, + verify_event_subscription_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'CodeLength' => code_length, + 'LookupEnabled' => lookup_enabled, + 'SkipSmsToLandlines' => skip_sms_to_landlines, + 'DtmfInputRequired' => dtmf_input_required, + 'TtsName' => tts_name, + 'Psd2Enabled' => psd2_enabled, + 'DoNotShareWarningEnabled' => do_not_share_warning_enabled, + 'CustomCodeEnabled' => custom_code_enabled, + 'Push.IncludeDate' => push_include_date, + 'Push.ApnCredentialSid' => push_apn_credential_sid, + 'Push.FcmCredentialSid' => push_fcm_credential_sid, + 'Totp.Issuer' => totp_issuer, + 'Totp.TimeStep' => totp_time_step, + 'Totp.CodeLength' => totp_code_length, + 'Totp.Skew' => totp_skew, + 'DefaultTemplateSid' => default_template_sid, + 'Whatsapp.MsgServiceSid' => whatsapp_msg_service_sid, + 'Whatsapp.From' => whatsapp_from, + 'Passkeys.RelyingParty.Id' => passkeys_relying_party_id, + 'Passkeys.RelyingParty.Name' => passkeys_relying_party_name, + 'Passkeys.RelyingParty.Origins' => passkeys_relying_party_origins, + 'Passkeys.AuthenticatorAttachment' => passkeys_authenticator_attachment, + 'Passkeys.DiscoverableCredentials' => passkeys_discoverable_credentials, + 'Passkeys.UserVerification' => passkeys_user_verification, + 'VerifyEventSubscriptionEnabled' => verify_event_subscription_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Lists ServiceInstance records from the API as a list. @@ -169,6 +275,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ServicePageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ServicePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ServiceInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -262,7 +390,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ServiceInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end ## @@ -284,6 +431,31 @@ def fetch ) end + ## + # Fetch the ServiceInstanceMetadata + # @return [ServiceInstance] Fetched ServiceInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Update the ServiceInstance # @param [String] friendly_name A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** @@ -385,6 +557,113 @@ def update( ) end + ## + # Update the ServiceInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** + # @param [String] code_length The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. + # @param [Boolean] lookup_enabled Whether to perform a lookup with each verification started and return info about the phone number. + # @param [Boolean] skip_sms_to_landlines Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. + # @param [Boolean] dtmf_input_required Whether to ask the user to press a number before delivering the verify code in a phone call. + # @param [String] tts_name The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. + # @param [Boolean] psd2_enabled Whether to pass PSD2 transaction parameters when starting a verification. + # @param [Boolean] do_not_share_warning_enabled Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.** + # @param [Boolean] custom_code_enabled Whether to allow sending verifications with a custom code instead of a randomly generated one. + # @param [Boolean] push_include_date Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. + # @param [String] push_apn_credential_sid Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) + # @param [String] push_fcm_credential_sid Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) + # @param [String] totp_issuer Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI. + # @param [String] totp_time_step Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds + # @param [String] totp_code_length Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 + # @param [String] totp_skew Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 + # @param [String] default_template_sid The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + # @param [String] whatsapp_msg_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service. + # @param [String] whatsapp_from The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service. + # @param [String] passkeys_relying_party_id The Relying Party ID for Passkeys. This is the domain of your application, e.g. `example.com`. It is used to identify your application when creating Passkeys. + # @param [String] passkeys_relying_party_name The Relying Party Name for Passkeys. This is the name of your application, e.g. `Example App`. It is used to identify your application when creating Passkeys. + # @param [String] passkeys_relying_party_origins The Relying Party Origins for Passkeys. This is the origin of your application, e.g. `login.example.com,www.example.com`. It is used to identify your application when creating Passkeys, it can have multiple origins split by `,`. + # @param [String] passkeys_authenticator_attachment The Authenticator Attachment for Passkeys. This is the type of authenticator that will be used to create Passkeys. It can be empty or it can have the values `platform`, `cross-platform` or `any`. + # @param [String] passkeys_discoverable_credentials Indicates whether credentials must be discoverable by the authenticator. It can be empty or it can have the values `required`, `preferred` or `discouraged`. + # @param [String] passkeys_user_verification The User Verification for Passkeys. This is the type of user verification that will be used to create Passkeys. It can be empty or it can have the values `required`, `preferred` or `discouraged`. + # @param [Boolean] verify_event_subscription_enabled Whether to allow verifications from the service to reach the stream-events sinks if configured + # @return [ServiceInstance] Updated ServiceInstance + def update_with_metadata( + friendly_name: :unset, + code_length: :unset, + lookup_enabled: :unset, + skip_sms_to_landlines: :unset, + dtmf_input_required: :unset, + tts_name: :unset, + psd2_enabled: :unset, + do_not_share_warning_enabled: :unset, + custom_code_enabled: :unset, + push_include_date: :unset, + push_apn_credential_sid: :unset, + push_fcm_credential_sid: :unset, + totp_issuer: :unset, + totp_time_step: :unset, + totp_code_length: :unset, + totp_skew: :unset, + default_template_sid: :unset, + whatsapp_msg_service_sid: :unset, + whatsapp_from: :unset, + passkeys_relying_party_id: :unset, + passkeys_relying_party_name: :unset, + passkeys_relying_party_origins: :unset, + passkeys_authenticator_attachment: :unset, + passkeys_discoverable_credentials: :unset, + passkeys_user_verification: :unset, + verify_event_subscription_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'CodeLength' => code_length, + 'LookupEnabled' => lookup_enabled, + 'SkipSmsToLandlines' => skip_sms_to_landlines, + 'DtmfInputRequired' => dtmf_input_required, + 'TtsName' => tts_name, + 'Psd2Enabled' => psd2_enabled, + 'DoNotShareWarningEnabled' => do_not_share_warning_enabled, + 'CustomCodeEnabled' => custom_code_enabled, + 'Push.IncludeDate' => push_include_date, + 'Push.ApnCredentialSid' => push_apn_credential_sid, + 'Push.FcmCredentialSid' => push_fcm_credential_sid, + 'Totp.Issuer' => totp_issuer, + 'Totp.TimeStep' => totp_time_step, + 'Totp.CodeLength' => totp_code_length, + 'Totp.Skew' => totp_skew, + 'DefaultTemplateSid' => default_template_sid, + 'Whatsapp.MsgServiceSid' => whatsapp_msg_service_sid, + 'Whatsapp.From' => whatsapp_from, + 'Passkeys.RelyingParty.Id' => passkeys_relying_party_id, + 'Passkeys.RelyingParty.Name' => passkeys_relying_party_name, + 'Passkeys.RelyingParty.Origins' => passkeys_relying_party_origins, + 'Passkeys.AuthenticatorAttachment' => passkeys_authenticator_attachment, + 'Passkeys.DiscoverableCredentials' => passkeys_discoverable_credentials, + 'Passkeys.UserVerification' => passkeys_user_verification, + 'VerifyEventSubscriptionEnabled' => verify_event_subscription_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + service_instance = ServiceInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ServiceInstanceMetadata.new( + @version, + service_instance, + response.headers, + response.status_code + ) + end + ## # Access the verification_checks # @return [VerificationCheckList] @@ -569,6 +848,45 @@ def inspect end end + class ServiceInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ServiceInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ServiceInstance] service_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ServiceInstanceMetadata] The initialized instance with metadata. + def initialize(version, service_instance, headers, status_code) + super(version, headers, status_code) + @service_instance = service_instance + end + + def service + @service_instance + end + + def to_s + "" + end + end + + class ServiceListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service_instance = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service_instance + @instance + end + end + class ServicePage < Page ## # Initialize the ServicePage @@ -597,6 +915,54 @@ def to_s '' end end + + class ServicePageMetadata < PageMetadata + attr_reader :service_page + + def initialize(version, response, solution, limit) + super(version, response) + @service_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @service_page << ServiceListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @service_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ServiceListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @service = payload.body[key].map do |data| + ServiceInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def service + @service + end + end + class ServiceInstance < InstanceResource ## # Initialize the ServiceInstance 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 ca884d406..f7482e1c9 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/access_token.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/access_token.rb @@ -67,6 +67,47 @@ def create( ) end + ## + # Create the AccessTokenInstanceMetadata + # @param [String] identity The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user's UUID, GUID, or SID. + # @param [FactorTypes] factor_type + # @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_with_metadata( + 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, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + accessToken_instance = AccessTokenInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + AccessTokenInstanceMetadata.new( + @version, + accessToken_instance, + response.headers, + response.status_code + ) + end + @@ -113,6 +154,32 @@ def fetch ) end + ## + # Fetch the AccessTokenInstanceMetadata + # @return [AccessTokenInstance] Fetched AccessTokenInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + accessToken_instance = AccessTokenInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + AccessTokenInstanceMetadata.new( + @version, + accessToken_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -129,6 +196,45 @@ def inspect end end + class AccessTokenInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AccessTokenInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AccessTokenInstance] access_token_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AccessTokenInstanceMetadata] The initialized instance with metadata. + def initialize(version, access_token_instance, headers, status_code) + super(version, headers, status_code) + @access_token_instance = access_token_instance + end + + def access_token + @access_token_instance + end + + def to_s + "" + end + end + + class AccessTokenListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @access_token_instance = payload.body[key].map do |data| + AccessTokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def access_token_instance + @instance + end + end + class AccessTokenPage < Page ## # Initialize the AccessTokenPage @@ -157,6 +263,54 @@ def to_s '' end end + + class AccessTokenPageMetadata < PageMetadata + attr_reader :access_token_page + + def initialize(version, response, solution, limit) + super(version, response) + @access_token_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @access_token_page << AccessTokenListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @access_token_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AccessTokenListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @access_token = payload.body[key].map do |data| + AccessTokenInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def access_token + @access_token + end + end + class AccessTokenInstance < InstanceResource ## # Initialize the AccessTokenInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/approve_challenge.rb b/lib/twilio-ruby/rest/verify/v2/service/approve_challenge.rb index befdb77c7..94b4b7335 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/approve_challenge.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/approve_challenge.rb @@ -101,6 +101,33 @@ def update(approve_passkeys_challenge_request: nil ) end + ## + # Update the ApproveChallengeInstanceMetadata + # @param [ApprovePasskeysChallengeRequest] approve_passkeys_challenge_request + # @return [ApproveChallengeInstance] Updated ApproveChallengeInstance + def update_with_metadata(approve_passkeys_challenge_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers, data: approve_passkeys_challenge_request.to_json) + approveChallenge_instance = ApproveChallengeInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + ApproveChallengeInstanceMetadata.new( + @version, + approveChallenge_instance, + response.headers, + response.status_code + ) + end + @@ -138,6 +165,54 @@ def to_s '' end end + + class ApproveChallengePageMetadata < PageMetadata + attr_reader :approve_challenge_page + + def initialize(version, response, solution, limit) + super(version, response) + @approve_challenge_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @approve_challenge_page << ApproveChallengeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @approve_challenge_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ApproveChallengeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @approve_challenge = payload.body[key].map do |data| + ApproveChallengeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def approve_challenge + @approve_challenge + end + end + class ApproveChallengeInstance < InstanceResource ## # Initialize the ApproveChallengeInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/entity.rb b/lib/twilio-ruby/rest/verify/v2/service/entity.rb index 46b1d2aea..d0161ab99 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/entity.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/entity.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the EntityInstanceMetadata + # @param [String] identity The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters. + # @return [EntityInstance] Created EntityInstance + def create_with_metadata( + identity: nil + ) + + data = Twilio::Values.of({ + 'Identity' => identity, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + entity_instance = EntityInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + EntityInstanceMetadata.new( + @version, + entity_instance, + response.headers, + response.status_code + ) + end + ## # Lists EntityInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists EntityPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + EntityPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields EntityInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -183,7 +237,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the EntityInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + entity_instance = EntityInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + EntityInstanceMetadata.new(@version, entity_instance, response.headers, response.status_code) end ## @@ -206,6 +279,32 @@ def fetch ) end + ## + # Fetch the EntityInstanceMetadata + # @return [EntityInstance] Fetched EntityInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + entity_instance = EntityInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + ) + EntityInstanceMetadata.new( + @version, + entity_instance, + response.headers, + response.status_code + ) + end + ## # Access the new_factors # @return [NewFactorList] @@ -271,6 +370,45 @@ def inspect end end + class EntityInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new EntityInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}EntityInstance] entity_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [EntityInstanceMetadata] The initialized instance with metadata. + def initialize(version, entity_instance, headers, status_code) + super(version, headers, status_code) + @entity_instance = entity_instance + end + + def entity + @entity_instance + end + + def to_s + "" + end + end + + class EntityListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @entity_instance = payload.body[key].map do |data| + EntityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def entity_instance + @instance + end + end + class EntityPage < Page ## # Initialize the EntityPage @@ -299,6 +437,54 @@ def to_s '' end end + + class EntityPageMetadata < PageMetadata + attr_reader :entity_page + + def initialize(version, response, solution, limit) + super(version, response) + @entity_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @entity_page << EntityListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @entity_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class EntityListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @entity = payload.body[key].map do |data| + EntityInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def entity + @entity + end + end + class EntityInstance < InstanceResource ## # Initialize the EntityInstance 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 dd261647b..d1cbf9de1 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb @@ -75,6 +75,54 @@ def create( ) end + ## + # Create the ChallengeInstanceMetadata + # @param [String] factor_sid The unique SID identifier of the Factor. + # @param [Time] expiration_date The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation. + # @param [String] details_message Shown to the user when the push notification arrives. Required when `factor_type` is `push`. Can be up to 256 characters in length + # @param [Array[Hash]] details_fields A list of objects that describe the Fields included in the Challenge. Each object contains the label and value of the field, the label can be up to 36 characters in length and the value can be up to 128 characters in length. Used when `factor_type` is `push`. There can be up to 20 details fields. + # @param [Object] hidden_details Details provided to give context about the Challenge. Not shown to the end user. It must be a stringified JSON with only strings values eg. `{\\\"ip\\\": \\\"172.168.1.234\\\"}`. Can be up to 1024 characters in length + # @param [String] auth_payload Optional payload used to verify the Challenge upon creation. Only used with a Factor of type `totp` to carry the TOTP code that needs to be verified. For `TOTP` this value must be between 3 and 8 characters long. + # @return [ChallengeInstance] Created ChallengeInstance + def create_with_metadata( + factor_sid: nil, + expiration_date: :unset, + details_message: :unset, + details_fields: :unset, + hidden_details: :unset, + auth_payload: :unset + ) + + data = Twilio::Values.of({ + 'FactorSid' => factor_sid, + 'ExpirationDate' => Twilio.serialize_iso8601_datetime(expiration_date), + 'Details.Message' => details_message, + 'Details.Fields' => Twilio.serialize_list(details_fields) { |e| Twilio.serialize_object(e) }, + 'HiddenDetails' => Twilio.serialize_object(hidden_details), + 'AuthPayload' => auth_payload, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + challenge_instance = ChallengeInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + ) + ChallengeInstanceMetadata.new( + @version, + challenge_instance, + response.headers, + response.status_code + ) + end + ## # Lists ChallengeInstance records from the API as a list. @@ -126,6 +174,34 @@ def stream(factor_sid: :unset, status: :unset, order: :unset, limit: nil, page_s @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ChallengePageMetadata records from the API as a list. + # @param [String] factor_sid The unique SID identifier of the Factor. + # @param [ChallengeStatuses] status The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`. + # @param [ListOrders] order The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`. + # @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_with_metadata(factor_sid: :unset, status: :unset, order: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FactorSid' => factor_sid, + 'Status' => status, + 'Order' => order, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ChallengePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ChallengeInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -229,6 +305,33 @@ def fetch ) end + ## + # Fetch the ChallengeInstanceMetadata + # @return [ChallengeInstance] Fetched ChallengeInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + challenge_instance = ChallengeInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + sid: @solution[:sid], + ) + ChallengeInstanceMetadata.new( + @version, + challenge_instance, + response.headers, + response.status_code + ) + end + ## # Update the ChallengeInstance # @param [String] auth_payload The optional payload needed to verify the 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 @@ -260,6 +363,43 @@ def update( ) end + ## + # Update the ChallengeInstanceMetadata + # @param [String] auth_payload The optional payload needed to verify the 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 [Object] 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_with_metadata( + auth_payload: :unset, + metadata: :unset + ) + + data = Twilio::Values.of({ + 'AuthPayload' => auth_payload, + 'Metadata' => Twilio.serialize_object(metadata), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + challenge_instance = ChallengeInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + sid: @solution[:sid], + ) + ChallengeInstanceMetadata.new( + @version, + challenge_instance, + response.headers, + response.status_code + ) + end + ## # Access the notifications # @return [NotificationList] @@ -287,6 +427,45 @@ def inspect end end + class ChallengeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ChallengeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ChallengeInstance] challenge_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ChallengeInstanceMetadata] The initialized instance with metadata. + def initialize(version, challenge_instance, headers, status_code) + super(version, headers, status_code) + @challenge_instance = challenge_instance + end + + def challenge + @challenge_instance + end + + def to_s + "" + end + end + + class ChallengeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @challenge_instance = payload.body[key].map do |data| + ChallengeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def challenge_instance + @instance + end + end + class ChallengePage < Page ## # Initialize the ChallengePage @@ -315,6 +494,54 @@ def to_s '' end end + + class ChallengePageMetadata < PageMetadata + attr_reader :challenge_page + + def initialize(version, response, solution, limit) + super(version, response) + @challenge_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @challenge_page << ChallengeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @challenge_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ChallengeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @challenge = payload.body[key].map do |data| + ChallengeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def challenge + @challenge + end + end + class ChallengeInstance < InstanceResource ## # Initialize the ChallengeInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb b/lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb index 15127a5c4..e663a64e9 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb @@ -62,6 +62,40 @@ def create( ) end + ## + # Create the NotificationInstanceMetadata + # @param [String] ttl How long, in seconds, the notification is valid. Can be an integer between 0 and 300. Default is 300. Delivery is attempted until the TTL elapses, even if the device is offline. 0 means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. + # @return [NotificationInstance] Created NotificationInstance + def create_with_metadata( + ttl: :unset + ) + + data = Twilio::Values.of({ + 'Ttl' => ttl, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + notification_instance = NotificationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + challenge_sid: @solution[:challenge_sid], + ) + NotificationInstanceMetadata.new( + @version, + notification_instance, + response.headers, + response.status_code + ) + end + @@ -99,6 +133,54 @@ def to_s '' end end + + class NotificationPageMetadata < PageMetadata + attr_reader :notification_page + + def initialize(version, response, solution, limit) + super(version, response) + @notification_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @notification_page << NotificationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @notification_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NotificationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @notification = payload.body[key].map do |data| + NotificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def notification + @notification + end + end + class NotificationInstance < InstanceResource ## # Initialize the NotificationInstance 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 ee5b6d806..4c3bf7a7c 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists FactorPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + FactorPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields FactorInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,7 +178,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the FactorInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + factor_instance = FactorInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + FactorInstanceMetadata.new(@version, factor_instance, response.headers, response.status_code) end ## @@ -180,6 +221,33 @@ def fetch ) end + ## + # Fetch the FactorInstanceMetadata + # @return [FactorInstance] Fetched FactorInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + factor_instance = FactorInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + sid: @solution[:sid], + ) + FactorInstanceMetadata.new( + @version, + factor_instance, + response.headers, + response.status_code + ) + end + ## # Update the FactorInstance # @param [String] auth_payload The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code. @@ -232,6 +300,64 @@ def update( ) end + ## + # Update the FactorInstanceMetadata + # @param [String] auth_payload The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code. + # @param [String] friendly_name The new friendly name of this Factor. It can be up to 64 characters. + # @param [String] config_notification_token For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Required when `factor_type` is `push`. If specified, this value must be between 32 and 255 characters long. + # @param [String] config_sdk_version The Verify Push SDK version used to configure the factor + # @param [String] config_time_step Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive + # @param [String] config_skew The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive + # @param [String] config_code_length Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive + # @param [TotpAlgorithms] config_alg + # @param [String] config_notification_platform The transport technology used to generate the Notification Token. Can be `apn`, `fcm` or `none`. Required when `factor_type` is `push`. + # @return [FactorInstance] Updated FactorInstance + def update_with_metadata( + auth_payload: :unset, + friendly_name: :unset, + config_notification_token: :unset, + config_sdk_version: :unset, + config_time_step: :unset, + config_skew: :unset, + config_code_length: :unset, + config_alg: :unset, + config_notification_platform: :unset + ) + + data = Twilio::Values.of({ + 'AuthPayload' => auth_payload, + 'FriendlyName' => friendly_name, + 'Config.NotificationToken' => config_notification_token, + 'Config.SdkVersion' => config_sdk_version, + 'Config.TimeStep' => config_time_step, + 'Config.Skew' => config_skew, + 'Config.CodeLength' => config_code_length, + 'Config.Alg' => config_alg, + 'Config.NotificationPlatform' => config_notification_platform, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + factor_instance = FactorInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + sid: @solution[:sid], + ) + FactorInstanceMetadata.new( + @version, + factor_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -248,6 +374,45 @@ def inspect end end + class FactorInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new FactorInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}FactorInstance] factor_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [FactorInstanceMetadata] The initialized instance with metadata. + def initialize(version, factor_instance, headers, status_code) + super(version, headers, status_code) + @factor_instance = factor_instance + end + + def factor + @factor_instance + end + + def to_s + "" + end + end + + class FactorListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @factor_instance = payload.body[key].map do |data| + FactorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def factor_instance + @instance + end + end + class FactorPage < Page ## # Initialize the FactorPage @@ -276,6 +441,54 @@ def to_s '' end end + + class FactorPageMetadata < PageMetadata + attr_reader :factor_page + + def initialize(version, response, solution, limit) + super(version, response) + @factor_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @factor_page << FactorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @factor_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class FactorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @factor = payload.body[key].map do |data| + FactorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def factor + @factor + end + end + class FactorInstance < InstanceResource ## # Initialize the FactorInstance 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 0700b0762..9f55e2a1c 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 @@ -99,6 +99,78 @@ def create( ) end + ## + # Create the NewFactorInstanceMetadata + # @param [String] friendly_name The friendly name of this Factor. This can be any string up to 64 characters, meant for humans to distinguish between Factors. For `factor_type` `push`, this could be a device name. For `factor_type` `totp`, this value is used as the “account name” in constructing the `binding.uri` property. At the same time, we recommend avoiding providing PII. + # @param [FactorTypes] factor_type + # @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 format encoded in Base64. Required when `factor_type` is `push` + # @param [String] config_app_id The ID that uniquely identifies your app in the Google or Apple store, such as `com.example.myapp`. It can be up to 100 characters long. Required when `factor_type` is `push`. + # @param [NotificationPlatforms] config_notification_platform + # @param [String] config_notification_token For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Must be between 32 and 255 characters long. Required when `factor_type` is `push`. + # @param [String] config_sdk_version The Verify Push SDK version used to configure the factor Required when `factor_type` is `push` + # @param [String] binding_secret The shared secret for TOTP factors encoded in Base32. This can be provided when creating the Factor, otherwise it will be generated. Used when `factor_type` is `totp` + # @param [String] config_time_step Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. The default value is defined at the service level in the property `totp.time_step`. Defaults to 30 seconds if not configured. Used when `factor_type` is `totp` + # @param [String] config_skew The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. The default value is defined at the service level in the property `totp.skew`. If not configured defaults to 1. Used when `factor_type` is `totp` + # @param [String] config_code_length Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. The default value is defined at the service level in the property `totp.code_length`. If not configured defaults to 6. Used when `factor_type` is `totp` + # @param [TotpAlgorithms] config_alg + # @param [Object] 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_with_metadata( + 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, + 'Binding.Alg' => binding_alg, + 'Binding.PublicKey' => binding_public_key, + 'Config.AppId' => config_app_id, + 'Config.NotificationPlatform' => config_notification_platform, + 'Config.NotificationToken' => config_notification_token, + 'Config.SdkVersion' => config_sdk_version, + 'Binding.Secret' => binding_secret, + 'Config.TimeStep' => config_time_step, + 'Config.Skew' => config_skew, + 'Config.CodeLength' => config_code_length, + 'Config.Alg' => config_alg, + 'Metadata' => Twilio.serialize_object(metadata), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + newFactor_instance = NewFactorInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + identity: @solution[:identity], + ) + NewFactorInstanceMetadata.new( + @version, + newFactor_instance, + response.headers, + response.status_code + ) + end + @@ -136,6 +208,54 @@ def to_s '' end end + + class NewFactorPageMetadata < PageMetadata + attr_reader :new_factor_page + + def initialize(version, response, solution, limit) + super(version, response) + @new_factor_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @new_factor_page << NewFactorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @new_factor_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NewFactorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_factor = payload.body[key].map do |data| + NewFactorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_factor + @new_factor + end + end + class NewFactorInstance < InstanceResource ## # Initialize the NewFactorInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/messaging_configuration.rb b/lib/twilio-ruby/rest/verify/v2/service/messaging_configuration.rb index 73ca74e10..e0f78062c 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/messaging_configuration.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/messaging_configuration.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the MessagingConfigurationInstanceMetadata + # @param [String] country The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`. + # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. + # @return [MessagingConfigurationInstance] Created MessagingConfigurationInstance + def create_with_metadata( + country: nil, + messaging_service_sid: nil + ) + + data = Twilio::Values.of({ + 'Country' => country, + 'MessagingServiceSid' => messaging_service_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + messagingConfiguration_instance = MessagingConfigurationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + MessagingConfigurationInstanceMetadata.new( + @version, + messagingConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Lists MessagingConfigurationInstance records from the API as a list. @@ -100,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists MessagingConfigurationPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + MessagingConfigurationPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields MessagingConfigurationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -183,7 +240,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the MessagingConfigurationInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + messagingConfiguration_instance = MessagingConfigurationInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + MessagingConfigurationInstanceMetadata.new(@version, messagingConfiguration_instance, response.headers, response.status_code) end ## @@ -206,6 +282,32 @@ def fetch ) end + ## + # Fetch the MessagingConfigurationInstanceMetadata + # @return [MessagingConfigurationInstance] Fetched MessagingConfigurationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + messagingConfiguration_instance = MessagingConfigurationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + country: @solution[:country], + ) + MessagingConfigurationInstanceMetadata.new( + @version, + messagingConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Update the MessagingConfigurationInstance # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. @@ -233,6 +335,39 @@ def update( ) end + ## + # Update the MessagingConfigurationInstanceMetadata + # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. + # @return [MessagingConfigurationInstance] Updated MessagingConfigurationInstance + def update_with_metadata( + messaging_service_sid: nil + ) + + data = Twilio::Values.of({ + 'MessagingServiceSid' => messaging_service_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + messagingConfiguration_instance = MessagingConfigurationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + country: @solution[:country], + ) + MessagingConfigurationInstanceMetadata.new( + @version, + messagingConfiguration_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -249,6 +384,45 @@ def inspect end end + class MessagingConfigurationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new MessagingConfigurationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}MessagingConfigurationInstance] messaging_configuration_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [MessagingConfigurationInstanceMetadata] The initialized instance with metadata. + def initialize(version, messaging_configuration_instance, headers, status_code) + super(version, headers, status_code) + @messaging_configuration_instance = messaging_configuration_instance + end + + def messaging_configuration + @messaging_configuration_instance + end + + def to_s + "" + end + end + + class MessagingConfigurationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @messaging_configuration_instance = payload.body[key].map do |data| + MessagingConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def messaging_configuration_instance + @instance + end + end + class MessagingConfigurationPage < Page ## # Initialize the MessagingConfigurationPage @@ -277,6 +451,54 @@ def to_s '' end end + + class MessagingConfigurationPageMetadata < PageMetadata + attr_reader :messaging_configuration_page + + def initialize(version, response, solution, limit) + super(version, response) + @messaging_configuration_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @messaging_configuration_page << MessagingConfigurationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @messaging_configuration_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class MessagingConfigurationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @messaging_configuration = payload.body[key].map do |data| + MessagingConfigurationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def messaging_configuration + @messaging_configuration + end + end + class MessagingConfigurationInstance < InstanceResource ## # Initialize the MessagingConfigurationInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/new_challenge.rb b/lib/twilio-ruby/rest/verify/v2/service/new_challenge.rb index ff1cc21a8..2f657f447 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/new_challenge.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/new_challenge.rb @@ -95,6 +95,33 @@ def create(create_passkeys_challenge_request: nil ) end + ## + # Create the NewChallengeInstanceMetadata + # @param [CreatePasskeysChallengeRequest] create_passkeys_challenge_request + # @return [NewChallengeInstance] Created NewChallengeInstance + def create_with_metadata(create_passkeys_challenge_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: create_passkeys_challenge_request.to_json) + newChallenge_instance = NewChallengeInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + NewChallengeInstanceMetadata.new( + @version, + newChallenge_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -111,6 +138,45 @@ def inspect end end + class NewChallengeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new NewChallengeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}NewChallengeInstance] new_challenge_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [NewChallengeInstanceMetadata] The initialized instance with metadata. + def initialize(version, new_challenge_instance, headers, status_code) + super(version, headers, status_code) + @new_challenge_instance = new_challenge_instance + end + + def new_challenge + @new_challenge_instance + end + + def to_s + "" + end + end + + class NewChallengeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_challenge_instance = payload.body[key].map do |data| + NewChallengeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_challenge_instance + @instance + end + end + class NewChallengePage < Page ## # Initialize the NewChallengePage @@ -139,6 +205,54 @@ def to_s '' end end + + class NewChallengePageMetadata < PageMetadata + attr_reader :new_challenge_page + + def initialize(version, response, solution, limit) + super(version, response) + @new_challenge_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @new_challenge_page << NewChallengeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @new_challenge_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NewChallengeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_challenge = payload.body[key].map do |data| + NewChallengeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_challenge + @new_challenge + end + end + class NewChallengeInstance < InstanceResource ## # Initialize the NewChallengeInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/new_factor.rb b/lib/twilio-ruby/rest/verify/v2/service/new_factor.rb index 02912709c..4c250ffdd 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/new_factor.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/new_factor.rb @@ -114,6 +114,33 @@ def create(create_new_passkeys_factor_request: nil ) end + ## + # Create the NewFactorInstanceMetadata + # @param [CreateNewPasskeysFactorRequest] create_new_passkeys_factor_request + # @return [NewFactorInstance] Created NewFactorInstance + def create_with_metadata(create_new_passkeys_factor_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.create_with_metadata('POST', @uri, headers: headers, data: create_new_passkeys_factor_request.to_json) + newFactor_instance = NewFactorInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + NewFactorInstanceMetadata.new( + @version, + newFactor_instance, + response.headers, + response.status_code + ) + end + @@ -151,6 +178,54 @@ def to_s '' end end + + class NewFactorPageMetadata < PageMetadata + attr_reader :new_factor_page + + def initialize(version, response, solution, limit) + super(version, response) + @new_factor_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @new_factor_page << NewFactorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @new_factor_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NewFactorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_factor = payload.body[key].map do |data| + NewFactorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_factor + @new_factor + end + end + class NewFactorInstance < InstanceResource ## # Initialize the NewFactorInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/new_verify_factor.rb b/lib/twilio-ruby/rest/verify/v2/service/new_verify_factor.rb index 6111d0399..807fd671c 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/new_verify_factor.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/new_verify_factor.rb @@ -98,6 +98,33 @@ def update(verify_passkeys_factor_request: nil ) end + ## + # Update the NewVerifyFactorInstanceMetadata + # @param [VerifyPasskeysFactorRequest] verify_passkeys_factor_request + # @return [NewVerifyFactorInstance] Updated NewVerifyFactorInstance + def update_with_metadata(verify_passkeys_factor_request: nil + ) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + headers['Content-Type'] = 'application/json' + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers, data: verify_passkeys_factor_request.to_json) + newVerifyFactor_instance = NewVerifyFactorInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + NewVerifyFactorInstanceMetadata.new( + @version, + newVerifyFactor_instance, + response.headers, + response.status_code + ) + end + @@ -135,6 +162,54 @@ def to_s '' end end + + class NewVerifyFactorPageMetadata < PageMetadata + attr_reader :new_verify_factor_page + + def initialize(version, response, solution, limit) + super(version, response) + @new_verify_factor_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @new_verify_factor_page << NewVerifyFactorListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @new_verify_factor_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class NewVerifyFactorListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @new_verify_factor = payload.body[key].map do |data| + NewVerifyFactorInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def new_verify_factor + @new_verify_factor + end + end + class NewVerifyFactorInstance < InstanceResource ## # Initialize the NewVerifyFactorInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/rate_limit.rb b/lib/twilio-ruby/rest/verify/v2/service/rate_limit.rb index 7efdd279b..5caa1cba5 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/rate_limit.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/rate_limit.rb @@ -61,6 +61,41 @@ def create( ) end + ## + # Create the RateLimitInstanceMetadata + # @param [String] unique_name Provides a unique and addressable name to be assigned to this Rate Limit, assigned by the developer, to be optionally used in addition to SID. **This value should not contain PII.** + # @param [String] description Description of this Rate Limit + # @return [RateLimitInstance] Created RateLimitInstance + def create_with_metadata( + unique_name: nil, + description: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + rateLimit_instance = RateLimitInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + RateLimitInstanceMetadata.new( + @version, + rateLimit_instance, + response.headers, + response.status_code + ) + end + ## # Lists RateLimitInstance records from the API as a list. @@ -100,6 +135,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RateLimitPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RateLimitPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RateLimitInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -184,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RateLimitInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + rateLimit_instance = RateLimitInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RateLimitInstanceMetadata.new(@version, rateLimit_instance, response.headers, response.status_code) end ## @@ -207,6 +283,32 @@ def fetch ) end + ## + # Fetch the RateLimitInstanceMetadata + # @return [RateLimitInstance] Fetched RateLimitInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + rateLimit_instance = RateLimitInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RateLimitInstanceMetadata.new( + @version, + rateLimit_instance, + response.headers, + response.status_code + ) + end + ## # Update the RateLimitInstance # @param [String] description Description of this Rate Limit @@ -234,6 +336,39 @@ def update( ) end + ## + # Update the RateLimitInstanceMetadata + # @param [String] description Description of this Rate Limit + # @return [RateLimitInstance] Updated RateLimitInstance + def update_with_metadata( + description: :unset + ) + + data = Twilio::Values.of({ + 'Description' => description, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + rateLimit_instance = RateLimitInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + RateLimitInstanceMetadata.new( + @version, + rateLimit_instance, + response.headers, + response.status_code + ) + end + ## # Access the buckets # @return [BucketList] @@ -269,6 +404,45 @@ def inspect end end + class RateLimitInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RateLimitInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RateLimitInstance] rate_limit_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RateLimitInstanceMetadata] The initialized instance with metadata. + def initialize(version, rate_limit_instance, headers, status_code) + super(version, headers, status_code) + @rate_limit_instance = rate_limit_instance + end + + def rate_limit + @rate_limit_instance + end + + def to_s + "" + end + end + + class RateLimitListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @rate_limit_instance = payload.body[key].map do |data| + RateLimitInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def rate_limit_instance + @instance + end + end + class RateLimitPage < Page ## # Initialize the RateLimitPage @@ -297,6 +471,54 @@ def to_s '' end end + + class RateLimitPageMetadata < PageMetadata + attr_reader :rate_limit_page + + def initialize(version, response, solution, limit) + super(version, response) + @rate_limit_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @rate_limit_page << RateLimitListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @rate_limit_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RateLimitListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @rate_limit = payload.body[key].map do |data| + RateLimitInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def rate_limit + @rate_limit + end + end + class RateLimitInstance < InstanceResource ## # Initialize the RateLimitInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb b/lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb index 604828323..7dbe86791 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb @@ -63,6 +63,42 @@ def create( ) end + ## + # Create the BucketInstanceMetadata + # @param [String] max Maximum number of requests permitted in during the interval. + # @param [String] interval Number of seconds that the rate limit will be enforced over. + # @return [BucketInstance] Created BucketInstance + def create_with_metadata( + max: nil, + interval: nil + ) + + data = Twilio::Values.of({ + 'Max' => max, + 'Interval' => interval, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + bucket_instance = BucketInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + rate_limit_sid: @solution[:rate_limit_sid], + ) + BucketInstanceMetadata.new( + @version, + bucket_instance, + response.headers, + response.status_code + ) + end + ## # Lists BucketInstance records from the API as a list. @@ -102,6 +138,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists BucketPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + BucketPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields BucketInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -186,7 +244,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the BucketInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + bucket_instance = BucketInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + BucketInstanceMetadata.new(@version, bucket_instance, response.headers, response.status_code) end ## @@ -210,6 +287,33 @@ def fetch ) end + ## + # Fetch the BucketInstanceMetadata + # @return [BucketInstance] Fetched BucketInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + bucket_instance = BucketInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + rate_limit_sid: @solution[:rate_limit_sid], + sid: @solution[:sid], + ) + BucketInstanceMetadata.new( + @version, + bucket_instance, + response.headers, + response.status_code + ) + end + ## # Update the BucketInstance # @param [String] max Maximum number of requests permitted in during the interval. @@ -241,6 +345,43 @@ def update( ) end + ## + # Update the BucketInstanceMetadata + # @param [String] max Maximum number of requests permitted in during the interval. + # @param [String] interval Number of seconds that the rate limit will be enforced over. + # @return [BucketInstance] Updated BucketInstance + def update_with_metadata( + max: :unset, + interval: :unset + ) + + data = Twilio::Values.of({ + 'Max' => max, + 'Interval' => interval, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + bucket_instance = BucketInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + rate_limit_sid: @solution[:rate_limit_sid], + sid: @solution[:sid], + ) + BucketInstanceMetadata.new( + @version, + bucket_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -257,6 +398,45 @@ def inspect end end + class BucketInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new BucketInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}BucketInstance] bucket_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [BucketInstanceMetadata] The initialized instance with metadata. + def initialize(version, bucket_instance, headers, status_code) + super(version, headers, status_code) + @bucket_instance = bucket_instance + end + + def bucket + @bucket_instance + end + + def to_s + "" + end + end + + class BucketListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bucket_instance = payload.body[key].map do |data| + BucketInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bucket_instance + @instance + end + end + class BucketPage < Page ## # Initialize the BucketPage @@ -285,6 +465,54 @@ def to_s '' end end + + class BucketPageMetadata < PageMetadata + attr_reader :bucket_page + + def initialize(version, response, solution, limit) + super(version, response) + @bucket_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bucket_page << BucketListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bucket_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BucketListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bucket = payload.body[key].map do |data| + BucketInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bucket + @bucket + end + end + class BucketInstance < InstanceResource ## # Initialize the BucketInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/verification.rb b/lib/twilio-ruby/rest/verify/v2/service/verification.rb index a78e2a464..6cd55176d 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/verification.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/verification.rb @@ -109,6 +109,89 @@ def create( ) end + ## + # Create the VerificationInstanceMetadata + # @param [String] to The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + # @param [String] channel The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, `sna` or `auto`. + # @param [String] custom_friendly_name A custom user defined friendly name that overwrites the existing one in the verification message + # @param [String] custom_message The text of a custom message to use for the verification. + # @param [String] send_digits The digits to send after a phone call is answered, for example, to dial an extension. For more information, see the Programmable Voice documentation of [sendDigits](https://www.twilio.com/docs/voice/twiml/number#attributes-sendDigits). + # @param [String] locale Locale will automatically resolve based on phone number country code for SMS, WhatsApp, and call channel verifications. It will fallback to English or the template’s default translation if the selected translation is not available. This parameter will override the automatic locale resolution. [See supported languages and more information here](https://www.twilio.com/docs/verify/supported-languages). + # @param [String] custom_code A pre-generated code to use for verification. The code can be between 4 and 10 characters, inclusive. + # @param [String] amount The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. + # @param [String] payee The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. + # @param [Object] rate_limits The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. + # @param [Object] channel_configuration [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. + # @param [String] app_hash Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. + # @param [String] template_sid The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. + # @param [String] template_custom_substitutions A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. + # @param [String] device_ip Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. + # @param [Boolean] enable_sna_client_token An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. + # @param [RiskCheck] risk_check + # @param [String] tags A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message. The object may contain up to 10 tags. Keys and values can each be up to 128 characters in length. + # @return [VerificationInstance] Created VerificationInstance + def create_with_metadata( + to: nil, + channel: nil, + custom_friendly_name: :unset, + custom_message: :unset, + send_digits: :unset, + locale: :unset, + custom_code: :unset, + amount: :unset, + payee: :unset, + rate_limits: :unset, + channel_configuration: :unset, + app_hash: :unset, + template_sid: :unset, + template_custom_substitutions: :unset, + device_ip: :unset, + enable_sna_client_token: :unset, + risk_check: :unset, + tags: :unset + ) + + data = Twilio::Values.of({ + 'To' => to, + 'Channel' => channel, + 'CustomFriendlyName' => custom_friendly_name, + 'CustomMessage' => custom_message, + 'SendDigits' => send_digits, + 'Locale' => locale, + 'CustomCode' => custom_code, + 'Amount' => amount, + 'Payee' => payee, + 'RateLimits' => Twilio.serialize_object(rate_limits), + 'ChannelConfiguration' => Twilio.serialize_object(channel_configuration), + 'AppHash' => app_hash, + 'TemplateSid' => template_sid, + 'TemplateCustomSubstitutions' => template_custom_substitutions, + 'DeviceIp' => device_ip, + 'EnableSnaClientToken' => enable_sna_client_token, + 'RiskCheck' => risk_check, + 'Tags' => tags, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + verification_instance = VerificationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + VerificationInstanceMetadata.new( + @version, + verification_instance, + response.headers, + response.status_code + ) + end + @@ -155,6 +238,32 @@ def fetch ) end + ## + # Fetch the VerificationInstanceMetadata + # @return [VerificationInstance] Fetched VerificationInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + verification_instance = VerificationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + VerificationInstanceMetadata.new( + @version, + verification_instance, + response.headers, + response.status_code + ) + end + ## # Update the VerificationInstance # @param [Status] status @@ -182,6 +291,39 @@ def update( ) end + ## + # Update the VerificationInstanceMetadata + # @param [Status] status + # @return [VerificationInstance] Updated VerificationInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + verification_instance = VerificationInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + VerificationInstanceMetadata.new( + @version, + verification_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -198,6 +340,45 @@ def inspect end end + class VerificationInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new VerificationInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}VerificationInstance] verification_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [VerificationInstanceMetadata] The initialized instance with metadata. + def initialize(version, verification_instance, headers, status_code) + super(version, headers, status_code) + @verification_instance = verification_instance + end + + def verification + @verification_instance + end + + def to_s + "" + end + end + + class VerificationListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @verification_instance = payload.body[key].map do |data| + VerificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def verification_instance + @instance + end + end + class VerificationPage < Page ## # Initialize the VerificationPage @@ -226,6 +407,54 @@ def to_s '' end end + + class VerificationPageMetadata < PageMetadata + attr_reader :verification_page + + def initialize(version, response, solution, limit) + super(version, response) + @verification_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @verification_page << VerificationListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @verification_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VerificationListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @verification = payload.body[key].map do |data| + VerificationInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def verification + @verification + end + end + class VerificationInstance < InstanceResource ## # Initialize the VerificationInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb b/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb index f2b40c73e..c4df41f9b 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb @@ -73,6 +73,53 @@ def create( ) end + ## + # Create the VerificationCheckInstanceMetadata + # @param [String] code The 4-10 character string being verified. + # @param [String] to The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Either this parameter or the `verification_sid` must be specified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + # @param [String] verification_sid A SID that uniquely identifies the Verification Check. Either this parameter or the `to` phone number/[email](https://www.twilio.com/docs/verify/email) must be specified. + # @param [String] amount The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. + # @param [String] payee The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. + # @param [String] sna_client_token A sna client token received in sna url invocation response needs to be passed in Verification Check request and should match to get successful response. + # @return [VerificationCheckInstance] Created VerificationCheckInstance + def create_with_metadata( + code: :unset, + to: :unset, + verification_sid: :unset, + amount: :unset, + payee: :unset, + sna_client_token: :unset + ) + + data = Twilio::Values.of({ + 'Code' => code, + 'To' => to, + 'VerificationSid' => verification_sid, + 'Amount' => amount, + 'Payee' => payee, + 'SnaClientToken' => sna_client_token, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + verificationCheck_instance = VerificationCheckInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + VerificationCheckInstanceMetadata.new( + @version, + verificationCheck_instance, + response.headers, + response.status_code + ) + end + @@ -110,6 +157,54 @@ def to_s '' end end + + class VerificationCheckPageMetadata < PageMetadata + attr_reader :verification_check_page + + def initialize(version, response, solution, limit) + super(version, response) + @verification_check_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @verification_check_page << VerificationCheckListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @verification_check_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VerificationCheckListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @verification_check = payload.body[key].map do |data| + VerificationCheckInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def verification_check + @verification_check + end + end + class VerificationCheckInstance < InstanceResource ## # Initialize the VerificationCheckInstance diff --git a/lib/twilio-ruby/rest/verify/v2/service/webhook.rb b/lib/twilio-ruby/rest/verify/v2/service/webhook.rb index ff7a511f9..894c42223 100644 --- a/lib/twilio-ruby/rest/verify/v2/service/webhook.rb +++ b/lib/twilio-ruby/rest/verify/v2/service/webhook.rb @@ -70,6 +70,50 @@ def create( ) end + ## + # Create the WebhookInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the webhook. **This value should not contain PII.** + # @param [Array[String]] event_types The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied` + # @param [String] webhook_url The URL associated with this Webhook. + # @param [Status] status + # @param [Version] version + # @return [WebhookInstance] Created WebhookInstance + def create_with_metadata( + friendly_name: nil, + event_types: nil, + webhook_url: nil, + status: :unset, + version: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'EventTypes' => Twilio.serialize_list(event_types) { |e| e }, + 'WebhookUrl' => webhook_url, + 'Status' => status, + 'Version' => version, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Lists WebhookInstance records from the API as a list. @@ -109,6 +153,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists WebhookPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + WebhookPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields WebhookInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -192,7 +258,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the WebhookInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new(@version, webhook_instance, response.headers, response.status_code) end ## @@ -215,6 +300,32 @@ def fetch ) end + ## + # Fetch the WebhookInstanceMetadata + # @return [WebhookInstance] Fetched WebhookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Update the WebhookInstance # @param [String] friendly_name The string that you assigned to describe the webhook. **This value should not contain PII.** @@ -254,6 +365,51 @@ def update( ) end + ## + # Update the WebhookInstanceMetadata + # @param [String] friendly_name The string that you assigned to describe the webhook. **This value should not contain PII.** + # @param [Array[String]] event_types The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied` + # @param [String] webhook_url The URL associated with this Webhook. + # @param [Status] status + # @param [Version] version + # @return [WebhookInstance] Updated WebhookInstance + def update_with_metadata( + friendly_name: :unset, + event_types: :unset, + webhook_url: :unset, + status: :unset, + version: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'EventTypes' => Twilio.serialize_list(event_types) { |e| e }, + 'WebhookUrl' => webhook_url, + 'Status' => status, + 'Version' => version, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + webhook_instance = WebhookInstance.new( + @version, + response.body, + service_sid: @solution[:service_sid], + sid: @solution[:sid], + ) + WebhookInstanceMetadata.new( + @version, + webhook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -270,6 +426,45 @@ def inspect end end + class WebhookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new WebhookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}WebhookInstance] webhook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [WebhookInstanceMetadata] The initialized instance with metadata. + def initialize(version, webhook_instance, headers, status_code) + super(version, headers, status_code) + @webhook_instance = webhook_instance + end + + def webhook + @webhook_instance + end + + def to_s + "" + end + end + + class WebhookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook_instance = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook_instance + @instance + end + end + class WebhookPage < Page ## # Initialize the WebhookPage @@ -298,6 +493,54 @@ def to_s '' end end + + class WebhookPageMetadata < PageMetadata + attr_reader :webhook_page + + def initialize(version, response, solution, limit) + super(version, response) + @webhook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @webhook_page << WebhookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @webhook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class WebhookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @webhook = payload.body[key].map do |data| + WebhookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def webhook + @webhook + end + end + class WebhookInstance < InstanceResource ## # Initialize the WebhookInstance diff --git a/lib/twilio-ruby/rest/verify/v2/template.rb b/lib/twilio-ruby/rest/verify/v2/template.rb index c06d34c27..8845d56c3 100644 --- a/lib/twilio-ruby/rest/verify/v2/template.rb +++ b/lib/twilio-ruby/rest/verify/v2/template.rb @@ -73,6 +73,30 @@ def stream(friendly_name: :unset, limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TemplatePageMetadata records from the API as a list. + # @param [String] friendly_name String filter used to query templates with a given friendly name. + # @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_with_metadata(friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TemplatePageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TemplateInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -160,6 +184,54 @@ def to_s '' end end + + class TemplatePageMetadata < PageMetadata + attr_reader :template_page + + def initialize(version, response, solution, limit) + super(version, response) + @template_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @template_page << TemplateListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @template_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TemplateListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @template = payload.body[key].map do |data| + TemplateInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def template + @template + end + end + class TemplateInstance < InstanceResource ## # Initialize the TemplateInstance diff --git a/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb b/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb index d92eff935..140e8e5f5 100644 --- a/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb +++ b/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb @@ -101,6 +101,44 @@ def stream(date_created_after: :unset, date_created_before: :unset, channel_data @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists VerificationAttemptPageMetadata records from the API as a list. + # @param [Time] date_created_after Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + # @param [Time] date_created_before Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + # @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 [Channels] channel Filter used to query Verification Attempts by communication channel. + # @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 [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 + # 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_with_metadata(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) + 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, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + VerificationAttemptPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields VerificationAttemptInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -209,6 +247,31 @@ def fetch ) end + ## + # Fetch the VerificationAttemptInstanceMetadata + # @return [VerificationAttemptInstance] Fetched VerificationAttemptInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + verificationAttempt_instance = VerificationAttemptInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + VerificationAttemptInstanceMetadata.new( + @version, + verificationAttempt_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -225,6 +288,45 @@ def inspect end end + class VerificationAttemptInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new VerificationAttemptInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}VerificationAttemptInstance] verification_attempt_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [VerificationAttemptInstanceMetadata] The initialized instance with metadata. + def initialize(version, verification_attempt_instance, headers, status_code) + super(version, headers, status_code) + @verification_attempt_instance = verification_attempt_instance + end + + def verification_attempt + @verification_attempt_instance + end + + def to_s + "" + end + end + + class VerificationAttemptListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @verification_attempt_instance = payload.body[key].map do |data| + VerificationAttemptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def verification_attempt_instance + @instance + end + end + class VerificationAttemptPage < Page ## # Initialize the VerificationAttemptPage @@ -253,6 +355,54 @@ def to_s '' end end + + class VerificationAttemptPageMetadata < PageMetadata + attr_reader :verification_attempt_page + + def initialize(version, response, solution, limit) + super(version, response) + @verification_attempt_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @verification_attempt_page << VerificationAttemptListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @verification_attempt_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VerificationAttemptListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @verification_attempt = payload.body[key].map do |data| + VerificationAttemptInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def verification_attempt + @verification_attempt + end + end + class VerificationAttemptInstance < InstanceResource ## # Initialize the VerificationAttemptInstance diff --git a/lib/twilio-ruby/rest/verify/v2/verification_attempts_summary.rb b/lib/twilio-ruby/rest/verify/v2/verification_attempts_summary.rb index d73edacef..3acbf6153 100644 --- a/lib/twilio-ruby/rest/verify/v2/verification_attempts_summary.rb +++ b/lib/twilio-ruby/rest/verify/v2/verification_attempts_summary.rb @@ -93,6 +93,51 @@ def fetch( ) end + ## + # Fetch the VerificationAttemptsSummaryInstanceMetadata + # @param [String] verify_service_sid Filter used to consider only Verification Attempts of the given verify service on the summary aggregation. + # @param [Time] date_created_after Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + # @param [Time] date_created_before Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + # @param [String] country Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation. + # @param [Channels] channel Filter Verification Attempts considered on the summary aggregation by communication channel. + # @param [String] destination_prefix Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format. + # @return [VerificationAttemptsSummaryInstance] Fetched VerificationAttemptsSummaryInstance + def fetch_with_metadata( + verify_service_sid: :unset, + date_created_after: :unset, + date_created_before: :unset, + country: :unset, + channel: :unset, + destination_prefix: :unset + ) + + params = Twilio::Values.of({ + 'VerifyServiceSid' => verify_service_sid, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + 'Country' => country, + 'Channel' => channel, + 'DestinationPrefix' => destination_prefix, + }) + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, params: params, headers: headers) + verificationAttemptsSummary_instance = VerificationAttemptsSummaryInstance.new( + @version, + response.body, + ) + VerificationAttemptsSummaryInstanceMetadata.new( + @version, + verificationAttemptsSummary_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -109,6 +154,45 @@ def inspect end end + class VerificationAttemptsSummaryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new VerificationAttemptsSummaryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}VerificationAttemptsSummaryInstance] verification_attempts_summary_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [VerificationAttemptsSummaryInstanceMetadata] The initialized instance with metadata. + def initialize(version, verification_attempts_summary_instance, headers, status_code) + super(version, headers, status_code) + @verification_attempts_summary_instance = verification_attempts_summary_instance + end + + def verification_attempts_summary + @verification_attempts_summary_instance + end + + def to_s + "" + end + end + + class VerificationAttemptsSummaryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @verification_attempts_summary_instance = payload.body[key].map do |data| + VerificationAttemptsSummaryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def verification_attempts_summary_instance + @instance + end + end + class VerificationAttemptsSummaryPage < Page ## # Initialize the VerificationAttemptsSummaryPage @@ -137,6 +221,54 @@ def to_s '' end end + + class VerificationAttemptsSummaryPageMetadata < PageMetadata + attr_reader :verification_attempts_summary_page + + def initialize(version, response, solution, limit) + super(version, response) + @verification_attempts_summary_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @verification_attempts_summary_page << VerificationAttemptsSummaryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @verification_attempts_summary_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class VerificationAttemptsSummaryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @verification_attempts_summary = payload.body[key].map do |data| + VerificationAttemptsSummaryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def verification_attempts_summary + @verification_attempts_summary + end + end + class VerificationAttemptsSummaryInstance < InstanceResource ## # Initialize the VerificationAttemptsSummaryInstance diff --git a/lib/twilio-ruby/rest/video/v1/composition.rb b/lib/twilio-ruby/rest/video/v1/composition.rb index 681711296..d6bbb3db1 100644 --- a/lib/twilio-ruby/rest/video/v1/composition.rb +++ b/lib/twilio-ruby/rest/video/v1/composition.rb @@ -79,6 +79,61 @@ def create( ) end + ## + # Create the CompositionInstanceMetadata + # @param [String] room_sid The SID of the Group Room with the media tracks to be used as composition sources. + # @param [Object] video_layout An object that describes the video layout of the composition in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request + # @param [Array[String]] audio_sources An array of track names from the same group room to merge into the new composition. Can include zero or more track names. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` includes `student` as well as `studentTeam`. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request + # @param [Array[String]] audio_sources_excluded An array of track names to exclude. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty. + # @param [String] resolution A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @param [Format] format + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`. + # @param [Boolean] trim Whether to clip the intervals where there is no active media in the composition. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @return [CompositionInstance] Created CompositionInstance + def create_with_metadata( + room_sid: nil, + video_layout: :unset, + audio_sources: :unset, + audio_sources_excluded: :unset, + resolution: :unset, + format: :unset, + status_callback: :unset, + status_callback_method: :unset, + trim: :unset + ) + + data = Twilio::Values.of({ + 'RoomSid' => room_sid, + 'VideoLayout' => Twilio.serialize_object(video_layout), + 'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e }, + 'AudioSourcesExcluded' => Twilio.serialize_list(audio_sources_excluded) { |e| e }, + 'Resolution' => resolution, + 'Format' => format, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'Trim' => trim, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + composition_instance = CompositionInstance.new( + @version, + response.body, + ) + CompositionInstanceMetadata.new( + @version, + composition_instance, + response.headers, + response.status_code + ) + end + ## # Lists CompositionInstance records from the API as a list. @@ -134,6 +189,36 @@ def stream(status: :unset, date_created_after: :unset, date_created_before: :uns @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CompositionPageMetadata records from the API as a list. + # @param [Status] status Read only Composition resources with this status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`. + # @param [Time] date_created_after Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone. + # @param [Time] date_created_before Read only Composition resources created before this ISO 8601 date-time with time zone. + # @param [String] room_sid Read only Composition resources with this Room SID. + # @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_with_metadata(status: :unset, date_created_after: :unset, date_created_before: :unset, room_sid: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + 'RoomSid' => room_sid, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CompositionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CompositionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -224,7 +309,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CompositionInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + composition_instance = CompositionInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CompositionInstanceMetadata.new(@version, composition_instance, response.headers, response.status_code) end ## @@ -246,6 +350,31 @@ def fetch ) end + ## + # Fetch the CompositionInstanceMetadata + # @return [CompositionInstance] Fetched CompositionInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + composition_instance = CompositionInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CompositionInstanceMetadata.new( + @version, + composition_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -262,6 +391,45 @@ def inspect end end + class CompositionInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CompositionInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CompositionInstance] composition_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CompositionInstanceMetadata] The initialized instance with metadata. + def initialize(version, composition_instance, headers, status_code) + super(version, headers, status_code) + @composition_instance = composition_instance + end + + def composition + @composition_instance + end + + def to_s + "" + end + end + + class CompositionListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @composition_instance = payload.body[key].map do |data| + CompositionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def composition_instance + @instance + end + end + class CompositionPage < Page ## # Initialize the CompositionPage @@ -290,6 +458,54 @@ def to_s '' end end + + class CompositionPageMetadata < PageMetadata + attr_reader :composition_page + + def initialize(version, response, solution, limit) + super(version, response) + @composition_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @composition_page << CompositionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @composition_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CompositionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @composition = payload.body[key].map do |data| + CompositionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def composition + @composition + end + end + class CompositionInstance < InstanceResource ## # Initialize the CompositionInstance diff --git a/lib/twilio-ruby/rest/video/v1/composition_hook.rb b/lib/twilio-ruby/rest/video/v1/composition_hook.rb index 1b677d0ba..17c753756 100644 --- a/lib/twilio-ruby/rest/video/v1/composition_hook.rb +++ b/lib/twilio-ruby/rest/video/v1/composition_hook.rb @@ -82,6 +82,64 @@ def create( ) end + ## + # Create the CompositionHookInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account. + # @param [Boolean] enabled Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook will never be triggered. + # @param [Object] video_layout An object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @param [Array[String]] audio_sources An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`. + # @param [Array[String]] audio_sources_excluded An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty. + # @param [String] resolution A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @param [Format] format + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`. + # @param [Boolean] trim Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @return [CompositionHookInstance] Created CompositionHookInstance + def create_with_metadata( + friendly_name: nil, + enabled: :unset, + video_layout: :unset, + audio_sources: :unset, + audio_sources_excluded: :unset, + resolution: :unset, + format: :unset, + status_callback: :unset, + status_callback_method: :unset, + trim: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Enabled' => enabled, + 'VideoLayout' => Twilio.serialize_object(video_layout), + 'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e }, + 'AudioSourcesExcluded' => Twilio.serialize_list(audio_sources_excluded) { |e| e }, + 'Resolution' => resolution, + 'Format' => format, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'Trim' => trim, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + compositionHook_instance = CompositionHookInstance.new( + @version, + response.body, + ) + CompositionHookInstanceMetadata.new( + @version, + compositionHook_instance, + response.headers, + response.status_code + ) + end + ## # Lists CompositionHookInstance records from the API as a list. @@ -137,6 +195,36 @@ def stream(enabled: :unset, date_created_after: :unset, date_created_before: :un @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CompositionHookPageMetadata records from the API as a list. + # @param [Boolean] enabled Read only CompositionHook resources with an `enabled` value that matches this parameter. + # @param [Time] date_created_after Read only CompositionHook resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone. + # @param [Time] date_created_before Read only CompositionHook resources created before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone. + # @param [String] friendly_name Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk `*` characters as wildcard match. + # @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_with_metadata(enabled: :unset, date_created_after: :unset, date_created_before: :unset, friendly_name: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Enabled' => enabled, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + 'FriendlyName' => friendly_name, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CompositionHookPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CompositionHookInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -227,7 +315,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CompositionHookInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + compositionHook_instance = CompositionHookInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CompositionHookInstanceMetadata.new(@version, compositionHook_instance, response.headers, response.status_code) end ## @@ -249,6 +356,31 @@ def fetch ) end + ## + # Fetch the CompositionHookInstanceMetadata + # @return [CompositionHookInstance] Fetched CompositionHookInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + compositionHook_instance = CompositionHookInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CompositionHookInstanceMetadata.new( + @version, + compositionHook_instance, + response.headers, + response.status_code + ) + end + ## # Update the CompositionHookInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account. @@ -302,6 +434,65 @@ def update( ) end + ## + # Update the CompositionHookInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account. + # @param [Boolean] enabled Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook never triggers. + # @param [Object] video_layout A JSON object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @param [Array[String]] audio_sources An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`. + # @param [Array[String]] audio_sources_excluded An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty. + # @param [Boolean] trim Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @param [Format] format + # @param [String] resolution A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`. + # @return [CompositionHookInstance] Updated CompositionHookInstance + def update_with_metadata( + friendly_name: nil, + enabled: :unset, + video_layout: :unset, + audio_sources: :unset, + audio_sources_excluded: :unset, + trim: :unset, + format: :unset, + resolution: :unset, + status_callback: :unset, + status_callback_method: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Enabled' => enabled, + 'VideoLayout' => Twilio.serialize_object(video_layout), + 'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e }, + 'AudioSourcesExcluded' => Twilio.serialize_list(audio_sources_excluded) { |e| e }, + 'Trim' => trim, + 'Format' => format, + 'Resolution' => resolution, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + compositionHook_instance = CompositionHookInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CompositionHookInstanceMetadata.new( + @version, + compositionHook_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -318,6 +509,45 @@ def inspect end end + class CompositionHookInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CompositionHookInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CompositionHookInstance] composition_hook_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CompositionHookInstanceMetadata] The initialized instance with metadata. + def initialize(version, composition_hook_instance, headers, status_code) + super(version, headers, status_code) + @composition_hook_instance = composition_hook_instance + end + + def composition_hook + @composition_hook_instance + end + + def to_s + "" + end + end + + class CompositionHookListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @composition_hook_instance = payload.body[key].map do |data| + CompositionHookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def composition_hook_instance + @instance + end + end + class CompositionHookPage < Page ## # Initialize the CompositionHookPage @@ -346,6 +576,54 @@ def to_s '' end end + + class CompositionHookPageMetadata < PageMetadata + attr_reader :composition_hook_page + + def initialize(version, response, solution, limit) + super(version, response) + @composition_hook_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @composition_hook_page << CompositionHookListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @composition_hook_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CompositionHookListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @composition_hook = payload.body[key].map do |data| + CompositionHookInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def composition_hook + @composition_hook + end + end + class CompositionHookInstance < InstanceResource ## # Initialize the CompositionHookInstance diff --git a/lib/twilio-ruby/rest/video/v1/composition_settings.rb b/lib/twilio-ruby/rest/video/v1/composition_settings.rb index 4a4c3f2c2..507a04b39 100644 --- a/lib/twilio-ruby/rest/video/v1/composition_settings.rb +++ b/lib/twilio-ruby/rest/video/v1/composition_settings.rb @@ -94,6 +94,52 @@ def create( ) end + ## + # Create the CompositionSettingsInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource and show to the user in the console + # @param [String] aws_credentials_sid The SID of the stored Credential resource. + # @param [String] encryption_key_sid The SID of the Public Key resource to use for encryption. + # @param [String] aws_s3_url The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). + # @param [Boolean] aws_storage_enabled Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud. + # @param [Boolean] encryption_enabled Whether all compositions should be stored in an encrypted form. The default is `false`. + # @return [CompositionSettingsInstance] Created CompositionSettingsInstance + def create_with_metadata( + friendly_name: nil, + aws_credentials_sid: :unset, + encryption_key_sid: :unset, + aws_s3_url: :unset, + aws_storage_enabled: :unset, + encryption_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'AwsCredentialsSid' => aws_credentials_sid, + 'EncryptionKeySid' => encryption_key_sid, + 'AwsS3Url' => aws_s3_url, + 'AwsStorageEnabled' => aws_storage_enabled, + 'EncryptionEnabled' => encryption_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + compositionSettings_instance = CompositionSettingsInstance.new( + @version, + response.body, + ) + CompositionSettingsInstanceMetadata.new( + @version, + compositionSettings_instance, + response.headers, + response.status_code + ) + end + ## # Fetch the CompositionSettingsInstance # @return [CompositionSettingsInstance] Fetched CompositionSettingsInstance @@ -112,6 +158,30 @@ def fetch ) end + ## + # Fetch the CompositionSettingsInstanceMetadata + # @return [CompositionSettingsInstance] Fetched CompositionSettingsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + compositionSettings_instance = CompositionSettingsInstance.new( + @version, + response.body, + ) + CompositionSettingsInstanceMetadata.new( + @version, + compositionSettings_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -128,6 +198,45 @@ def inspect end end + class CompositionSettingsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CompositionSettingsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CompositionSettingsInstance] composition_settings_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CompositionSettingsInstanceMetadata] The initialized instance with metadata. + def initialize(version, composition_settings_instance, headers, status_code) + super(version, headers, status_code) + @composition_settings_instance = composition_settings_instance + end + + def composition_settings + @composition_settings_instance + end + + def to_s + "" + end + end + + class CompositionSettingsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @composition_settings_instance = payload.body[key].map do |data| + CompositionSettingsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def composition_settings_instance + @instance + end + end + class CompositionSettingsPage < Page ## # Initialize the CompositionSettingsPage @@ -156,6 +265,54 @@ def to_s '' end end + + class CompositionSettingsPageMetadata < PageMetadata + attr_reader :composition_settings_page + + def initialize(version, response, solution, limit) + super(version, response) + @composition_settings_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @composition_settings_page << CompositionSettingsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @composition_settings_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CompositionSettingsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @composition_settings = payload.body[key].map do |data| + CompositionSettingsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def composition_settings + @composition_settings + end + end + class CompositionSettingsInstance < InstanceResource ## # Initialize the CompositionSettingsInstance diff --git a/lib/twilio-ruby/rest/video/v1/recording.rb b/lib/twilio-ruby/rest/video/v1/recording.rb index 7c6ac593d..8894abd60 100644 --- a/lib/twilio-ruby/rest/video/v1/recording.rb +++ b/lib/twilio-ruby/rest/video/v1/recording.rb @@ -93,6 +93,41 @@ def stream(status: :unset, source_sid: :unset, grouping_sid: :unset, date_create @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RecordingPageMetadata records from the API as a list. + # @param [Status] status Read only the recordings that have this status. Can be: `processing`, `completed`, or `deleted`. + # @param [String] source_sid Read only the recordings that have this `source_sid`. + # @param [Array[String]] grouping_sid Read only recordings with this `grouping_sid`, which may include a `participant_sid` and/or a `room_sid`. + # @param [Time] date_created_after Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone. + # @param [Time] date_created_before Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone, given as `YYYY-MM-DDThh:mm:ss+|-hh:mm` or `YYYY-MM-DDThh:mm:ssZ`. + # @param [Type] media_type Read only recordings that have this media type. Can be either `audio` or `video`. + # @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_with_metadata(status: :unset, source_sid: :unset, grouping_sid: :unset, date_created_after: :unset, date_created_before: :unset, media_type: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'SourceSid' => source_sid, + + 'GroupingSid' => Twilio.serialize_list(grouping_sid) { |e| e }, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + 'MediaType' => media_type, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RecordingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RecordingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -188,7 +223,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RecordingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new(@version, recording_instance, response.headers, response.status_code) end ## @@ -210,6 +264,31 @@ def fetch ) end + ## + # Fetch the RecordingInstanceMetadata + # @return [RecordingInstance] Fetched RecordingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + recording_instance = RecordingInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RecordingInstanceMetadata.new( + @version, + recording_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -226,6 +305,45 @@ def inspect end end + class RecordingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RecordingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RecordingInstance] recording_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RecordingInstanceMetadata] The initialized instance with metadata. + def initialize(version, recording_instance, headers, status_code) + super(version, headers, status_code) + @recording_instance = recording_instance + end + + def recording + @recording_instance + end + + def to_s + "" + end + end + + class RecordingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_instance = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_instance + @instance + end + end + class RecordingPage < Page ## # Initialize the RecordingPage @@ -254,6 +372,54 @@ def to_s '' end end + + class RecordingPageMetadata < PageMetadata + attr_reader :recording_page + + def initialize(version, response, solution, limit) + super(version, response) + @recording_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @recording_page << RecordingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @recording_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording = payload.body[key].map do |data| + RecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording + @recording + end + end + class RecordingInstance < InstanceResource ## # Initialize the RecordingInstance diff --git a/lib/twilio-ruby/rest/video/v1/recording_settings.rb b/lib/twilio-ruby/rest/video/v1/recording_settings.rb index c29281b40..7b59addf0 100644 --- a/lib/twilio-ruby/rest/video/v1/recording_settings.rb +++ b/lib/twilio-ruby/rest/video/v1/recording_settings.rb @@ -94,6 +94,52 @@ def create( ) end + ## + # Create the RecordingSettingsInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource and be shown to users in the console + # @param [String] aws_credentials_sid The SID of the stored Credential resource. + # @param [String] encryption_key_sid The SID of the Public Key resource to use for encryption. + # @param [String] aws_s3_url The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). + # @param [Boolean] aws_storage_enabled Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud. + # @param [Boolean] encryption_enabled Whether all recordings should be stored in an encrypted form. The default is `false`. + # @return [RecordingSettingsInstance] Created RecordingSettingsInstance + def create_with_metadata( + friendly_name: nil, + aws_credentials_sid: :unset, + encryption_key_sid: :unset, + aws_s3_url: :unset, + aws_storage_enabled: :unset, + encryption_enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'AwsCredentialsSid' => aws_credentials_sid, + 'EncryptionKeySid' => encryption_key_sid, + 'AwsS3Url' => aws_s3_url, + 'AwsStorageEnabled' => aws_storage_enabled, + 'EncryptionEnabled' => encryption_enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + recordingSettings_instance = RecordingSettingsInstance.new( + @version, + response.body, + ) + RecordingSettingsInstanceMetadata.new( + @version, + recordingSettings_instance, + response.headers, + response.status_code + ) + end + ## # Fetch the RecordingSettingsInstance # @return [RecordingSettingsInstance] Fetched RecordingSettingsInstance @@ -112,6 +158,30 @@ def fetch ) end + ## + # Fetch the RecordingSettingsInstanceMetadata + # @return [RecordingSettingsInstance] Fetched RecordingSettingsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + recordingSettings_instance = RecordingSettingsInstance.new( + @version, + response.body, + ) + RecordingSettingsInstanceMetadata.new( + @version, + recordingSettings_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -128,6 +198,45 @@ def inspect end end + class RecordingSettingsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RecordingSettingsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RecordingSettingsInstance] recording_settings_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RecordingSettingsInstanceMetadata] The initialized instance with metadata. + def initialize(version, recording_settings_instance, headers, status_code) + super(version, headers, status_code) + @recording_settings_instance = recording_settings_instance + end + + def recording_settings + @recording_settings_instance + end + + def to_s + "" + end + end + + class RecordingSettingsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_settings_instance = payload.body[key].map do |data| + RecordingSettingsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_settings_instance + @instance + end + end + class RecordingSettingsPage < Page ## # Initialize the RecordingSettingsPage @@ -156,6 +265,54 @@ def to_s '' end end + + class RecordingSettingsPageMetadata < PageMetadata + attr_reader :recording_settings_page + + def initialize(version, response, solution, limit) + super(version, response) + @recording_settings_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @recording_settings_page << RecordingSettingsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @recording_settings_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordingSettingsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_settings = payload.body[key].map do |data| + RecordingSettingsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_settings + @recording_settings + end + end + class RecordingSettingsInstance < InstanceResource ## # Initialize the RecordingSettingsInstance diff --git a/lib/twilio-ruby/rest/video/v1/room.rb b/lib/twilio-ruby/rest/video/v1/room.rb index fc4e7475c..e3386e1c6 100644 --- a/lib/twilio-ruby/rest/video/v1/room.rb +++ b/lib/twilio-ruby/rest/video/v1/room.rb @@ -103,6 +103,85 @@ def create( ) end + ## + # Create the RoomInstanceMetadata + # @param [Boolean] enable_turn Deprecated, now always considered to be true. + # @param [RoomType] type + # @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, 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 Twilio should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. + # @param [String] status_callback_method The HTTP method Twilio should use to call `status_callback`. Can be `POST` or `GET`. + # @param [String] max_participants The maximum number of concurrent Participants allowed in the room. The maximum allowed value is 50. + # @param [Boolean] record_participants_on_connect Whether to start recording when Participants connect. + # @param [Boolean] transcribe_participants_on_connect Whether to start transcriptions when Participants connect. If TranscriptionsConfiguration is not provided, default settings will be used. + # @param [Array[VideoCodec]] video_codecs An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. + # @param [String] media_region The region for the Room's media server. Can be one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). + # @param [Object] recording_rules A collection of Recording Rules that describe how to include or exclude matching tracks for recording + # @param [Object] transcriptions_configuration A collection of properties that describe transcription behaviour. If TranscribeParticipantsOnConnect is set to true and TranscriptionsConfiguration is not provided, default settings will be used. + # @param [Boolean] audio_only When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. + # @param [String] max_participant_duration The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours). + # @param [String] empty_room_timeout Configures how long (in minutes) a room will remain active after last participant leaves. Valid values range from 1 to 60 minutes (no fractions). + # @param [String] unused_room_timeout Configures how long (in minutes) a room will remain active if no one joins. Valid values range from 1 to 60 minutes (no fractions). + # @param [Boolean] large_room When set to true, indicated that this is the large room. + # @return [RoomInstance] Created RoomInstance + def create_with_metadata( + enable_turn: :unset, + type: :unset, + unique_name: :unset, + status_callback: :unset, + status_callback_method: :unset, + max_participants: :unset, + record_participants_on_connect: :unset, + transcribe_participants_on_connect: :unset, + video_codecs: :unset, + media_region: :unset, + recording_rules: :unset, + transcriptions_configuration: :unset, + audio_only: :unset, + max_participant_duration: :unset, + empty_room_timeout: :unset, + unused_room_timeout: :unset, + large_room: :unset + ) + + data = Twilio::Values.of({ + 'EnableTurn' => enable_turn, + 'Type' => type, + 'UniqueName' => unique_name, + 'StatusCallback' => status_callback, + 'StatusCallbackMethod' => status_callback_method, + 'MaxParticipants' => max_participants, + 'RecordParticipantsOnConnect' => record_participants_on_connect, + 'TranscribeParticipantsOnConnect' => transcribe_participants_on_connect, + 'VideoCodecs' => Twilio.serialize_list(video_codecs) { |e| e }, + 'MediaRegion' => media_region, + 'RecordingRules' => Twilio.serialize_object(recording_rules), + 'TranscriptionsConfiguration' => Twilio.serialize_object(transcriptions_configuration), + 'AudioOnly' => audio_only, + 'MaxParticipantDuration' => max_participant_duration, + 'EmptyRoomTimeout' => empty_room_timeout, + 'UnusedRoomTimeout' => unused_room_timeout, + 'LargeRoom' => large_room, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + room_instance = RoomInstance.new( + @version, + response.body, + ) + RoomInstanceMetadata.new( + @version, + room_instance, + response.headers, + response.status_code + ) + end + ## # Lists RoomInstance records from the API as a list. @@ -158,6 +237,36 @@ def stream(status: :unset, unique_name: :unset, date_created_after: :unset, date @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RoomPageMetadata records from the API as a list. + # @param [RoomStatus] status Read only the rooms with this status. Can be: `in-progress` (default) or `completed` + # @param [String] unique_name Read only rooms with the this `unique_name`. + # @param [Time] date_created_after Read only rooms that started on or after this date, given as `YYYY-MM-DD`. + # @param [Time] date_created_before Read only rooms that started before this date, given as `YYYY-MM-DD`. + # @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_with_metadata(status: :unset, unique_name: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'UniqueName' => unique_name, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RoomPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoomInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -262,6 +371,31 @@ def fetch ) end + ## + # Fetch the RoomInstanceMetadata + # @return [RoomInstance] Fetched RoomInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + room_instance = RoomInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RoomInstanceMetadata.new( + @version, + room_instance, + response.headers, + response.status_code + ) + end + ## # Update the RoomInstance # @param [RoomStatus] status @@ -288,6 +422,38 @@ def update( ) end + ## + # Update the RoomInstanceMetadata + # @param [RoomStatus] status + # @return [RoomInstance] Updated RoomInstance + def update_with_metadata( + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + room_instance = RoomInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RoomInstanceMetadata.new( + @version, + room_instance, + response.headers, + response.status_code + ) + end + ## # Access the recording_rules # @return [RecordingRulesList] @@ -372,6 +538,45 @@ def inspect end end + class RoomInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoomInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoomInstance] room_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoomInstanceMetadata] The initialized instance with metadata. + def initialize(version, room_instance, headers, status_code) + super(version, headers, status_code) + @room_instance = room_instance + end + + def room + @room_instance + end + + def to_s + "" + end + end + + class RoomListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @room_instance = payload.body[key].map do |data| + RoomInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def room_instance + @instance + end + end + class RoomPage < Page ## # Initialize the RoomPage @@ -400,6 +605,54 @@ def to_s '' end end + + class RoomPageMetadata < PageMetadata + attr_reader :room_page + + def initialize(version, response, solution, limit) + super(version, response) + @room_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @room_page << RoomListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @room_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoomListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @room = payload.body[key].map do |data| + RoomInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def room + @room + end + end + class RoomInstance < InstanceResource ## # Initialize the RoomInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/participant.rb b/lib/twilio-ruby/rest/video/v1/room/participant.rb index 80bbf8262..c5c59a8de 100644 --- a/lib/twilio-ruby/rest/video/v1/room/participant.rb +++ b/lib/twilio-ruby/rest/video/v1/room/participant.rb @@ -87,6 +87,36 @@ def stream(status: :unset, identity: :unset, date_created_after: :unset, date_cr @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ParticipantPageMetadata records from the API as a list. + # @param [Status] status Read only the participants with this status. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned. + # @param [String] identity Read only the Participants with this [User](https://www.twilio.com/docs/chat/rest/user-resource) `identity` value. + # @param [Time] date_created_after Read only Participants that started after this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format. + # @param [Time] date_created_before Read only Participants that started before this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format. + # @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_with_metadata(status: :unset, identity: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'Identity' => identity, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ParticipantPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ParticipantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -193,6 +223,32 @@ def fetch ) end + ## + # Fetch the ParticipantInstanceMetadata + # @return [ParticipantInstance] Fetched ParticipantInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Update the ParticipantInstance # @param [Status] status @@ -220,6 +276,39 @@ def update( ) end + ## + # Update the ParticipantInstanceMetadata + # @param [Status] status + # @return [ParticipantInstance] Updated ParticipantInstance + def update_with_metadata( + status: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + participant_instance = ParticipantInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + sid: @solution[:sid], + ) + ParticipantInstanceMetadata.new( + @version, + participant_instance, + response.headers, + response.status_code + ) + end + ## # Access the subscribe_rules # @return [SubscribeRulesList] @@ -296,6 +385,45 @@ def inspect end end + class ParticipantInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ParticipantInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ParticipantInstance] participant_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ParticipantInstanceMetadata] The initialized instance with metadata. + def initialize(version, participant_instance, headers, status_code) + super(version, headers, status_code) + @participant_instance = participant_instance + end + + def participant + @participant_instance + end + + def to_s + "" + end + end + + class ParticipantListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant_instance = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant_instance + @instance + end + end + class ParticipantPage < Page ## # Initialize the ParticipantPage @@ -324,6 +452,54 @@ def to_s '' end end + + class ParticipantPageMetadata < PageMetadata + attr_reader :participant_page + + def initialize(version, response, solution, limit) + super(version, response) + @participant_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @participant_page << ParticipantListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @participant_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ParticipantListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @participant = payload.body[key].map do |data| + ParticipantInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def participant + @participant + end + end + class ParticipantInstance < InstanceResource ## # Initialize the ParticipantInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/participant/anonymize.rb b/lib/twilio-ruby/rest/video/v1/room/participant/anonymize.rb index ca8fe9d64..8d4c71888 100644 --- a/lib/twilio-ruby/rest/video/v1/room/participant/anonymize.rb +++ b/lib/twilio-ruby/rest/video/v1/room/participant/anonymize.rb @@ -79,6 +79,32 @@ def update ) end + ## + # Update the AnonymizeInstanceMetadata + # @return [AnonymizeInstance] Updated AnonymizeInstance + def update_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, headers: headers) + anonymize_instance = AnonymizeInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + sid: @solution[:sid], + ) + AnonymizeInstanceMetadata.new( + @version, + anonymize_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -95,6 +121,45 @@ def inspect end end + class AnonymizeInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new AnonymizeInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}AnonymizeInstance] anonymize_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [AnonymizeInstanceMetadata] The initialized instance with metadata. + def initialize(version, anonymize_instance, headers, status_code) + super(version, headers, status_code) + @anonymize_instance = anonymize_instance + end + + def anonymize + @anonymize_instance + end + + def to_s + "" + end + end + + class AnonymizeListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @anonymize_instance = payload.body[key].map do |data| + AnonymizeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def anonymize_instance + @instance + end + end + class AnonymizePage < Page ## # Initialize the AnonymizePage @@ -123,6 +188,54 @@ def to_s '' end end + + class AnonymizePageMetadata < PageMetadata + attr_reader :anonymize_page + + def initialize(version, response, solution, limit) + super(version, response) + @anonymize_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @anonymize_page << AnonymizeListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @anonymize_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class AnonymizeListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @anonymize = payload.body[key].map do |data| + AnonymizeInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def anonymize + @anonymize + end + end + class AnonymizeInstance < InstanceResource ## # Initialize the AnonymizeInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/participant/published_track.rb b/lib/twilio-ruby/rest/video/v1/room/participant/published_track.rb index 554c16167..dacddf5e0 100644 --- a/lib/twilio-ruby/rest/video/v1/room/participant/published_track.rb +++ b/lib/twilio-ruby/rest/video/v1/room/participant/published_track.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists PublishedTrackPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + PublishedTrackPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields PublishedTrackInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +190,33 @@ def fetch ) end + ## + # Fetch the PublishedTrackInstanceMetadata + # @return [PublishedTrackInstance] Fetched PublishedTrackInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + publishedTrack_instance = PublishedTrackInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + participant_sid: @solution[:participant_sid], + sid: @solution[:sid], + ) + PublishedTrackInstanceMetadata.new( + @version, + publishedTrack_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -184,6 +233,45 @@ def inspect end end + class PublishedTrackInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new PublishedTrackInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}PublishedTrackInstance] published_track_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [PublishedTrackInstanceMetadata] The initialized instance with metadata. + def initialize(version, published_track_instance, headers, status_code) + super(version, headers, status_code) + @published_track_instance = published_track_instance + end + + def published_track + @published_track_instance + end + + def to_s + "" + end + end + + class PublishedTrackListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @published_track_instance = payload.body[key].map do |data| + PublishedTrackInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def published_track_instance + @instance + end + end + class PublishedTrackPage < Page ## # Initialize the PublishedTrackPage @@ -212,6 +300,54 @@ def to_s '' end end + + class PublishedTrackPageMetadata < PageMetadata + attr_reader :published_track_page + + def initialize(version, response, solution, limit) + super(version, response) + @published_track_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @published_track_page << PublishedTrackListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @published_track_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class PublishedTrackListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @published_track = payload.body[key].map do |data| + PublishedTrackInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def published_track + @published_track + end + end + class PublishedTrackInstance < InstanceResource ## # Initialize the PublishedTrackInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/participant/subscribe_rules.rb b/lib/twilio-ruby/rest/video/v1/room/participant/subscribe_rules.rb index c4b2190ed..5e4c5a7fd 100644 --- a/lib/twilio-ruby/rest/video/v1/room/participant/subscribe_rules.rb +++ b/lib/twilio-ruby/rest/video/v1/room/participant/subscribe_rules.rb @@ -53,6 +53,32 @@ def fetch ) end + ## + # Fetch the SubscribeRulesInstanceMetadata + # @return [SubscribeRulesInstance] Fetched SubscribeRulesInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + subscribeRules_instance = SubscribeRulesInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + participant_sid: @solution[:participant_sid], + ) + SubscribeRulesInstanceMetadata.new( + @version, + subscribeRules_instance, + response.headers, + response.status_code + ) + end + ## # Update the SubscribeRulesInstance # @param [Object] rules A JSON-encoded array of subscribe rules. See the [Specifying Subscribe Rules](https://www.twilio.com/docs/video/api/track-subscriptions#specifying-sr) section for further information. @@ -80,6 +106,39 @@ def update( ) end + ## + # Update the SubscribeRulesInstanceMetadata + # @param [Object] rules A JSON-encoded array of subscribe rules. See the [Specifying Subscribe Rules](https://www.twilio.com/docs/video/api/track-subscriptions#specifying-sr) section for further information. + # @return [SubscribeRulesInstance] Updated SubscribeRulesInstance + def update_with_metadata( + rules: :unset + ) + + data = Twilio::Values.of({ + 'Rules' => Twilio.serialize_object(rules), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + subscribeRules_instance = SubscribeRulesInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + participant_sid: @solution[:participant_sid], + ) + SubscribeRulesInstanceMetadata.new( + @version, + subscribeRules_instance, + response.headers, + response.status_code + ) + end + @@ -117,6 +176,54 @@ def to_s '' end end + + class SubscribeRulesPageMetadata < PageMetadata + attr_reader :subscribe_rules_page + + def initialize(version, response, solution, limit) + super(version, response) + @subscribe_rules_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @subscribe_rules_page << SubscribeRulesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @subscribe_rules_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SubscribeRulesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @subscribe_rules = payload.body[key].map do |data| + SubscribeRulesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def subscribe_rules + @subscribe_rules + end + end + class SubscribeRulesInstance < InstanceResource ## # Initialize the SubscribeRulesInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/participant/subscribed_track.rb b/lib/twilio-ruby/rest/video/v1/room/participant/subscribed_track.rb index 5f0bedf2c..ace373725 100644 --- a/lib/twilio-ruby/rest/video/v1/room/participant/subscribed_track.rb +++ b/lib/twilio-ruby/rest/video/v1/room/participant/subscribed_track.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SubscribedTrackPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SubscribedTrackPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SubscribedTrackInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -168,6 +190,33 @@ def fetch ) end + ## + # Fetch the SubscribedTrackInstanceMetadata + # @return [SubscribedTrackInstance] Fetched SubscribedTrackInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + subscribedTrack_instance = SubscribedTrackInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + participant_sid: @solution[:participant_sid], + sid: @solution[:sid], + ) + SubscribedTrackInstanceMetadata.new( + @version, + subscribedTrack_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -184,6 +233,45 @@ def inspect end end + class SubscribedTrackInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SubscribedTrackInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SubscribedTrackInstance] subscribed_track_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SubscribedTrackInstanceMetadata] The initialized instance with metadata. + def initialize(version, subscribed_track_instance, headers, status_code) + super(version, headers, status_code) + @subscribed_track_instance = subscribed_track_instance + end + + def subscribed_track + @subscribed_track_instance + end + + def to_s + "" + end + end + + class SubscribedTrackListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @subscribed_track_instance = payload.body[key].map do |data| + SubscribedTrackInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def subscribed_track_instance + @instance + end + end + class SubscribedTrackPage < Page ## # Initialize the SubscribedTrackPage @@ -212,6 +300,54 @@ def to_s '' end end + + class SubscribedTrackPageMetadata < PageMetadata + attr_reader :subscribed_track_page + + def initialize(version, response, solution, limit) + super(version, response) + @subscribed_track_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @subscribed_track_page << SubscribedTrackListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @subscribed_track_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SubscribedTrackListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @subscribed_track = payload.body[key].map do |data| + SubscribedTrackInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def subscribed_track + @subscribed_track + end + end + class SubscribedTrackInstance < InstanceResource ## # Initialize the SubscribedTrackInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/recording_rules.rb b/lib/twilio-ruby/rest/video/v1/room/recording_rules.rb index cefc14b59..027d82ac0 100644 --- a/lib/twilio-ruby/rest/video/v1/room/recording_rules.rb +++ b/lib/twilio-ruby/rest/video/v1/room/recording_rules.rb @@ -51,6 +51,31 @@ def fetch ) end + ## + # Fetch the RecordingRulesInstanceMetadata + # @return [RecordingRulesInstance] Fetched RecordingRulesInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + recordingRules_instance = RecordingRulesInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + ) + RecordingRulesInstanceMetadata.new( + @version, + recordingRules_instance, + response.headers, + response.status_code + ) + end + ## # Update the RecordingRulesInstance # @param [Object] rules A JSON-encoded array of recording rules. @@ -77,6 +102,38 @@ def update( ) end + ## + # Update the RecordingRulesInstanceMetadata + # @param [Object] rules A JSON-encoded array of recording rules. + # @return [RecordingRulesInstance] Updated RecordingRulesInstance + def update_with_metadata( + rules: :unset + ) + + data = Twilio::Values.of({ + 'Rules' => Twilio.serialize_object(rules), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + recordingRules_instance = RecordingRulesInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + ) + RecordingRulesInstanceMetadata.new( + @version, + recordingRules_instance, + response.headers, + response.status_code + ) + end + @@ -114,6 +171,54 @@ def to_s '' end end + + class RecordingRulesPageMetadata < PageMetadata + attr_reader :recording_rules_page + + def initialize(version, response, solution, limit) + super(version, response) + @recording_rules_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @recording_rules_page << RecordingRulesListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @recording_rules_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RecordingRulesListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @recording_rules = payload.body[key].map do |data| + RecordingRulesInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def recording_rules + @recording_rules + end + end + class RecordingRulesInstance < InstanceResource ## # Initialize the RecordingRulesInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/room_recording.rb b/lib/twilio-ruby/rest/video/v1/room/room_recording.rb index 64447d88a..643c37f9d 100644 --- a/lib/twilio-ruby/rest/video/v1/room/room_recording.rb +++ b/lib/twilio-ruby/rest/video/v1/room/room_recording.rb @@ -87,6 +87,36 @@ def stream(status: :unset, source_sid: :unset, date_created_after: :unset, date_ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RoomRecordingPageMetadata records from the API as a list. + # @param [Status] status Read only the recordings with this status. Can be: `processing`, `completed`, or `deleted`. + # @param [String] source_sid Read only the recordings that have this `source_sid`. + # @param [Time] date_created_after Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone. + # @param [Time] date_created_before Read only Recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone. + # @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_with_metadata(status: :unset, source_sid: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'SourceSid' => source_sid, + 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), + 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RoomRecordingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RoomRecordingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -178,7 +208,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RoomRecordingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + roomRecording_instance = RoomRecordingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RoomRecordingInstanceMetadata.new(@version, roomRecording_instance, response.headers, response.status_code) end ## @@ -201,6 +250,32 @@ def fetch ) end + ## + # Fetch the RoomRecordingInstanceMetadata + # @return [RoomRecordingInstance] Fetched RoomRecordingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + roomRecording_instance = RoomRecordingInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + sid: @solution[:sid], + ) + RoomRecordingInstanceMetadata.new( + @version, + roomRecording_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -217,6 +292,45 @@ def inspect end end + class RoomRecordingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RoomRecordingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RoomRecordingInstance] room_recording_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RoomRecordingInstanceMetadata] The initialized instance with metadata. + def initialize(version, room_recording_instance, headers, status_code) + super(version, headers, status_code) + @room_recording_instance = room_recording_instance + end + + def room_recording + @room_recording_instance + end + + def to_s + "" + end + end + + class RoomRecordingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @room_recording_instance = payload.body[key].map do |data| + RoomRecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def room_recording_instance + @instance + end + end + class RoomRecordingPage < Page ## # Initialize the RoomRecordingPage @@ -245,6 +359,54 @@ def to_s '' end end + + class RoomRecordingPageMetadata < PageMetadata + attr_reader :room_recording_page + + def initialize(version, response, solution, limit) + super(version, response) + @room_recording_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @room_recording_page << RoomRecordingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @room_recording_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RoomRecordingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @room_recording = payload.body[key].map do |data| + RoomRecordingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def room_recording + @room_recording + end + end + class RoomRecordingInstance < InstanceResource ## # Initialize the RoomRecordingInstance diff --git a/lib/twilio-ruby/rest/video/v1/room/transcriptions.rb b/lib/twilio-ruby/rest/video/v1/room/transcriptions.rb index 9d9a69876..4d807740f 100644 --- a/lib/twilio-ruby/rest/video/v1/room/transcriptions.rb +++ b/lib/twilio-ruby/rest/video/v1/room/transcriptions.rb @@ -58,6 +58,38 @@ def create( ) end + ## + # Create the TranscriptionsInstanceMetadata + # @param [Object] configuration A collection of properties that describe transcription behaviour. + # @return [TranscriptionsInstance] Created TranscriptionsInstance + def create_with_metadata( + configuration: :unset + ) + + data = Twilio::Values.of({ + 'Configuration' => Twilio.serialize_object(configuration), + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + transcriptions_instance = TranscriptionsInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + ) + TranscriptionsInstanceMetadata.new( + @version, + transcriptions_instance, + response.headers, + response.status_code + ) + end + ## # Lists TranscriptionsInstance records from the API as a list. @@ -97,6 +129,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists TranscriptionsPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + TranscriptionsPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields TranscriptionsInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -191,6 +245,32 @@ def fetch ) end + ## + # Fetch the TranscriptionsInstanceMetadata + # @return [TranscriptionsInstance] Fetched TranscriptionsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + transcriptions_instance = TranscriptionsInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + ttid: @solution[:ttid], + ) + TranscriptionsInstanceMetadata.new( + @version, + transcriptions_instance, + response.headers, + response.status_code + ) + end + ## # Update the TranscriptionsInstance # @param [Status] status @@ -218,6 +298,39 @@ def update( ) end + ## + # Update the TranscriptionsInstanceMetadata + # @param [Status] status + # @return [TranscriptionsInstance] Updated TranscriptionsInstance + def update_with_metadata( + status: :unset + ) + + data = Twilio::Values.of({ + 'Status' => status, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + transcriptions_instance = TranscriptionsInstance.new( + @version, + response.body, + room_sid: @solution[:room_sid], + ttid: @solution[:ttid], + ) + TranscriptionsInstanceMetadata.new( + @version, + transcriptions_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -234,6 +347,45 @@ def inspect end end + class TranscriptionsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new TranscriptionsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}TranscriptionsInstance] transcriptions_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [TranscriptionsInstanceMetadata] The initialized instance with metadata. + def initialize(version, transcriptions_instance, headers, status_code) + super(version, headers, status_code) + @transcriptions_instance = transcriptions_instance + end + + def transcriptions + @transcriptions_instance + end + + def to_s + "" + end + end + + class TranscriptionsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcriptions_instance = payload.body[key].map do |data| + TranscriptionsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcriptions_instance + @instance + end + end + class TranscriptionsPage < Page ## # Initialize the TranscriptionsPage @@ -262,6 +414,54 @@ def to_s '' end end + + class TranscriptionsPageMetadata < PageMetadata + attr_reader :transcriptions_page + + def initialize(version, response, solution, limit) + super(version, response) + @transcriptions_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @transcriptions_page << TranscriptionsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @transcriptions_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class TranscriptionsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @transcriptions = payload.body[key].map do |data| + TranscriptionsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def transcriptions + @transcriptions + end + end + class TranscriptionsInstance < InstanceResource ## # Initialize the TranscriptionsInstance diff --git a/lib/twilio-ruby/rest/voice/v1/archived_call.rb b/lib/twilio-ruby/rest/voice/v1/archived_call.rb index cc3897db2..9dd462c9b 100644 --- a/lib/twilio-ruby/rest/voice/v1/archived_call.rb +++ b/lib/twilio-ruby/rest/voice/v1/archived_call.rb @@ -65,7 +65,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ArchivedCallInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + archivedCall_instance = ArchivedCallInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ArchivedCallInstanceMetadata.new(@version, archivedCall_instance, response.headers, response.status_code) end @@ -84,6 +103,45 @@ def inspect end end + class ArchivedCallInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ArchivedCallInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ArchivedCallInstance] archived_call_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ArchivedCallInstanceMetadata] The initialized instance with metadata. + def initialize(version, archived_call_instance, headers, status_code) + super(version, headers, status_code) + @archived_call_instance = archived_call_instance + end + + def archived_call + @archived_call_instance + end + + def to_s + "" + end + end + + class ArchivedCallListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @archived_call_instance = payload.body[key].map do |data| + ArchivedCallInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def archived_call_instance + @instance + end + end + class ArchivedCallPage < Page ## # Initialize the ArchivedCallPage @@ -112,6 +170,54 @@ def to_s '' end end + + class ArchivedCallPageMetadata < PageMetadata + attr_reader :archived_call_page + + def initialize(version, response, solution, limit) + super(version, response) + @archived_call_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @archived_call_page << ArchivedCallListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @archived_call_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ArchivedCallListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @archived_call = payload.body[key].map do |data| + ArchivedCallInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def archived_call + @archived_call + end + end + class ArchivedCallInstance < InstanceResource ## # Initialize the ArchivedCallInstance diff --git a/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb b/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb index 1602590db..302ced48a 100644 --- a/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb +++ b/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb @@ -82,6 +82,64 @@ def create( ) end + ## + # Create the ByocTrunkInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @param [String] voice_url The URL we should call when the BYOC Trunk receives a call. + # @param [String] voice_method The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`. + # @param [String] voice_fallback_url The URL that we should call when an error occurs while retrieving or executing the TwiML from `voice_url`. + # @param [String] voice_fallback_method The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. + # @param [String] status_callback_url The URL that we should call to pass status parameters (such as call ended) to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`. + # @param [Boolean] cnam_lookup_enabled Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information. + # @param [String] connection_policy_sid The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure. + # @param [String] from_domain_sid The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\". + # @return [ByocTrunkInstance] Created ByocTrunkInstance + def create_with_metadata( + friendly_name: :unset, + voice_url: :unset, + voice_method: :unset, + voice_fallback_url: :unset, + voice_fallback_method: :unset, + status_callback_url: :unset, + status_callback_method: :unset, + cnam_lookup_enabled: :unset, + connection_policy_sid: :unset, + from_domain_sid: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'VoiceUrl' => voice_url, + 'VoiceMethod' => voice_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceFallbackMethod' => voice_fallback_method, + 'StatusCallbackUrl' => status_callback_url, + 'StatusCallbackMethod' => status_callback_method, + 'CnamLookupEnabled' => cnam_lookup_enabled, + 'ConnectionPolicySid' => connection_policy_sid, + 'FromDomainSid' => from_domain_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + byocTrunk_instance = ByocTrunkInstance.new( + @version, + response.body, + ) + ByocTrunkInstanceMetadata.new( + @version, + byocTrunk_instance, + response.headers, + response.status_code + ) + end + ## # Lists ByocTrunkInstance records from the API as a list. @@ -121,6 +179,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ByocTrunkPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ByocTrunkPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ByocTrunkInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -203,7 +283,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ByocTrunkInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + byocTrunk_instance = ByocTrunkInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ByocTrunkInstanceMetadata.new(@version, byocTrunk_instance, response.headers, response.status_code) end ## @@ -225,6 +324,31 @@ def fetch ) end + ## + # Fetch the ByocTrunkInstanceMetadata + # @return [ByocTrunkInstance] Fetched ByocTrunkInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + byocTrunk_instance = ByocTrunkInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ByocTrunkInstanceMetadata.new( + @version, + byocTrunk_instance, + response.headers, + response.status_code + ) + end + ## # Update the ByocTrunkInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. @@ -278,6 +402,65 @@ def update( ) end + ## + # Update the ByocTrunkInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @param [String] voice_url The URL we should call when the BYOC Trunk receives a call. + # @param [String] voice_method The HTTP method we should use to call `voice_url` + # @param [String] voice_fallback_url The URL that we should call when an error occurs while retrieving or executing the TwiML requested by `voice_url`. + # @param [String] voice_fallback_method The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. + # @param [String] status_callback_url The URL that we should call to pass status parameters (such as call ended) to your application. + # @param [String] status_callback_method The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`. + # @param [Boolean] cnam_lookup_enabled Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information. + # @param [String] connection_policy_sid The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure. + # @param [String] from_domain_sid The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\". + # @return [ByocTrunkInstance] Updated ByocTrunkInstance + def update_with_metadata( + friendly_name: :unset, + voice_url: :unset, + voice_method: :unset, + voice_fallback_url: :unset, + voice_fallback_method: :unset, + status_callback_url: :unset, + status_callback_method: :unset, + cnam_lookup_enabled: :unset, + connection_policy_sid: :unset, + from_domain_sid: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'VoiceUrl' => voice_url, + 'VoiceMethod' => voice_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceFallbackMethod' => voice_fallback_method, + 'StatusCallbackUrl' => status_callback_url, + 'StatusCallbackMethod' => status_callback_method, + 'CnamLookupEnabled' => cnam_lookup_enabled, + 'ConnectionPolicySid' => connection_policy_sid, + 'FromDomainSid' => from_domain_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + byocTrunk_instance = ByocTrunkInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ByocTrunkInstanceMetadata.new( + @version, + byocTrunk_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -294,6 +477,45 @@ def inspect end end + class ByocTrunkInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ByocTrunkInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ByocTrunkInstance] byoc_trunk_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ByocTrunkInstanceMetadata] The initialized instance with metadata. + def initialize(version, byoc_trunk_instance, headers, status_code) + super(version, headers, status_code) + @byoc_trunk_instance = byoc_trunk_instance + end + + def byoc_trunk + @byoc_trunk_instance + end + + def to_s + "" + end + end + + class ByocTrunkListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @byoc_trunk_instance = payload.body[key].map do |data| + ByocTrunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def byoc_trunk_instance + @instance + end + end + class ByocTrunkPage < Page ## # Initialize the ByocTrunkPage @@ -322,6 +544,54 @@ def to_s '' end end + + class ByocTrunkPageMetadata < PageMetadata + attr_reader :byoc_trunk_page + + def initialize(version, response, solution, limit) + super(version, response) + @byoc_trunk_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @byoc_trunk_page << ByocTrunkListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @byoc_trunk_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ByocTrunkListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @byoc_trunk = payload.body[key].map do |data| + ByocTrunkInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def byoc_trunk + @byoc_trunk + end + end + class ByocTrunkInstance < InstanceResource ## # Initialize the ByocTrunkInstance diff --git a/lib/twilio-ruby/rest/voice/v1/connection_policy.rb b/lib/twilio-ruby/rest/voice/v1/connection_policy.rb index 54964de59..d8458211f 100644 --- a/lib/twilio-ruby/rest/voice/v1/connection_policy.rb +++ b/lib/twilio-ruby/rest/voice/v1/connection_policy.rb @@ -55,6 +55,37 @@ def create( ) end + ## + # Create the ConnectionPolicyInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @return [ConnectionPolicyInstance] Created ConnectionPolicyInstance + def create_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + connectionPolicy_instance = ConnectionPolicyInstance.new( + @version, + response.body, + ) + ConnectionPolicyInstanceMetadata.new( + @version, + connectionPolicy_instance, + response.headers, + response.status_code + ) + end + ## # Lists ConnectionPolicyInstance records from the API as a list. @@ -94,6 +125,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConnectionPolicyPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConnectionPolicyPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConnectionPolicyInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -177,7 +230,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ConnectionPolicyInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + connectionPolicy_instance = ConnectionPolicyInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConnectionPolicyInstanceMetadata.new(@version, connectionPolicy_instance, response.headers, response.status_code) end ## @@ -199,6 +271,31 @@ def fetch ) end + ## + # Fetch the ConnectionPolicyInstanceMetadata + # @return [ConnectionPolicyInstance] Fetched ConnectionPolicyInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + connectionPolicy_instance = ConnectionPolicyInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ConnectionPolicyInstanceMetadata.new( + @version, + connectionPolicy_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConnectionPolicyInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. @@ -225,6 +322,38 @@ def update( ) end + ## + # Update the ConnectionPolicyInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @return [ConnectionPolicyInstance] Updated ConnectionPolicyInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + connectionPolicy_instance = ConnectionPolicyInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + ConnectionPolicyInstanceMetadata.new( + @version, + connectionPolicy_instance, + response.headers, + response.status_code + ) + end + ## # Access the targets # @return [ConnectionPolicyTargetList] @@ -260,6 +389,45 @@ def inspect end end + class ConnectionPolicyInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConnectionPolicyInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConnectionPolicyInstance] connection_policy_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConnectionPolicyInstanceMetadata] The initialized instance with metadata. + def initialize(version, connection_policy_instance, headers, status_code) + super(version, headers, status_code) + @connection_policy_instance = connection_policy_instance + end + + def connection_policy + @connection_policy_instance + end + + def to_s + "" + end + end + + class ConnectionPolicyListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @connection_policy_instance = payload.body[key].map do |data| + ConnectionPolicyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def connection_policy_instance + @instance + end + end + class ConnectionPolicyPage < Page ## # Initialize the ConnectionPolicyPage @@ -288,6 +456,54 @@ def to_s '' end end + + class ConnectionPolicyPageMetadata < PageMetadata + attr_reader :connection_policy_page + + def initialize(version, response, solution, limit) + super(version, response) + @connection_policy_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @connection_policy_page << ConnectionPolicyListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @connection_policy_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConnectionPolicyListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @connection_policy = payload.body[key].map do |data| + ConnectionPolicyInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def connection_policy + @connection_policy + end + end + class ConnectionPolicyInstance < InstanceResource ## # Initialize the ConnectionPolicyInstance diff --git a/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb b/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb index 5c2bc7145..b82ee345b 100644 --- a/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +++ b/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb @@ -70,6 +70,50 @@ def create( ) end + ## + # Create the ConnectionPolicyTargetInstanceMetadata + # @param [String] target The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @param [String] priority The relative importance of the target. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important target. + # @param [String] weight The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. Targets with higher values receive more load than those with lower ones with the same priority. + # @param [Boolean] enabled Whether the Target is enabled. The default is `true`. + # @return [ConnectionPolicyTargetInstance] Created ConnectionPolicyTargetInstance + def create_with_metadata( + target: nil, + friendly_name: :unset, + priority: :unset, + weight: :unset, + enabled: :unset + ) + + data = Twilio::Values.of({ + 'Target' => target, + 'FriendlyName' => friendly_name, + 'Priority' => priority, + 'Weight' => weight, + 'Enabled' => enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + connectionPolicyTarget_instance = ConnectionPolicyTargetInstance.new( + @version, + response.body, + connection_policy_sid: @solution[:connection_policy_sid], + ) + ConnectionPolicyTargetInstanceMetadata.new( + @version, + connectionPolicyTarget_instance, + response.headers, + response.status_code + ) + end + ## # Lists ConnectionPolicyTargetInstance records from the API as a list. @@ -109,6 +153,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists ConnectionPolicyTargetPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + ConnectionPolicyTargetPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields ConnectionPolicyTargetInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -192,7 +258,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the ConnectionPolicyTargetInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + connectionPolicyTarget_instance = ConnectionPolicyTargetInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + ConnectionPolicyTargetInstanceMetadata.new(@version, connectionPolicyTarget_instance, response.headers, response.status_code) end ## @@ -215,6 +300,32 @@ def fetch ) end + ## + # Fetch the ConnectionPolicyTargetInstanceMetadata + # @return [ConnectionPolicyTargetInstance] Fetched ConnectionPolicyTargetInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + connectionPolicyTarget_instance = ConnectionPolicyTargetInstance.new( + @version, + response.body, + connection_policy_sid: @solution[:connection_policy_sid], + sid: @solution[:sid], + ) + ConnectionPolicyTargetInstanceMetadata.new( + @version, + connectionPolicyTarget_instance, + response.headers, + response.status_code + ) + end + ## # Update the ConnectionPolicyTargetInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. @@ -254,6 +365,51 @@ def update( ) end + ## + # Update the ConnectionPolicyTargetInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @param [String] target The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported. + # @param [String] priority The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target. + # @param [String] weight The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority. + # @param [Boolean] enabled Whether the Target is enabled. + # @return [ConnectionPolicyTargetInstance] Updated ConnectionPolicyTargetInstance + def update_with_metadata( + friendly_name: :unset, + target: :unset, + priority: :unset, + weight: :unset, + enabled: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + 'Target' => target, + 'Priority' => priority, + 'Weight' => weight, + 'Enabled' => enabled, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + connectionPolicyTarget_instance = ConnectionPolicyTargetInstance.new( + @version, + response.body, + connection_policy_sid: @solution[:connection_policy_sid], + sid: @solution[:sid], + ) + ConnectionPolicyTargetInstanceMetadata.new( + @version, + connectionPolicyTarget_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -270,6 +426,45 @@ def inspect end end + class ConnectionPolicyTargetInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new ConnectionPolicyTargetInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}ConnectionPolicyTargetInstance] connection_policy_target_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [ConnectionPolicyTargetInstanceMetadata] The initialized instance with metadata. + def initialize(version, connection_policy_target_instance, headers, status_code) + super(version, headers, status_code) + @connection_policy_target_instance = connection_policy_target_instance + end + + def connection_policy_target + @connection_policy_target_instance + end + + def to_s + "" + end + end + + class ConnectionPolicyTargetListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @connection_policy_target_instance = payload.body[key].map do |data| + ConnectionPolicyTargetInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def connection_policy_target_instance + @instance + end + end + class ConnectionPolicyTargetPage < Page ## # Initialize the ConnectionPolicyTargetPage @@ -298,6 +493,54 @@ def to_s '' end end + + class ConnectionPolicyTargetPageMetadata < PageMetadata + attr_reader :connection_policy_target_page + + def initialize(version, response, solution, limit) + super(version, response) + @connection_policy_target_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @connection_policy_target_page << ConnectionPolicyTargetListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @connection_policy_target_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class ConnectionPolicyTargetListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @connection_policy_target = payload.body[key].map do |data| + ConnectionPolicyTargetInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def connection_policy_target + @connection_policy_target + end + end + class ConnectionPolicyTargetInstance < InstanceResource ## # Initialize the ConnectionPolicyTargetInstance diff --git a/lib/twilio-ruby/rest/voice/v1/dialing_permissions.rb b/lib/twilio-ruby/rest/voice/v1/dialing_permissions.rb index 51463c798..c3cbdee45 100644 --- a/lib/twilio-ruby/rest/voice/v1/dialing_permissions.rb +++ b/lib/twilio-ruby/rest/voice/v1/dialing_permissions.rb @@ -96,6 +96,54 @@ def to_s '' end end + + class DialingPermissionsPageMetadata < PageMetadata + attr_reader :dialing_permissions_page + + def initialize(version, response, solution, limit) + super(version, response) + @dialing_permissions_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @dialing_permissions_page << DialingPermissionsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @dialing_permissions_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DialingPermissionsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @dialing_permissions = payload.body[key].map do |data| + DialingPermissionsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def dialing_permissions + @dialing_permissions + end + end + class DialingPermissionsInstance < InstanceResource ## # Initialize the DialingPermissionsInstance diff --git a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/bulk_country_update.rb b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/bulk_country_update.rb index 2c416a38b..d8a7cb30c 100644 --- a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/bulk_country_update.rb +++ b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/bulk_country_update.rb @@ -57,6 +57,37 @@ def create( ) end + ## + # Create the BulkCountryUpdateInstanceMetadata + # @param [String] update_request URL encoded JSON array of update objects. example : `[ { \\\"iso_code\\\": \\\"GB\\\", \\\"low_risk_numbers_enabled\\\": \\\"true\\\", \\\"high_risk_special_numbers_enabled\\\":\\\"true\\\", \\\"high_risk_tollfraud_numbers_enabled\\\": \\\"false\\\" } ]` + # @return [BulkCountryUpdateInstance] Created BulkCountryUpdateInstance + def create_with_metadata( + update_request: nil + ) + + data = Twilio::Values.of({ + 'UpdateRequest' => update_request, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + bulkCountryUpdate_instance = BulkCountryUpdateInstance.new( + @version, + response.body, + ) + BulkCountryUpdateInstanceMetadata.new( + @version, + bulkCountryUpdate_instance, + response.headers, + response.status_code + ) + end + @@ -94,6 +125,54 @@ def to_s '' end end + + class BulkCountryUpdatePageMetadata < PageMetadata + attr_reader :bulk_country_update_page + + def initialize(version, response, solution, limit) + super(version, response) + @bulk_country_update_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @bulk_country_update_page << BulkCountryUpdateListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @bulk_country_update_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class BulkCountryUpdateListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @bulk_country_update = payload.body[key].map do |data| + BulkCountryUpdateInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def bulk_country_update + @bulk_country_update + end + end + class BulkCountryUpdateInstance < InstanceResource ## # Initialize the BulkCountryUpdateInstance diff --git a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb index e3e618fe5..136d25055 100644 --- a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb +++ b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb @@ -95,6 +95,40 @@ def stream(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_n @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CountryPageMetadata records from the API as a list. + # @param [String] iso_code Filter to retrieve the country permissions by specifying the [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + # @param [String] continent Filter to retrieve the country permissions by specifying the continent + # @param [String] country_code Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) + # @param [Boolean] low_risk_numbers_enabled Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`. + # @param [Boolean] high_risk_special_numbers_enabled Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false` + # @param [Boolean] high_risk_tollfraud_numbers_enabled Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `false`. + # @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_with_metadata(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_numbers_enabled: :unset, high_risk_special_numbers_enabled: :unset, high_risk_tollfraud_numbers_enabled: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'IsoCode' => iso_code, + 'Continent' => continent, + 'CountryCode' => country_code, + 'LowRiskNumbersEnabled' => low_risk_numbers_enabled, + 'HighRiskSpecialNumbersEnabled' => high_risk_special_numbers_enabled, + 'HighRiskTollfraudNumbersEnabled' => high_risk_tollfraud_numbers_enabled, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CountryPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CountryInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -200,6 +234,31 @@ def fetch ) end + ## + # Fetch the CountryInstanceMetadata + # @return [CountryInstance] Fetched CountryInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + country_instance = CountryInstance.new( + @version, + response.body, + iso_code: @solution[:iso_code], + ) + CountryInstanceMetadata.new( + @version, + country_instance, + response.headers, + response.status_code + ) + end + ## # Access the highrisk_special_prefixes # @return [HighriskSpecialPrefixList] @@ -227,6 +286,45 @@ def inspect end end + class CountryInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CountryInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CountryInstance] country_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CountryInstanceMetadata] The initialized instance with metadata. + def initialize(version, country_instance, headers, status_code) + super(version, headers, status_code) + @country_instance = country_instance + end + + def country + @country_instance + end + + def to_s + "" + end + end + + class CountryListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country_instance = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country_instance + @instance + end + end + class CountryPage < Page ## # Initialize the CountryPage @@ -255,6 +353,54 @@ def to_s '' end end + + class CountryPageMetadata < PageMetadata + attr_reader :country_page + + def initialize(version, response, solution, limit) + super(version, response) + @country_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @country_page << CountryListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @country_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CountryListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @country = payload.body[key].map do |data| + CountryInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def country + @country + end + end + class CountryInstance < InstanceResource ## # Initialize the CountryInstance diff --git a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.rb b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.rb index a29728488..aceb727fc 100644 --- a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.rb +++ b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.rb @@ -72,6 +72,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists HighriskSpecialPrefixPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + HighriskSpecialPrefixPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields HighriskSpecialPrefixInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -157,6 +179,54 @@ def to_s '' end end + + class HighriskSpecialPrefixPageMetadata < PageMetadata + attr_reader :highrisk_special_prefix_page + + def initialize(version, response, solution, limit) + super(version, response) + @highrisk_special_prefix_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @highrisk_special_prefix_page << HighriskSpecialPrefixListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @highrisk_special_prefix_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class HighriskSpecialPrefixListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @highrisk_special_prefix = payload.body[key].map do |data| + HighriskSpecialPrefixInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def highrisk_special_prefix + @highrisk_special_prefix + end + end + class HighriskSpecialPrefixInstance < InstanceResource ## # Initialize the HighriskSpecialPrefixInstance diff --git a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/settings.rb b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/settings.rb index 3639ac465..9ad9be0c4 100644 --- a/lib/twilio-ruby/rest/voice/v1/dialing_permissions/settings.rb +++ b/lib/twilio-ruby/rest/voice/v1/dialing_permissions/settings.rb @@ -74,6 +74,30 @@ def fetch ) end + ## + # Fetch the SettingsInstanceMetadata + # @return [SettingsInstance] Fetched SettingsInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + settings_instance = SettingsInstance.new( + @version, + response.body, + ) + SettingsInstanceMetadata.new( + @version, + settings_instance, + response.headers, + response.status_code + ) + end + ## # Update the SettingsInstance # @param [Boolean] dialing_permissions_inheritance `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`. @@ -99,6 +123,37 @@ def update( ) end + ## + # Update the SettingsInstanceMetadata + # @param [Boolean] dialing_permissions_inheritance `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`. + # @return [SettingsInstance] Updated SettingsInstance + def update_with_metadata( + dialing_permissions_inheritance: :unset + ) + + data = Twilio::Values.of({ + 'DialingPermissionsInheritance' => dialing_permissions_inheritance, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + settings_instance = SettingsInstance.new( + @version, + response.body, + ) + SettingsInstanceMetadata.new( + @version, + settings_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -115,6 +170,45 @@ def inspect end end + class SettingsInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SettingsInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SettingsInstance] settings_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SettingsInstanceMetadata] The initialized instance with metadata. + def initialize(version, settings_instance, headers, status_code) + super(version, headers, status_code) + @settings_instance = settings_instance + end + + def settings + @settings_instance + end + + def to_s + "" + end + end + + class SettingsListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @settings_instance = payload.body[key].map do |data| + SettingsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def settings_instance + @instance + end + end + class SettingsPage < Page ## # Initialize the SettingsPage @@ -143,6 +237,54 @@ def to_s '' end end + + class SettingsPageMetadata < PageMetadata + attr_reader :settings_page + + def initialize(version, response, solution, limit) + super(version, response) + @settings_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @settings_page << SettingsListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @settings_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SettingsListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @settings = payload.body[key].map do |data| + SettingsInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def settings + @settings + end + end + class SettingsInstance < InstanceResource ## # Initialize the SettingsInstance diff --git a/lib/twilio-ruby/rest/voice/v1/ip_record.rb b/lib/twilio-ruby/rest/voice/v1/ip_record.rb index b955b1903..c2487e085 100644 --- a/lib/twilio-ruby/rest/voice/v1/ip_record.rb +++ b/lib/twilio-ruby/rest/voice/v1/ip_record.rb @@ -61,6 +61,43 @@ def create( ) end + ## + # Create the IpRecordInstanceMetadata + # @param [String] ip_address An IP address in dotted decimal notation, IPv4 only. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @param [String] cidr_prefix_length An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32. + # @return [IpRecordInstance] Created IpRecordInstance + def create_with_metadata( + ip_address: nil, + friendly_name: :unset, + cidr_prefix_length: :unset + ) + + data = Twilio::Values.of({ + 'IpAddress' => ip_address, + 'FriendlyName' => friendly_name, + 'CidrPrefixLength' => cidr_prefix_length, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ipRecord_instance = IpRecordInstance.new( + @version, + response.body, + ) + IpRecordInstanceMetadata.new( + @version, + ipRecord_instance, + response.headers, + response.status_code + ) + end + ## # Lists IpRecordInstance records from the API as a list. @@ -100,6 +137,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists IpRecordPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + IpRecordPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields IpRecordInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -182,7 +241,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the IpRecordInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + ipRecord_instance = IpRecordInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + IpRecordInstanceMetadata.new(@version, ipRecord_instance, response.headers, response.status_code) end ## @@ -204,6 +282,31 @@ def fetch ) end + ## + # Fetch the IpRecordInstanceMetadata + # @return [IpRecordInstance] Fetched IpRecordInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ipRecord_instance = IpRecordInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + IpRecordInstanceMetadata.new( + @version, + ipRecord_instance, + response.headers, + response.status_code + ) + end + ## # Update the IpRecordInstance # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. @@ -230,6 +333,38 @@ def update( ) end + ## + # Update the IpRecordInstanceMetadata + # @param [String] friendly_name A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. + # @return [IpRecordInstance] Updated IpRecordInstance + def update_with_metadata( + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + ipRecord_instance = IpRecordInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + IpRecordInstanceMetadata.new( + @version, + ipRecord_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -246,6 +381,45 @@ def inspect end end + class IpRecordInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new IpRecordInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}IpRecordInstance] ip_record_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [IpRecordInstanceMetadata] The initialized instance with metadata. + def initialize(version, ip_record_instance, headers, status_code) + super(version, headers, status_code) + @ip_record_instance = ip_record_instance + end + + def ip_record + @ip_record_instance + end + + def to_s + "" + end + end + + class IpRecordListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_record_instance = payload.body[key].map do |data| + IpRecordInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_record_instance + @instance + end + end + class IpRecordPage < Page ## # Initialize the IpRecordPage @@ -274,6 +448,54 @@ def to_s '' end end + + class IpRecordPageMetadata < PageMetadata + attr_reader :ip_record_page + + def initialize(version, response, solution, limit) + super(version, response) + @ip_record_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @ip_record_page << IpRecordListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @ip_record_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class IpRecordListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @ip_record = payload.body[key].map do |data| + IpRecordInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def ip_record + @ip_record + end + end + class IpRecordInstance < InstanceResource ## # Initialize the IpRecordInstance diff --git a/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb b/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb index 4ea523f6e..10976f1e2 100644 --- a/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb +++ b/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb @@ -58,6 +58,40 @@ def create( ) end + ## + # Create the SourceIpMappingInstanceMetadata + # @param [String] ip_record_sid The Twilio-provided string that uniquely identifies the IP Record resource to map from. + # @param [String] sip_domain_sid The SID of the SIP Domain that the IP Record should be mapped to. + # @return [SourceIpMappingInstance] Created SourceIpMappingInstance + def create_with_metadata( + ip_record_sid: nil, + sip_domain_sid: nil + ) + + data = Twilio::Values.of({ + 'IpRecordSid' => ip_record_sid, + 'SipDomainSid' => sip_domain_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + sourceIpMapping_instance = SourceIpMappingInstance.new( + @version, + response.body, + ) + SourceIpMappingInstanceMetadata.new( + @version, + sourceIpMapping_instance, + response.headers, + response.status_code + ) + end + ## # Lists SourceIpMappingInstance records from the API as a list. @@ -97,6 +131,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SourceIpMappingPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SourceIpMappingPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SourceIpMappingInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -179,7 +235,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SourceIpMappingInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + sourceIpMapping_instance = SourceIpMappingInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SourceIpMappingInstanceMetadata.new(@version, sourceIpMapping_instance, response.headers, response.status_code) end ## @@ -201,6 +276,31 @@ def fetch ) end + ## + # Fetch the SourceIpMappingInstanceMetadata + # @return [SourceIpMappingInstance] Fetched SourceIpMappingInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + sourceIpMapping_instance = SourceIpMappingInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SourceIpMappingInstanceMetadata.new( + @version, + sourceIpMapping_instance, + response.headers, + response.status_code + ) + end + ## # Update the SourceIpMappingInstance # @param [String] sip_domain_sid The SID of the SIP Domain that the IP Record should be mapped to. @@ -227,6 +327,38 @@ def update( ) end + ## + # Update the SourceIpMappingInstanceMetadata + # @param [String] sip_domain_sid The SID of the SIP Domain that the IP Record should be mapped to. + # @return [SourceIpMappingInstance] Updated SourceIpMappingInstance + def update_with_metadata( + sip_domain_sid: nil + ) + + data = Twilio::Values.of({ + 'SipDomainSid' => sip_domain_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + sourceIpMapping_instance = SourceIpMappingInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SourceIpMappingInstanceMetadata.new( + @version, + sourceIpMapping_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -243,6 +375,45 @@ def inspect end end + class SourceIpMappingInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SourceIpMappingInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SourceIpMappingInstance] source_ip_mapping_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SourceIpMappingInstanceMetadata] The initialized instance with metadata. + def initialize(version, source_ip_mapping_instance, headers, status_code) + super(version, headers, status_code) + @source_ip_mapping_instance = source_ip_mapping_instance + end + + def source_ip_mapping + @source_ip_mapping_instance + end + + def to_s + "" + end + end + + class SourceIpMappingListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @source_ip_mapping_instance = payload.body[key].map do |data| + SourceIpMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def source_ip_mapping_instance + @instance + end + end + class SourceIpMappingPage < Page ## # Initialize the SourceIpMappingPage @@ -271,6 +442,54 @@ def to_s '' end end + + class SourceIpMappingPageMetadata < PageMetadata + attr_reader :source_ip_mapping_page + + def initialize(version, response, solution, limit) + super(version, response) + @source_ip_mapping_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @source_ip_mapping_page << SourceIpMappingListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @source_ip_mapping_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SourceIpMappingListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @source_ip_mapping = payload.body[key].map do |data| + SourceIpMappingInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def source_ip_mapping + @source_ip_mapping + end + end + class SourceIpMappingInstance < InstanceResource ## # Initialize the SourceIpMappingInstance diff --git a/lib/twilio-ruby/rest/wireless/v1/command.rb b/lib/twilio-ruby/rest/wireless/v1/command.rb index 106c12575..e34ca44a2 100644 --- a/lib/twilio-ruby/rest/wireless/v1/command.rb +++ b/lib/twilio-ruby/rest/wireless/v1/command.rb @@ -73,6 +73,55 @@ def create( ) end + ## + # Create the CommandInstanceMetadata + # @param [String] command The message body of the Command. Can be plain text in text mode or a Base64 encoded byte string in binary mode. + # @param [String] sim The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to send the Command to. + # @param [String] callback_method The HTTP method we use to call `callback_url`. Can be: `POST` or `GET`, and the default is `POST`. + # @param [String] callback_url The URL we call using the `callback_url` when the Command has finished sending, whether the command was delivered or it failed. + # @param [CommandMode] command_mode + # @param [String] include_sid Whether to include the SID of the command in the message body. Can be: `none`, `start`, or `end`, and the default behavior is `none`. When sending a Command to a SIM in text mode, we can automatically include the SID of the Command in the message body, which could be used to ensure that the device does not process the same Command more than once. A value of `start` will prepend the message with the Command SID, and `end` will append it to the end, separating the Command SID from the message body with a space. The length of the Command SID is included in the 160 character limit so the SMS body must be 128 characters or less before the Command SID is included. + # @param [Boolean] delivery_receipt_requested Whether to request delivery receipt from the recipient. For Commands that request delivery receipt, the Command state transitions to 'delivered' once the server has received a delivery receipt from the device. The default value is `true`. + # @return [CommandInstance] Created CommandInstance + def create_with_metadata( + command: nil, + sim: :unset, + callback_method: :unset, + callback_url: :unset, + command_mode: :unset, + include_sid: :unset, + delivery_receipt_requested: :unset + ) + + data = Twilio::Values.of({ + 'Command' => command, + 'Sim' => sim, + 'CallbackMethod' => callback_method, + 'CallbackUrl' => callback_url, + 'CommandMode' => command_mode, + 'IncludeSid' => include_sid, + 'DeliveryReceiptRequested' => delivery_receipt_requested, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + command_instance = CommandInstance.new( + @version, + response.body, + ) + CommandInstanceMetadata.new( + @version, + command_instance, + response.headers, + response.status_code + ) + end + ## # Lists CommandInstance records from the API as a list. @@ -128,6 +177,36 @@ def stream(sim: :unset, status: :unset, direction: :unset, transport: :unset, li @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists CommandPageMetadata records from the API as a list. + # @param [String] sim The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read. + # @param [Status] status The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`. + # @param [Direction] direction Only return Commands with this direction value. + # @param [Transport] transport Only return Commands with this transport value. Can be: `sms` or `ip`. + # @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_with_metadata(sim: :unset, status: :unset, direction: :unset, transport: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Sim' => sim, + 'Status' => status, + 'Direction' => direction, + 'Transport' => transport, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + CommandPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields CommandInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -218,7 +297,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the CommandInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + command_instance = CommandInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + CommandInstanceMetadata.new(@version, command_instance, response.headers, response.status_code) end ## @@ -240,6 +338,31 @@ def fetch ) end + ## + # Fetch the CommandInstanceMetadata + # @return [CommandInstance] Fetched CommandInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + command_instance = CommandInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + CommandInstanceMetadata.new( + @version, + command_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -256,6 +379,45 @@ def inspect end end + class CommandInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new CommandInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}CommandInstance] command_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [CommandInstanceMetadata] The initialized instance with metadata. + def initialize(version, command_instance, headers, status_code) + super(version, headers, status_code) + @command_instance = command_instance + end + + def command + @command_instance + end + + def to_s + "" + end + end + + class CommandListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @command_instance = payload.body[key].map do |data| + CommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def command_instance + @instance + end + end + class CommandPage < Page ## # Initialize the CommandPage @@ -284,6 +446,54 @@ def to_s '' end end + + class CommandPageMetadata < PageMetadata + attr_reader :command_page + + def initialize(version, response, solution, limit) + super(version, response) + @command_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @command_page << CommandListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @command_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class CommandListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @command = payload.body[key].map do |data| + CommandInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def command + @command + end + end + class CommandInstance < InstanceResource ## # Initialize the CommandInstance diff --git a/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb b/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb index 84ccb5a8e..81d005899 100644 --- a/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +++ b/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb @@ -88,6 +88,70 @@ def create( ) end + ## + # Create the RatePlanInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It does not have to be unique. + # @param [Boolean] data_enabled Whether SIMs can use GPRS/3G/4G/LTE data connectivity. + # @param [String] data_limit The total data usage (download and upload combined) in Megabytes that the Network allows during one month on the home network (T-Mobile USA). The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB and the default value is `1000`. + # @param [String] data_metering The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#payg-vs-quota-data-plans). + # @param [Boolean] messaging_enabled Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/iot/wireless/api/command-resource). + # @param [Boolean] voice_enabled Deprecated. + # @param [Boolean] national_roaming_enabled Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming). + # @param [Array[String]] international_roaming The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`. + # @param [String] national_roaming_data_limit The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming) for more info. + # @param [String] international_roaming_data_limit The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB. + # @param [DataLimitStrategy] data_limit_strategy + # @return [RatePlanInstance] Created RatePlanInstance + def create_with_metadata( + unique_name: :unset, + friendly_name: :unset, + data_enabled: :unset, + data_limit: :unset, + data_metering: :unset, + messaging_enabled: :unset, + voice_enabled: :unset, + national_roaming_enabled: :unset, + international_roaming: :unset, + national_roaming_data_limit: :unset, + international_roaming_data_limit: :unset, + data_limit_strategy: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'FriendlyName' => friendly_name, + 'DataEnabled' => data_enabled, + 'DataLimit' => data_limit, + 'DataMetering' => data_metering, + 'MessagingEnabled' => messaging_enabled, + 'VoiceEnabled' => voice_enabled, + 'NationalRoamingEnabled' => national_roaming_enabled, + 'InternationalRoaming' => Twilio.serialize_list(international_roaming) { |e| e }, + 'NationalRoamingDataLimit' => national_roaming_data_limit, + 'InternationalRoamingDataLimit' => international_roaming_data_limit, + 'DataLimitStrategy' => data_limit_strategy, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.create_with_metadata('POST', @uri, data: data, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + ) + RatePlanInstanceMetadata.new( + @version, + ratePlan_instance, + response.headers, + response.status_code + ) + end + ## # Lists RatePlanInstance records from the API as a list. @@ -127,6 +191,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists RatePlanPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + RatePlanPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields RatePlanInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -209,7 +295,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the RatePlanInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + RatePlanInstanceMetadata.new(@version, ratePlan_instance, response.headers, response.status_code) end ## @@ -231,6 +336,31 @@ def fetch ) end + ## + # Fetch the RatePlanInstanceMetadata + # @return [RatePlanInstance] Fetched RatePlanInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RatePlanInstanceMetadata.new( + @version, + ratePlan_instance, + response.headers, + response.status_code + ) + end + ## # Update the RatePlanInstance # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. @@ -260,6 +390,41 @@ def update( ) end + ## + # Update the RatePlanInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. + # @param [String] friendly_name A descriptive string that you create to describe the resource. It does not have to be unique. + # @return [RatePlanInstance] Updated RatePlanInstance + def update_with_metadata( + unique_name: :unset, + friendly_name: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'FriendlyName' => friendly_name, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + ratePlan_instance = RatePlanInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + RatePlanInstanceMetadata.new( + @version, + ratePlan_instance, + response.headers, + response.status_code + ) + end + ## # Provide a user friendly representation @@ -276,6 +441,45 @@ def inspect end end + class RatePlanInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new RatePlanInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}RatePlanInstance] rate_plan_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [RatePlanInstanceMetadata] The initialized instance with metadata. + def initialize(version, rate_plan_instance, headers, status_code) + super(version, headers, status_code) + @rate_plan_instance = rate_plan_instance + end + + def rate_plan + @rate_plan_instance + end + + def to_s + "" + end + end + + class RatePlanListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @rate_plan_instance = payload.body[key].map do |data| + RatePlanInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def rate_plan_instance + @instance + end + end + class RatePlanPage < Page ## # Initialize the RatePlanPage @@ -304,6 +508,54 @@ def to_s '' end end + + class RatePlanPageMetadata < PageMetadata + attr_reader :rate_plan_page + + def initialize(version, response, solution, limit) + super(version, response) + @rate_plan_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @rate_plan_page << RatePlanListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @rate_plan_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class RatePlanListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @rate_plan = payload.body[key].map do |data| + RatePlanInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def rate_plan + @rate_plan + end + end + class RatePlanInstance < InstanceResource ## # Initialize the RatePlanInstance diff --git a/lib/twilio-ruby/rest/wireless/v1/sim.rb b/lib/twilio-ruby/rest/wireless/v1/sim.rb index 2b488561f..8ad132dba 100644 --- a/lib/twilio-ruby/rest/wireless/v1/sim.rb +++ b/lib/twilio-ruby/rest/wireless/v1/sim.rb @@ -89,6 +89,38 @@ def stream(status: :unset, iccid: :unset, rate_plan: :unset, e_id: :unset, sim_r @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists SimPageMetadata records from the API as a list. + # @param [Status] status Only return Sim resources with this status. + # @param [String] iccid Only return Sim resources with this ICCID. This will return a list with a maximum size of 1. + # @param [String] rate_plan The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. + # @param [String] e_id Deprecated. + # @param [String] sim_registration_code Only return Sim resources with this registration code. This will return a list with a maximum size of 1. + # @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_with_metadata(status: :unset, iccid: :unset, rate_plan: :unset, e_id: :unset, sim_registration_code: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'Status' => status, + 'Iccid' => iccid, + 'RatePlan' => rate_plan, + 'EId' => e_id, + 'SimRegistrationCode' => sim_registration_code, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + SimPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields SimInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -183,7 +215,26 @@ def delete - @version.delete('DELETE', @uri, headers: headers) + @version.delete('DELETE', @uri, headers: headers) + end + + ## + # Delete the SimInstanceMetadata + # @return [Boolean] True if delete succeeds, false otherwise + def delete_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + response = @version.delete_with_metadata('DELETE', @uri, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + SimInstanceMetadata.new(@version, sim_instance, response.headers, response.status_code) end ## @@ -205,6 +256,31 @@ def fetch ) end + ## + # Fetch the SimInstanceMetadata + # @return [SimInstance] Fetched SimInstance + def fetch_with_metadata + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.fetch_with_metadata('GET', @uri, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SimInstanceMetadata.new( + @version, + sim_instance, + response.headers, + response.status_code + ) + end + ## # Update the SimInstance # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the `sid` in the URL path to address the resource. @@ -282,6 +358,89 @@ def update( ) end + ## + # Update the SimInstanceMetadata + # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used in place of the `sid` in the URL path to address the resource. + # @param [String] callback_method The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`. + # @param [String] callback_url The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`). + # @param [String] friendly_name A descriptive string that you create to describe the Sim resource. It does not need to be unique. + # @param [String] rate_plan The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned. + # @param [Status] status + # @param [String] commands_callback_method The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`. + # @param [String] commands_callback_url The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. + # @param [String] sms_fallback_method The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`. + # @param [String] sms_fallback_url The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`. + # @param [String] sms_method The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`. + # @param [String] sms_url The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). + # @param [String] voice_fallback_method Deprecated. + # @param [String] voice_fallback_url Deprecated. + # @param [String] voice_method Deprecated. + # @param [String] voice_url Deprecated. + # @param [ResetStatus] reset_status + # @param [String] account_sid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts). + # @return [SimInstance] Updated SimInstance + def update_with_metadata( + unique_name: :unset, + callback_method: :unset, + callback_url: :unset, + friendly_name: :unset, + rate_plan: :unset, + status: :unset, + commands_callback_method: :unset, + commands_callback_url: :unset, + sms_fallback_method: :unset, + sms_fallback_url: :unset, + sms_method: :unset, + sms_url: :unset, + voice_fallback_method: :unset, + voice_fallback_url: :unset, + voice_method: :unset, + voice_url: :unset, + reset_status: :unset, + account_sid: :unset + ) + + data = Twilio::Values.of({ + 'UniqueName' => unique_name, + 'CallbackMethod' => callback_method, + 'CallbackUrl' => callback_url, + 'FriendlyName' => friendly_name, + 'RatePlan' => rate_plan, + 'Status' => status, + 'CommandsCallbackMethod' => commands_callback_method, + 'CommandsCallbackUrl' => commands_callback_url, + 'SmsFallbackMethod' => sms_fallback_method, + 'SmsFallbackUrl' => sms_fallback_url, + 'SmsMethod' => sms_method, + 'SmsUrl' => sms_url, + 'VoiceFallbackMethod' => voice_fallback_method, + 'VoiceFallbackUrl' => voice_fallback_url, + 'VoiceMethod' => voice_method, + 'VoiceUrl' => voice_url, + 'ResetStatus' => reset_status, + 'AccountSid' => account_sid, + }) + + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) + + + + + + response = @version.update_with_metadata('POST', @uri, data: data, headers: headers) + sim_instance = SimInstance.new( + @version, + response.body, + sid: @solution[:sid], + ) + SimInstanceMetadata.new( + @version, + sim_instance, + response.headers, + response.status_code + ) + end + ## # Access the data_sessions # @return [DataSessionList] @@ -320,6 +479,45 @@ def inspect end end + class SimInstanceMetadata < InstanceResourceMetadata + ## + # Initializes a new SimInstanceMetadata. + # @param [Version] version Version that contains the resource + # @param [}SimInstance] sim_instance The instance associated with the metadata. + # @param [Hash] headers Header object with response headers. + # @param [Integer] status_code The HTTP status code of the response. + # @return [SimInstanceMetadata] The initialized instance with metadata. + def initialize(version, sim_instance, headers, status_code) + super(version, headers, status_code) + @sim_instance = sim_instance + end + + def sim + @sim_instance + end + + def to_s + "" + end + end + + class SimListResponse < InstanceListResource + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sim_instance = payload.body[key].map do |data| + SimInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sim_instance + @instance + end + end + class SimPage < Page ## # Initialize the SimPage @@ -348,6 +546,54 @@ def to_s '' end end + + class SimPageMetadata < PageMetadata + attr_reader :sim_page + + def initialize(version, response, solution, limit) + super(version, response) + @sim_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @sim_page << SimListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @sim_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class SimListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @sim = payload.body[key].map do |data| + SimInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def sim + @sim + end + end + class SimInstance < InstanceResource ## # Initialize the SimInstance diff --git a/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb b/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb index dc998d827..7ac30217e 100644 --- a/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +++ b/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb @@ -71,6 +71,28 @@ def stream(limit: nil, page_size: nil) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists DataSessionPageMetadata records from the API as a list. + # @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_with_metadata(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + DataSessionPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields DataSessionInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -156,6 +178,54 @@ def to_s '' end end + + class DataSessionPageMetadata < PageMetadata + attr_reader :data_session_page + + def initialize(version, response, solution, limit) + super(version, response) + @data_session_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @data_session_page << DataSessionListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @data_session_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class DataSessionListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @data_session = payload.body[key].map do |data| + DataSessionInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def data_session + @data_session + end + end + class DataSessionInstance < InstanceResource ## # Initialize the DataSessionInstance diff --git a/lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb b/lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb index 130a63c1a..870a07e51 100644 --- a/lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb +++ b/lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb @@ -83,6 +83,34 @@ def stream(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_si @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UsageRecordPageMetadata records from the API as a list. + # @param [Time] end_ Only include usage that occurred on or before this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is the current time. + # @param [Time] start Only include usage that has occurred on or after this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is one month before the `end` parameter value. + # @param [Granularity] granularity How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. The default is `all`. A value of `all` returns one Usage Record that describes the usage for the entire period. + # @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_with_metadata(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'End' => Twilio.serialize_iso8601_datetime(end_), + 'Start' => Twilio.serialize_iso8601_datetime(start), + 'Granularity' => granularity, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UsageRecordPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UsageRecordInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -174,6 +202,54 @@ def to_s '' end end + + class UsageRecordPageMetadata < PageMetadata + attr_reader :usage_record_page + + def initialize(version, response, solution, limit) + super(version, response) + @usage_record_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @usage_record_page << UsageRecordListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @usage_record_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsageRecordListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @usage_record = payload.body[key].map do |data| + UsageRecordInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def usage_record + @usage_record + end + end + class UsageRecordInstance < InstanceResource ## # Initialize the UsageRecordInstance diff --git a/lib/twilio-ruby/rest/wireless/v1/usage_record.rb b/lib/twilio-ruby/rest/wireless/v1/usage_record.rb index 15852d230..fda7f40e1 100644 --- a/lib/twilio-ruby/rest/wireless/v1/usage_record.rb +++ b/lib/twilio-ruby/rest/wireless/v1/usage_record.rb @@ -81,6 +81,34 @@ def stream(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_si @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end + ## + # Lists UsageRecordPageMetadata records from the API as a list. + # @param [Time] end_ Only include usage that has occurred on or before this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). + # @param [Time] start Only include usage that has occurred on or after this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). + # @param [Granularity] granularity How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period. + # @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_with_metadata(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + params = Twilio::Values.of({ + 'End' => Twilio.serialize_iso8601_datetime(end_), + 'Start' => Twilio.serialize_iso8601_datetime(start), + 'Granularity' => granularity, + + 'PageSize' => page_size, + }); + headers = Twilio::Values.of({}) + + response = @version.page('GET', @uri, params: params, headers: headers) + + UsageRecordPageMetadata.new(@version, response, @solution, limits[:limit]) + end + ## # When passed a block, yields UsageRecordInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit @@ -172,6 +200,54 @@ def to_s '' end end + + class UsageRecordPageMetadata < PageMetadata + attr_reader :usage_record_page + + def initialize(version, response, solution, limit) + super(version, response) + @usage_record_page = [] + @limit = limit + key = get_key(response.body) + number_of_records = response.body[key].size + while( limit != :unset && number_of_records <= limit ) + @usage_record_page << UsageRecordListResponse.new(version, @payload, key) + @payload = self.next_page + break unless @payload + number_of_records += page_size + end + # Path Solution + @solution = solution + end + + def each + @usage_record_page.each do |record| + yield record + end + end + + def to_s + ''; + end + end + class UsageRecordListResponse < InstanceListResource + + # @param [Array] instance + # @param [Hash{String => Object}] headers + # @param [Integer] status_code + def initialize(version, payload, key) + @usage_record = payload.body[key].map do |data| + UsageRecordInstance.new(version, data) + end + @headers = payload.headers + @status_code = payload.status_code + end + + def usage_record + @usage_record + end + end + class UsageRecordInstance < InstanceResource ## # Initialize the UsageRecordInstance diff --git a/test.rb b/test.rb index cb475d542..effc2a16a 100644 --- a/test.rb +++ b/test.rb @@ -7,6 +7,35 @@ auth_token = ENV["TWILIO_AUTH_TOKEN"] @client = Twilio::REST::Client.new account_sid, auth_token -# message = @client.messages.list( limit: 20, page_size: 5) -message_page_with_metadata = @client.messages.list_with_metadata( limit: 20, page_size: 5) -message_page_with_metadata.each { |item| puts item.instance } # Internally calls collection.each +message_page_with_metadata = @client.messages.list_with_metadata(limit: 20, page_size: 5) +message_page_with_metadata.each { |item| puts item.message } + +# message_created_with_metadata = @client.messages.create_with_metadata( +# to: "+", +# from: "+", +# body: "Hello from Twilio!", +# ) +# +# puts message_created_with_metadata.message +# puts message_created_with_metadata.headers +# puts message_created_with_metadata.status_code + +# message_created_with_metadata = @client.messages('SM6dbc937b06440ee0eb9153e55a74c9fd').fetch_with_metadata +# +# puts message_created_with_metadata.message +# puts message_created_with_metadata.headers +# puts message_created_with_metadata.status_code + +# message_update_with_metadata = @client.messages('SM6dbc937b06440ee0eb9153e55a74c9fd').update_with_metadata(body: "Hello from Twilio Ruby") +# +# puts message_update_with_metadata.message +# puts message_update_with_metadata.headers +# puts message_update_with_metadata.status_code + +# message_delete_with_metadata = @client.messages('SMd21346242f23d663a4729859effa4e76').delete_with_metadata +# puts message_delete_with_metadata.message +# puts message_delete_with_metadata.headers +# puts message_delete_with_metadata.status_code + +message_page_with_metadata = @client.chat.v1.credentials.list_with_metadata(limit: 20, page_size: 5) +message_page_with_metadata.each { |item| puts item.credential }