Class: Twilio::REST::IpMessaging::V1::ServiceContext::UserContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb,
lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb

Defined Under Namespace

Classes: UserChannelInstance, UserChannelList, UserChannelPage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ UserContext

Initialize the UserContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the [Service](www.twilio.com/docs/api/chat/rest/services) to fetch the resource from.

  • sid (String)

    The Twilio-provided string that uniquely identifies the User resource to fetch.



191
192
193
194
195
196
197
198
199
200
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 191

def initialize(version, service_sid, sid)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:sid]}"

  # Dependents
  @user_channels = nil
end

Instance Method Details

#deleteBoolean

Deletes the UserInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



220
221
222
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 220

def delete
  @version.delete('delete', @uri)
end

#fetchUserInstance

Fetch a UserInstance

Returns:



205
206
207
208
209
210
211
212
213
214
215
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 205

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  UserInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation



274
275
276
277
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 274

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.IpMessaging.V1.UserContext #{context}>"
end

#to_sObject

Provide a user friendly representation



267
268
269
270
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 267

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.IpMessaging.V1.UserContext #{context}>"
end

#update(role_sid: :unset, attributes: :unset, friendly_name: :unset) ⇒ UserInstance

Update the UserInstance

Parameters:

  • role_sid (String) (defaults to: :unset)

    The SID of the [Role](www.twilio.com/docs/api/chat/rest/roles) assigned to this user.

  • attributes (String) (defaults to: :unset)

    A valid JSON string that contains application-specific data.

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the resource. It is often used for display purposes.

Returns:



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 233

def update(role_sid: :unset, attributes: :unset, friendly_name: :unset)
  data = Twilio::Values.of({
      'RoleSid' => role_sid,
      'Attributes' => attributes,
      'FriendlyName' => friendly_name,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  UserInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
end

#user_channelsUserChannelList, UserChannelContext

Access the user_channels

Returns:



253
254
255
256
257
258
259
260
261
262
263
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 253

def user_channels
  unless @user_channels
    @user_channels = UserChannelList.new(
        @version,
        service_sid: @solution[:service_sid],
        user_sid: @solution[:sid],
    )
  end

  @user_channels
end