class Twilio::REST::Chat::V2::ServiceContext::UserContext

Public Class Methods

new(version, service_sid, sid) click to toggle source

Initialize the UserContext @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] to fetch the
User resource from.

@param [String] sid The SID of the User resource to fetch. This value can be

either the `sid` or the `identity` of the User resource to fetch.

@return [UserContext] UserContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
187 def initialize(version, service_sid, sid)
188   super(version)
189 
190   # Path Solution
191   @solution = {service_sid: service_sid, sid: sid, }
192   @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:sid]}"
193 
194   # Dependents
195   @user_channels = nil
196   @user_bindings = nil
197 end

Public Instance Methods

delete() click to toggle source

Delete the UserInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
211 def delete
212    @version.delete('DELETE', @uri)
213 end
fetch() click to toggle source

Fetch the UserInstance @return [UserInstance] Fetched UserInstance

    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
202 def fetch
203   payload = @version.fetch('GET', @uri)
204 
205   UserInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
206 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
293 def inspect
294   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
295   "#<Twilio.Chat.V2.UserContext #{context}>"
296 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
286 def to_s
287   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
288   "#<Twilio.Chat.V2.UserContext #{context}>"
289 end
update(role_sid: :unset, attributes: :unset, friendly_name: :unset, x_twilio_webhook_enabled: :unset) click to toggle source

Update the UserInstance @param [String] role_sid The SID of the

{Role}[https://www.twilio.com/docs/chat/rest/role-resource] to assign to the
User.

@param [String] attributes A valid JSON string that contains

application-specific data.

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

the resource. It is often used for display purposes.

@param [user.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

@return [UserInstance] Updated UserInstance

    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
227 def update(role_sid: :unset, attributes: :unset, friendly_name: :unset, x_twilio_webhook_enabled: :unset)
228   data = Twilio::Values.of({
229       'RoleSid' => role_sid,
230       'Attributes' => attributes,
231       'FriendlyName' => friendly_name,
232   })
233   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
234 
235   payload = @version.update('POST', @uri, data: data, headers: headers)
236 
237   UserInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
238 end
user_bindings(sid=:unset) click to toggle source

Access the user_bindings @return [UserBindingList] @return [UserBindingContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
266 def user_bindings(sid=:unset)
267   raise ArgumentError, 'sid cannot be nil' if sid.nil?
268 
269   if sid != :unset
270     return UserBindingContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
271   end
272 
273   unless @user_bindings
274     @user_bindings = UserBindingList.new(
275         @version,
276         service_sid: @solution[:service_sid],
277         user_sid: @solution[:sid],
278     )
279   end
280 
281   @user_bindings
282 end
user_channels(channel_sid=:unset) click to toggle source

Access the user_channels @return [UserChannelList] @return [UserChannelContext] if channel_sid was passed.

    # File lib/twilio-ruby/rest/chat/v2/service/user.rb
244 def user_channels(channel_sid=:unset)
245   raise ArgumentError, 'channel_sid cannot be nil' if channel_sid.nil?
246 
247   if channel_sid != :unset
248     return UserChannelContext.new(@version, @solution[:service_sid], @solution[:sid], channel_sid, )
249   end
250 
251   unless @user_channels
252     @user_channels = UserChannelList.new(
253         @version,
254         service_sid: @solution[:service_sid],
255         user_sid: @solution[:sid],
256     )
257   end
258 
259   @user_channels
260 end