class Twilio::REST::Conversations::V1::ServiceContext::RoleList

Public Class Methods

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

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

@return [RoleList] RoleList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/conversations/v1/service/role.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]}/Roles"
28 end

Public Instance Methods

create(friendly_name: nil, type: nil, permission: nil) click to toggle source

Create the RoleInstance @param [String] friendly_name A descriptive string that you create to describe

the new resource. It can be up to 64 characters long.

@param [role.RoleType] type The type of role. Can be: `conversation` for

{Conversation}[https://www.twilio.com/docs/conversations/api/conversation-resource]
roles or `service` for {Conversation
Service}[https://www.twilio.com/docs/conversations/api/service-resource] roles.

@param [Array] permission A permission that you grant to the new role.

Only one permission can be granted per parameter. To assign more than one
permission, repeat this parameter for each permission value. The values for this
parameter depend on the role's `type`.

@return [RoleInstance] Created RoleInstance

   # File lib/twilio-ruby/rest/conversations/v1/service/role.rb
43 def create(friendly_name: nil, type: nil, permission: nil)
44   data = Twilio::Values.of({
45       'FriendlyName' => friendly_name,
46       'Type' => type,
47       'Permission' => Twilio.serialize_list(permission) { |e| e },
48   })
49 
50   payload = @version.create('POST', @uri, data: data)
51 
52   RoleInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
53 end
each() { |x| ... } click to toggle source

When passed a block, yields RoleInstance 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/role.rb
 93 def each
 94   limits = @version.read_limits
 95 
 96   page = self.page(page_size: limits[:page_size], )
 97 
 98   @version.stream(page,
 99                   limit: limits[:limit],
100                   page_limit: limits[:page_limit]).each {|x| yield x}
101 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/conversations/v1/service/role.rb
127 def get_page(target_url)
128   response = @version.domain.request(
129       'GET',
130       target_url
131   )
132   RolePage.new(@version, response, @solution)
133 end
list(limit: nil, page_size: nil) click to toggle source

Lists RoleInstance 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/role.rb
66 def list(limit: nil, page_size: nil)
67   self.stream(limit: limit, page_size: page_size).entries
68 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

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

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

Streams RoleInstance 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/role.rb
81 def stream(limit: nil, page_size: nil)
82   limits = @version.read_limits(limit, page_size)
83 
84   page = self.page(page_size: limits[:page_size], )
85 
86   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
87 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/conversations/v1/service/role.rb
137 def to_s
138   '#<Twilio.Conversations.V1.RoleList>'
139 end