class Twilio::REST::Conversations::V1::ConversationContext::ParticipantList
Public Class Methods
Initialize the ParticipantList
@param [Version] version Version
that contains the resource @param [String] conversation_sid The unique ID of the
{Conversation}[https://www.twilio.com/docs/conversations/api/conversation-resource] for this participant.
@return [ParticipantList] ParticipantList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb 22 def initialize(version, conversation_sid: nil) 23 super(version) 24 25 # Path Solution 26 @solution = {conversation_sid: conversation_sid} 27 @uri = "/Conversations/#{@solution[:conversation_sid]}/Participants" 28 end
Public Instance Methods
Create the ParticipantInstance
@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 [participant.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [ParticipantInstance] Created ParticipantInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb 61 def create(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) 62 data = Twilio::Values.of({ 63 'Identity' => identity, 64 'MessagingBinding.Address' => messaging_binding_address, 65 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address, 66 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 67 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 68 'Attributes' => attributes, 69 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address, 70 'RoleSid' => role_sid, 71 }) 72 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 73 74 payload = @version.create('POST', @uri, data: data, headers: headers) 75 76 ParticipantInstance.new(@version, payload, conversation_sid: @solution[:conversation_sid], ) 77 end
When passed a block, yields ParticipantInstance
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/participant.rb 117 def each 118 limits = @version.read_limits 119 120 page = self.page(page_size: limits[:page_size], ) 121 122 @version.stream(page, 123 limit: limits[:limit], 124 page_limit: limits[:page_limit]).each {|x| yield x} 125 end
Retrieve a single page of ParticipantInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of ParticipantInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb 151 def get_page(target_url) 152 response = @version.domain.request( 153 'GET', 154 target_url 155 ) 156 ParticipantPage.new(@version, response, @solution) 157 end
Lists ParticipantInstance
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/participant.rb 90 def list(limit: nil, page_size: nil) 91 self.stream(limit: limit, page_size: page_size).entries 92 end
Retrieve a single page of ParticipantInstance
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 ParticipantInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb 134 def page(page_token: :unset, page_number: :unset, page_size: :unset) 135 params = Twilio::Values.of({ 136 'PageToken' => page_token, 137 'Page' => page_number, 138 'PageSize' => page_size, 139 }) 140 141 response = @version.page('GET', @uri, params: params) 142 143 ParticipantPage.new(@version, response, @solution) 144 end
Streams ParticipantInstance
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/participant.rb 105 def stream(limit: nil, page_size: nil) 106 limits = @version.read_limits(limit, page_size) 107 108 page = self.page(page_size: limits[:page_size], ) 109 110 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 111 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb 161 def to_s 162 '#<Twilio.Conversations.V1.ParticipantList>' 163 end