class Twilio::REST::Conversations::V1::ServiceContext::ConversationContext::ParticipantList
Public Class Methods
Initialize the ParticipantList
@param [Version] version Version
that contains the resource @param [String] chat_service_sid The SID of the {Conversation
Service}[https://www.twilio.com/docs/conversations/api/service-resource] the Participant resource is associated with.
@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/service/conversation/participant.rb 26 def initialize(version, chat_service_sid: nil, conversation_sid: nil) 27 super(version) 28 29 # Path Solution 30 @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid} 31 @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Participants" 32 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 Conversation 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/service/conversation/participant.rb 65 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) 66 data = Twilio::Values.of({ 67 'Identity' => identity, 68 'MessagingBinding.Address' => messaging_binding_address, 69 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address, 70 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 71 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 72 'Attributes' => attributes, 73 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address, 74 'RoleSid' => role_sid, 75 }) 76 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 77 78 payload = @version.create('POST', @uri, data: data, headers: headers) 79 80 ParticipantInstance.new( 81 @version, 82 payload, 83 chat_service_sid: @solution[:chat_service_sid], 84 conversation_sid: @solution[:conversation_sid], 85 ) 86 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/service/conversation/participant.rb 126 def each 127 limits = @version.read_limits 128 129 page = self.page(page_size: limits[:page_size], ) 130 131 @version.stream(page, 132 limit: limits[:limit], 133 page_limit: limits[:page_limit]).each {|x| yield x} 134 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/service/conversation/participant.rb 160 def get_page(target_url) 161 response = @version.domain.request( 162 'GET', 163 target_url 164 ) 165 ParticipantPage.new(@version, response, @solution) 166 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/service/conversation/participant.rb 99 def list(limit: nil, page_size: nil) 100 self.stream(limit: limit, page_size: page_size).entries 101 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/service/conversation/participant.rb 143 def page(page_token: :unset, page_number: :unset, page_size: :unset) 144 params = Twilio::Values.of({ 145 'PageToken' => page_token, 146 'Page' => page_number, 147 'PageSize' => page_size, 148 }) 149 150 response = @version.page('GET', @uri, params: params) 151 152 ParticipantPage.new(@version, response, @solution) 153 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/service/conversation/participant.rb 114 def stream(limit: nil, page_size: nil) 115 limits = @version.read_limits(limit, page_size) 116 117 page = self.page(page_size: limits[:page_size], ) 118 119 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 120 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb 170 def to_s 171 '#<Twilio.Conversations.V1.ParticipantList>' 172 end