class Twilio::REST::Chat::V1::ServiceContext::ChannelContext::MemberList

Public Class Methods

new(version, service_sid: nil, channel_sid: nil) click to toggle source

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/api/chat/rest/services] the resource is
associated with.

@param [String] channel_sid The unique ID of the

{Channel}[https://www.twilio.com/docs/api/chat/rest/channels] for the member.

@return [MemberList] MemberList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/chat/v1/service/channel/member.rb
25 def initialize(version, service_sid: nil, channel_sid: nil)
26   super(version)
27 
28   # Path Solution
29   @solution = {service_sid: service_sid, channel_sid: channel_sid}
30   @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Members"
31 end

Public Instance Methods

create(identity: nil, role_sid: :unset) click to toggle source

Create the MemberInstance @param [String] identity The `identity` value that uniquely identifies the new

resource's {User}[https://www.twilio.com/docs/api/chat/rest/v1/user] within the
{Service}[https://www.twilio.com/docs/api/chat/rest/services]. See {access
tokens}[https://www.twilio.com/docs/api/chat/guides/create-tokens] for more
details.

@param [String] role_sid The SID of the

{Role}[https://www.twilio.com/docs/api/chat/rest/roles] to assign to the member.
The default roles are those specified on the
{Service}[https://www.twilio.com/docs/chat/api/services].

@return [MemberInstance] Created MemberInstance

   # File lib/twilio-ruby/rest/chat/v1/service/channel/member.rb
45 def create(identity: nil, role_sid: :unset)
46   data = Twilio::Values.of({'Identity' => identity, 'RoleSid' => role_sid, })
47 
48   payload = @version.create('POST', @uri, data: data)
49 
50   MemberInstance.new(
51       @version,
52       payload,
53       service_sid: @solution[:service_sid],
54       channel_sid: @solution[:channel_sid],
55   )
56 end
each() { |x| ... } click to toggle source

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/v1/service/channel/member.rb
106 def each
107   limits = @version.read_limits
108 
109   page = self.page(page_size: limits[:page_size], )
110 
111   @version.stream(page,
112                   limit: limits[:limit],
113                   page_limit: limits[:page_limit]).each {|x| yield x}
114 end
get_page(target_url) click to toggle source

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/v1/service/channel/member.rb
146 def get_page(target_url)
147   response = @version.domain.request(
148       'GET',
149       target_url
150   )
151   MemberPage.new(@version, response, @solution)
152 end
list(identity: :unset, limit: nil, page_size: nil) click to toggle source

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/api/chat/rest/v1/user]'s `identity` value of
the resources to read. See {access
tokens}[https://www.twilio.com/docs/api/chat/guides/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/v1/service/channel/member.rb
74 def list(identity: :unset, limit: nil, page_size: nil)
75   self.stream(identity: identity, limit: limit, page_size: page_size).entries
76 end
page(identity: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of MemberInstance records from the API. Request is executed immediately. @param [Array] identity The

{User}[https://www.twilio.com/docs/api/chat/rest/v1/user]'s `identity` value of
the resources to read. See {access
tokens}[https://www.twilio.com/docs/api/chat/guides/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/v1/service/channel/member.rb
128 def page(identity: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
129   params = Twilio::Values.of({
130       'Identity' => Twilio.serialize_list(identity) { |e| e },
131       'PageToken' => page_token,
132       'Page' => page_number,
133       'PageSize' => page_size,
134   })
135 
136   response = @version.page('GET', @uri, params: params)
137 
138   MemberPage.new(@version, response, @solution)
139 end
stream(identity: :unset, limit: nil, page_size: nil) click to toggle source

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/api/chat/rest/v1/user]'s `identity` value of
the resources to read. See {access
tokens}[https://www.twilio.com/docs/api/chat/guides/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/v1/service/channel/member.rb
 94 def stream(identity: :unset, limit: nil, page_size: nil)
 95   limits = @version.read_limits(limit, page_size)
 96 
 97   page = self.page(identity: identity, page_size: limits[:page_size], )
 98 
 99   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
100 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel/member.rb
156 def to_s
157   '#<Twilio.Chat.V1.MemberList>'
158 end