Class: Twilio::REST::Api::V2010::AccountContext::UsageList::TriggerContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ TriggerContext

Initialize the TriggerContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the UsageTrigger resources to update.

  • sid (String)

    The Twilio-provided string that uniquely identifies the UsageTrigger resource to update.



289
290
291
292
293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 289

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

    # Path Solution
    @solution = { account_sid: , sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/Usage/Triggers/#{@solution[:sid]}.json"

    
end

Instance Method Details

#deleteBoolean

Delete the TriggerInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



302
303
304
305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 302

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the TriggerInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 315

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      trigger_instance = TriggerInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      TriggerInstanceMetadata.new(@version, trigger_instance, response.headers, response.status_code)
end

#fetchTriggerInstance

Fetch the TriggerInstance

Returns:



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 334

def fetch

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

#fetch_with_metadataTriggerInstance

Fetch the TriggerInstanceMetadata

Returns:



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 354

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    trigger_instance = TriggerInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    TriggerInstanceMetadata.new(
        @version,
        trigger_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



459
460
461
462
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 459

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

#to_sObject

Provide a user friendly representation



452
453
454
455
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 452

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

#update(callback_method: :unset, callback_url: :unset, friendly_name: :unset) ⇒ TriggerInstance

Update the TriggerInstance

Parameters:

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

    The HTTP method we should use to call ‘callback_url`. Can be: `GET` or `POST` and the default is `POST`.

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

    The URL we should call using ‘callback_method` when the trigger fires.

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

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

Returns:



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 383

def update(
  callback_method: :unset, 
  callback_url: :unset, 
  friendly_name: :unset
)

    data = Twilio::Values.of({
        'CallbackMethod' => callback_method,
        'CallbackUrl' => callback_url,
        'FriendlyName' => friendly_name,
    })

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

#update_with_metadata(callback_method: :unset, callback_url: :unset, friendly_name: :unset) ⇒ TriggerInstance

Update the TriggerInstanceMetadata

Parameters:

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

    The HTTP method we should use to call ‘callback_url`. Can be: `GET` or `POST` and the default is `POST`.

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

    The URL we should call using ‘callback_method` when the trigger fires.

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

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

Returns:



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 416

def (
  callback_method: :unset, 
  callback_url: :unset, 
  friendly_name: :unset
)

    data = Twilio::Values.of({
        'CallbackMethod' => callback_method,
        'CallbackUrl' => callback_url,
        'FriendlyName' => friendly_name,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    trigger_instance = TriggerInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    TriggerInstanceMetadata.new(
        @version,
        trigger_instance,
        response.headers,
        response.status_code
    )
end