class Twilio::REST::IpMessaging::V2::ServiceContext::ChannelContext::MemberList
Public Class Methods
Initialize the MemberList
@param [Version] version Version
that contains the resource @param [String] service_sid The service_sid @param [String] channel_sid The channel_sid @return [MemberList] MemberList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb 22 def initialize(version, service_sid: nil, channel_sid: nil) 23 super(version) 24 25 # Path Solution 26 @solution = {service_sid: service_sid, channel_sid: channel_sid} 27 @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Members" 28 end
Public Instance Methods
Create the MemberInstance
@param [String] identity The identity @param [String] role_sid The role_sid @param [String] last_consumed_message_index The last_consumed_message_index @param [Time] last_consumption_timestamp The last_consumption_timestamp @param [Time] date_created The date_created @param [Time] date_updated The date_updated @param [String] attributes The attributes @param [member.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [MemberInstance] Created MemberInstance
# File lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb 42 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) 43 data = Twilio::Values.of({ 44 'Identity' => identity, 45 'RoleSid' => role_sid, 46 'LastConsumedMessageIndex' => last_consumed_message_index, 47 'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp), 48 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 49 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 50 'Attributes' => attributes, 51 }) 52 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 53 54 payload = @version.create('POST', @uri, data: data, headers: headers) 55 56 MemberInstance.new( 57 @version, 58 payload, 59 service_sid: @solution[:service_sid], 60 channel_sid: @solution[:channel_sid], 61 ) 62 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/ip_messaging/v2/service/channel/member.rb 104 def each 105 limits = @version.read_limits 106 107 page = self.page(page_size: limits[:page_size], ) 108 109 @version.stream(page, 110 limit: limits[:limit], 111 page_limit: limits[:page_limit]).each {|x| yield x} 112 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/ip_messaging/v2/service/channel/member.rb 140 def get_page(target_url) 141 response = @version.domain.request( 142 'GET', 143 target_url 144 ) 145 MemberPage.new(@version, response, @solution) 146 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 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
# File lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb 76 def list(identity: :unset, limit: nil, page_size: nil) 77 self.stream(identity: identity, limit: limit, page_size: page_size).entries 78 end
Retrieve a single page of MemberInstance
records from the API. Request
is executed immediately. @param [Array] identity The identity @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/ip_messaging/v2/service/channel/member.rb 122 def page(identity: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 123 params = Twilio::Values.of({ 124 'Identity' => Twilio.serialize_list(identity) { |e| e }, 125 'PageToken' => page_token, 126 'Page' => page_number, 127 'PageSize' => page_size, 128 }) 129 130 response = @version.page('GET', @uri, params: params) 131 132 MemberPage.new(@version, response, @solution) 133 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 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 [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb 92 def stream(identity: :unset, limit: nil, page_size: nil) 93 limits = @version.read_limits(limit, page_size) 94 95 page = self.page(identity: identity, page_size: limits[:page_size], ) 96 97 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 98 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb 150 def to_s 151 '#<Twilio.IpMessaging.V2.MemberList>' 152 end