class Twilio::REST::Chat::V2::ServiceContext::ChannelContext::MemberList
Public Class Methods
Initialize the MemberList
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the
{Service}[https://www.twilio.com/docs/chat/rest/service-resource] the Member resource is associated with.
@param [String] channel_sid The SID of the
{Channel}[https://www.twilio.com/docs/chat/channels] the Member resource belongs to.
@return [MemberList] MemberList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 26 def initialize(version, service_sid: nil, channel_sid: nil) 27 super(version) 28 29 # Path Solution 30 @solution = {service_sid: service_sid, channel_sid: channel_sid} 31 @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Members" 32 end
Public Instance Methods
Create the MemberInstance
@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 [member.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [MemberInstance] Created MemberInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 68 def create(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) 69 data = Twilio::Values.of({ 70 'Identity' => identity, 71 'RoleSid' => role_sid, 72 'LastConsumedMessageIndex' => last_consumed_message_index, 73 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), 74 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 75 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 76 'Attributes' => attributes, 77 }) 78 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 79 80 payload = @version.create('POST', @uri, data: data, headers: headers) 81 82 MemberInstance.new( 83 @version, 84 payload, 85 service_sid: @solution[:service_sid], 86 channel_sid: @solution[:channel_sid], 87 ) 88 end
When passed a block, yields MemberInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 136 def each 137 limits = @version.read_limits 138 139 page = self.page(page_size: limits[:page_size], ) 140 141 @version.stream(page, 142 limit: limits[:limit], 143 page_limit: limits[:page_limit]).each {|x| yield x} 144 end
Retrieve a single page of MemberInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of MemberInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 175 def get_page(target_url) 176 response = @version.domain.request( 177 'GET', 178 target_url 179 ) 180 MemberPage.new(@version, response, @solution) 181 end
Lists MemberInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Array] 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
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 105 def list(identity: :unset, limit: nil, page_size: nil) 106 self.stream(identity: identity, limit: limit, page_size: page_size).entries 107 end
Retrieve a single page of MemberInstance
records from the API. Request
is executed immediately. @param [Array] 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 [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 MemberInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 157 def page(identity: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 158 params = Twilio::Values.of({ 159 'Identity' => Twilio.serialize_list(identity) { |e| e }, 160 'PageToken' => page_token, 161 'Page' => page_number, 162 'PageSize' => page_size, 163 }) 164 165 response = @version.page('GET', @uri, params: params) 166 167 MemberPage.new(@version, response, @solution) 168 end
Streams MemberInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Array] 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 [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 124 def stream(identity: :unset, limit: nil, page_size: nil) 125 limits = @version.read_limits(limit, page_size) 126 127 page = self.page(identity: identity, page_size: limits[:page_size], ) 128 129 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 130 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/member.rb 185 def to_s 186 '#<Twilio.Chat.V2.MemberList>' 187 end