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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, account_sid: nil, sid: nil) ⇒ TriggerInstance

Initialize the TriggerInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource.

  • sid (String) (defaults to: nil)

    The usage-trigger Sid that uniquely identifies this resource



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 322

def initialize(version, payload, account_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'api_version' => payload['api_version'],
      'callback_method' => payload['callback_method'],
      'callback_url' => payload['callback_url'],
      'current_value' => payload['current_value'],
      'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
      'date_fired' => Twilio.deserialize_rfc2822(payload['date_fired']),
      'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
      'friendly_name' => payload['friendly_name'],
      'recurring' => payload['recurring'],
      'sid' => payload['sid'],
      'trigger_by' => payload['trigger_by'],
      'trigger_value' => payload['trigger_value'],
      'uri' => payload['uri'],
      'usage_category' => payload['usage_category'],
      'usage_record_uri' => payload['usage_record_uri'],
  }

  # Context
  @instance_context = nil
  @params = {
      'account_sid' => ,
      'sid' => sid || @properties['sid'],
  }
end

Instance Method Details

#account_sidString

Returns The account this trigger monitors.

Returns:

  • (String)

    The account this trigger monitors.



370
371
372
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 370

def 
  @properties['account_sid']
end

#api_versionString

Returns The api_version.

Returns:

  • (String)

    The api_version



376
377
378
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 376

def api_version
  @properties['api_version']
end

#callback_methodString

Returns HTTP method to use with callback_url.

Returns:

  • (String)

    HTTP method to use with callback_url



382
383
384
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 382

def callback_method
  @properties['callback_method']
end

#callback_urlString

Returns URL Twilio will request when the trigger fires.

Returns:

  • (String)

    URL Twilio will request when the trigger fires



388
389
390
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 388

def callback_url
  @properties['callback_url']
end

#contextTriggerContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



357
358
359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 357

def context
  unless @instance_context
    @instance_context = TriggerContext.new(
        @version,
        @params['account_sid'],
        @params['sid'],
    )
  end
  @instance_context
end

#current_valueString

Returns The current value of the field the trigger is watching.

Returns:

  • (String)

    The current value of the field the trigger is watching.



394
395
396
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 394

def current_value
  @properties['current_value']
end

#date_createdTime

Returns The date this resource was created.

Returns:

  • (Time)

    The date this resource was created



400
401
402
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 400

def date_created
  @properties['date_created']
end

#date_firedTime

Returns The date the trigger was last fired.

Returns:

  • (Time)

    The date the trigger was last fired



406
407
408
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 406

def date_fired
  @properties['date_fired']
end

#date_updatedTime

Returns The date this resource was last updated.

Returns:

  • (Time)

    The date this resource was last updated



412
413
414
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 412

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the TriggerInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



491
492
493
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 491

def delete
  context.delete
end

#fetchTriggerInstance

Fetch a TriggerInstance

Returns:



467
468
469
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 467

def fetch
  context.fetch
end

#friendly_nameString

Returns A user-specified, human-readable name for the trigger.

Returns:

  • (String)

    A user-specified, human-readable name for the trigger.



418
419
420
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 418

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



504
505
506
507
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 504

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Api.V2010.TriggerInstance #{values}>"
end

#recurringtrigger.Recurring

Returns How this trigger recurs.

Returns:

  • (trigger.Recurring)

    How this trigger recurs



424
425
426
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 424

def recurring
  @properties['recurring']
end

#sidString

Returns The trigger’s unique Sid.

Returns:

  • (String)

    The trigger’s unique Sid



430
431
432
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 430

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



497
498
499
500
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 497

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Api.V2010.TriggerInstance #{values}>"
end

#trigger_bytrigger.TriggerField

Returns The field in the UsageRecord that fires the trigger.

Returns:

  • (trigger.TriggerField)

    The field in the UsageRecord that fires the trigger



436
437
438
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 436

def trigger_by
  @properties['trigger_by']
end

#trigger_valueString

Returns the value at which the trigger will fire.

Returns:

  • (String)

    the value at which the trigger will fire



442
443
444
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 442

def trigger_value
  @properties['trigger_value']
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 Twilio will use when making a request to the CallbackUrl. GET or POST.

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

    Twilio will make a request to this url when the trigger fires.

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

    A user-specified, human-readable name for the trigger.

Returns:



480
481
482
483
484
485
486
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 480

def update(callback_method: :unset, callback_url: :unset, friendly_name: :unset)
  context.update(
      callback_method: callback_method,
      callback_url: callback_url,
      friendly_name: friendly_name,
  )
end

#uriString

Returns The URI for this resource.

Returns:

  • (String)

    The URI for this resource



448
449
450
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 448

def uri
  @properties['uri']
end

#usage_categorytrigger.UsageCategory

Returns The usage category the trigger watches.

Returns:

  • (trigger.UsageCategory)

    The usage category the trigger watches



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

def usage_category
  @properties['usage_category']
end

#usage_record_uriString

Returns The URI of the UsageRecord this trigger is watching.

Returns:

  • (String)

    The URI of the UsageRecord this trigger is watching



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

def usage_record_uri
  @properties['usage_record_uri']
end