class Twilio::REST::Conversations::V1::ConversationList

Public Class Methods

new(version) click to toggle source

Initialize the ConversationList @param [Version] version Version that contains the resource @return [ConversationList] ConversationList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
18 def initialize(version)
19   super(version)
20 
21   # Path Solution
22   @solution = {}
23   @uri = "/Conversations"
24 end

Public Instance Methods

create(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, x_twilio_webhook_enabled: :unset) click to toggle source

Create the ConversationInstance @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/sms/services/api] 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 [conversation.State] state Current state of this conversation. Can be

either `active`, `inactive` or `closed` and defaults to `active`

@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 [conversation.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

@return [ConversationInstance] Created ConversationInstance

   # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
51 def create(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, x_twilio_webhook_enabled: :unset)
52   data = Twilio::Values.of({
53       'FriendlyName' => friendly_name,
54       'UniqueName' => unique_name,
55       'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
56       'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
57       'MessagingServiceSid' => messaging_service_sid,
58       'Attributes' => attributes,
59       'State' => state,
60       'Timers.Inactive' => timers_inactive,
61       'Timers.Closed' => timers_closed,
62   })
63   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
64 
65   payload = @version.create('POST', @uri, data: data, headers: headers)
66 
67   ConversationInstance.new(@version, payload, )
68 end
each() { |x| ... } click to toggle source

When passed a block, yields ConversationInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
108 def each
109   limits = @version.read_limits
110 
111   page = self.page(page_size: limits[:page_size], )
112 
113   @version.stream(page,
114                   limit: limits[:limit],
115                   page_limit: limits[:page_limit]).each {|x| yield x}
116 end
get_page(target_url) click to toggle source

Retrieve a single page of ConversationInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of ConversationInstance

    # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
142 def get_page(target_url)
143   response = @version.domain.request(
144       'GET',
145       target_url
146   )
147   ConversationPage.new(@version, response, @solution)
148 end
list(limit: nil, page_size: nil) click to toggle source

Lists ConversationInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
81 def list(limit: nil, page_size: nil)
82   self.stream(limit: limit, page_size: page_size).entries
83 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of ConversationInstance records from the API. Request is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of ConversationInstance

    # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
125 def page(page_token: :unset, page_number: :unset, page_size: :unset)
126   params = Twilio::Values.of({
127       'PageToken' => page_token,
128       'Page' => page_number,
129       'PageSize' => page_size,
130   })
131 
132   response = @version.page('GET', @uri, params: params)
133 
134   ConversationPage.new(@version, response, @solution)
135 end
stream(limit: nil, page_size: nil) click to toggle source

Streams ConversationInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

    # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
 96 def stream(limit: nil, page_size: nil)
 97   limits = @version.read_limits(limit, page_size)
 98 
 99   page = self.page(page_size: limits[:page_size], )
100 
101   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
102 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/conversations/v1/conversation.rb
152 def to_s
153   '#<Twilio.Conversations.V1.ConversationList>'
154 end