class Twilio::REST::Chat::V2::ServiceContext::ChannelContext::InviteList
Public Class Methods
Initialize the InviteList
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the
{Service}[https://www.twilio.com/docs/chat/rest/service-resource] the Invite resource is associated with.
@param [String] channel_sid The SID of the
{Channel}[https://www.twilio.com/docs/chat/channels] the Invite resource belongs to.
@return [InviteList] InviteList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb 26 def initialize(version, service_sid: nil, channel_sid: nil) 27 super(version) 28 29 # Path Solution 30 @solution = {service_sid: service_sid, channel_sid: channel_sid} 31 @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Invites" 32 end
Public Instance Methods
Create the InviteInstance
@param [String] identity The `identity` value that uniquely identifies the new
resource's {User}[https://www.twilio.com/docs/chat/rest/user-resource] within the {Service}[https://www.twilio.com/docs/chat/rest/service-resource]. See {access tokens}[https://www.twilio.com/docs/chat/create-tokens] for more info.
@param [String] role_sid The SID of the
{Role}[https://www.twilio.com/docs/chat/rest/role-resource] assigned to the new member.
@return [InviteInstance] Created InviteInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb 44 def create(identity: nil, role_sid: :unset) 45 data = Twilio::Values.of({'Identity' => identity, 'RoleSid' => role_sid, }) 46 47 payload = @version.create('POST', @uri, data: data) 48 49 InviteInstance.new( 50 @version, 51 payload, 52 service_sid: @solution[:service_sid], 53 channel_sid: @solution[:channel_sid], 54 ) 55 end
When passed a block, yields InviteInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb 103 def each 104 limits = @version.read_limits 105 106 page = self.page(page_size: limits[:page_size], ) 107 108 @version.stream(page, 109 limit: limits[:limit], 110 page_limit: limits[:page_limit]).each {|x| yield x} 111 end
Retrieve a single page of InviteInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of InviteInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb 142 def get_page(target_url) 143 response = @version.domain.request( 144 'GET', 145 target_url 146 ) 147 InvitePage.new(@version, response, @solution) 148 end
Lists InviteInstance
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/chat/rest/user-resource]'s `identity` value of the resources to read. See {access tokens}[https://www.twilio.com/docs/chat/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/v2/service/channel/invite.rb 72 def list(identity: :unset, limit: nil, page_size: nil) 73 self.stream(identity: identity, limit: limit, page_size: page_size).entries 74 end
Retrieve a single page of InviteInstance
records from the API. Request
is executed immediately. @param [Array] identity The
{User}[https://www.twilio.com/docs/chat/rest/user-resource]'s `identity` value of the resources to read. See {access tokens}[https://www.twilio.com/docs/chat/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 InviteInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb 124 def page(identity: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 125 params = Twilio::Values.of({ 126 'Identity' => Twilio.serialize_list(identity) { |e| e }, 127 'PageToken' => page_token, 128 'Page' => page_number, 129 'PageSize' => page_size, 130 }) 131 132 response = @version.page('GET', @uri, params: params) 133 134 InvitePage.new(@version, response, @solution) 135 end
Streams InviteInstance
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/chat/rest/user-resource]'s `identity` value of the resources to read. See {access tokens}[https://www.twilio.com/docs/chat/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/v2/service/channel/invite.rb 91 def stream(identity: :unset, limit: nil, page_size: nil) 92 limits = @version.read_limits(limit, page_size) 93 94 page = self.page(identity: identity, page_size: limits[:page_size], ) 95 96 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 97 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb 152 def to_s 153 '#<Twilio.Chat.V2.InviteList>' 154 end