class Twilio::REST::Conversations::V1::UserList
Public Class Methods
Initialize the UserList
@param [Version] version Version
that contains the resource @return [UserList] UserList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/conversations/v1/user.rb 18 def initialize(version) 19 super(version) 20 21 # Path Solution 22 @solution = {} 23 @uri = "/Users" 24 end
Public Instance Methods
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/user.rb 42 def create(identity: nil, friendly_name: :unset, attributes: :unset, role_sid: :unset, x_twilio_webhook_enabled: :unset) 43 data = Twilio::Values.of({ 44 'Identity' => identity, 45 'FriendlyName' => friendly_name, 46 'Attributes' => attributes, 47 'RoleSid' => role_sid, 48 }) 49 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 50 51 payload = @version.create('POST', @uri, data: data, headers: headers) 52 53 UserInstance.new(@version, payload, ) 54 end
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/user.rb 94 def each 95 limits = @version.read_limits 96 97 page = self.page(page_size: limits[:page_size], ) 98 99 @version.stream(page, 100 limit: limits[:limit], 101 page_limit: limits[:page_limit]).each {|x| yield x} 102 end
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/user.rb 128 def get_page(target_url) 129 response = @version.domain.request( 130 'GET', 131 target_url 132 ) 133 UserPage.new(@version, response, @solution) 134 end
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/user.rb 67 def list(limit: nil, page_size: nil) 68 self.stream(limit: limit, page_size: page_size).entries 69 end
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/user.rb 111 def page(page_token: :unset, page_number: :unset, page_size: :unset) 112 params = Twilio::Values.of({ 113 'PageToken' => page_token, 114 'Page' => page_number, 115 'PageSize' => page_size, 116 }) 117 118 response = @version.page('GET', @uri, params: params) 119 120 UserPage.new(@version, response, @solution) 121 end
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/user.rb 82 def stream(limit: nil, page_size: nil) 83 limits = @version.read_limits(limit, page_size) 84 85 page = self.page(page_size: limits[:page_size], ) 86 87 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 88 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/user.rb 138 def to_s 139 '#<Twilio.Conversations.V1.UserList>' 140 end