class Twilio::REST::Conversations::V1::ServiceContext::UserList

Public Class Methods

new(version, chat_service_sid: nil) click to toggle source

Initialize the UserList @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
User resource is associated with.

@return [UserList] UserList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/conversations/v1/service/user.rb
22 def initialize(version, chat_service_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {chat_service_sid: chat_service_sid}
27   @uri = "/Services/#{@solution[:chat_service_sid]}/Users"
28 end

Public Instance Methods

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

Create the UserInstance @param [String] identity The application-defined string that uniquely identifies

the resource's User within the {Conversation
Service}[https://www.twilio.com/docs/conversations/api/service-resource]. This
value is often a username or an email address, and is case-sensitive.

@param [String] friendly_name The string that you assigned to describe the

resource.

@param [String] attributes The JSON Object string that stores

application-specific data. If attributes have not been set, `{}` is returned.

@param [String] role_sid The SID of a service-level

{Role}[https://www.twilio.com/docs/conversations/api/role-resource] to assign to
the user.

@param [user.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

@return [UserInstance] Created UserInstance

   # File lib/twilio-ruby/rest/conversations/v1/service/user.rb
46 def create(identity: nil, friendly_name: :unset, attributes: :unset, role_sid: :unset, x_twilio_webhook_enabled: :unset)
47   data = Twilio::Values.of({
48       'Identity' => identity,
49       'FriendlyName' => friendly_name,
50       'Attributes' => attributes,
51       'RoleSid' => role_sid,
52   })
53   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
54 
55   payload = @version.create('POST', @uri, data: data, headers: headers)
56 
57   UserInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
58 end
each() { |x| ... } click to toggle source

When passed a block, yields UserInstance 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/user.rb
 98 def each
 99   limits = @version.read_limits
100 
101   page = self.page(page_size: limits[:page_size], )
102 
103   @version.stream(page,
104                   limit: limits[:limit],
105                   page_limit: limits[:page_limit]).each {|x| yield x}
106 end
get_page(target_url) click to toggle source

Retrieve a single page of UserInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of UserInstance

    # File lib/twilio-ruby/rest/conversations/v1/service/user.rb
132 def get_page(target_url)
133   response = @version.domain.request(
134       'GET',
135       target_url
136   )
137   UserPage.new(@version, response, @solution)
138 end
list(limit: nil, page_size: nil) click to toggle source

Lists UserInstance 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/user.rb
71 def list(limit: nil, page_size: nil)
72   self.stream(limit: limit, page_size: page_size).entries
73 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of UserInstance 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 UserInstance

    # File lib/twilio-ruby/rest/conversations/v1/service/user.rb
115 def page(page_token: :unset, page_number: :unset, page_size: :unset)
116   params = Twilio::Values.of({
117       'PageToken' => page_token,
118       'Page' => page_number,
119       'PageSize' => page_size,
120   })
121 
122   response = @version.page('GET', @uri, params: params)
123 
124   UserPage.new(@version, response, @solution)
125 end
stream(limit: nil, page_size: nil) click to toggle source

Streams UserInstance 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/user.rb
86 def stream(limit: nil, page_size: nil)
87   limits = @version.read_limits(limit, page_size)
88 
89   page = self.page(page_size: limits[:page_size], )
90 
91   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
92 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/conversations/v1/service/user.rb
142 def to_s
143   '#<Twilio.Conversations.V1.UserList>'
144 end