Class: Twilio::REST::Conversations::V1::UserContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/user.rb,
lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb

Defined Under Namespace

Classes: UserConversationContext, UserConversationInstance, UserConversationList, UserConversationPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ UserContext

Initialize the UserContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the User resource to update. This value can be either the ‘sid` or the `identity` of the User resource to update.



172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/conversations/v1/user.rb', line 172

def initialize(version, sid)
    super(version)

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

    # Dependents
    @user_conversations = nil
end

Instance Method Details

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the UserInstance

Parameters:

  • x_twilio_webhook_enabled (UserEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



186
187
188
189
190
191
192
193
194
195
# File 'lib/twilio-ruby/rest/conversations/v1/user.rb', line 186

def delete(
    x_twilio_webhook_enabled: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchUserInstance

Fetch the UserInstance

Returns:



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/twilio-ruby/rest/conversations/v1/user.rb', line 200

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    UserInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



279
280
281
282
# File 'lib/twilio-ruby/rest/conversations/v1/user.rb', line 279

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

#to_sObject

Provide a user friendly representation



272
273
274
275
# File 'lib/twilio-ruby/rest/conversations/v1/user.rb', line 272

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

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

Update the UserInstance

Parameters:

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

    The string that you assigned to describe the resource.

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

    The JSON Object string that stores application-specific data. If attributes have not been set, ‘{}` is returned.

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

    The SID of a service-level [Role](www.twilio.com/docs/conversations/api/role-resource) to assign to the user.

  • x_twilio_webhook_enabled (UserEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/twilio-ruby/rest/conversations/v1/user.rb', line 223

def update(
    friendly_name: :unset, 
    attributes: :unset, 
    role_sid: :unset, 
    x_twilio_webhook_enabled: :unset
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    UserInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#user_conversations(conversation_sid = :unset) ⇒ UserConversationList, UserConversationContext

Access the user_conversations

Returns:

Raises:

  • (ArgumentError)


254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/twilio-ruby/rest/conversations/v1/user.rb', line 254

def user_conversations(conversation_sid=:unset)

    raise ArgumentError, 'conversation_sid cannot be nil' if conversation_sid.nil?

    if conversation_sid != :unset
        return UserConversationContext.new(@version, @solution[:sid],conversation_sid )
    end

    unless @user_conversations
        @user_conversations = UserConversationList.new(
            @version, user_sid: @solution[:sid], )
    end

 @user_conversations
end