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.



196
197
198
199
200
201
202
203
204
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 196

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



208
209
210
211
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 208

def delete

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

#fetchTriggerInstance

Fetch the TriggerInstance

Returns:



216
217
218
219
220
221
222
223
224
225
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 216

def fetch

    payload = @version.fetch('GET', @uri)
    TriggerInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



264
265
266
267
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 264

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

#to_sObject

Provide a user friendly representation



257
258
259
260
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 257

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:



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb', line 233

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

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

    payload = @version.update('POST', @uri, data: data)
    TriggerInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end