Class: Twilio::REST::Events::V1::SubscriptionContext::SubscribedEventContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, subscription_sid, type) ⇒ SubscribedEventContext

Initialize the SubscribedEventContext

Parameters:

  • version (Version)

    Version that contains the resource

  • subscription_sid (String)

    The unique SID identifier of the Subscription.

  • type (String)

    Type of event being subscribed to.



226
227
228
229
230
231
232
233
234
235
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 226

def initialize(version, subscription_sid, type)
    super(version)
    

    # Path Solution
    @solution = { subscription_sid: subscription_sid, type: type,  }
    @uri = "/Subscriptions/#{@solution[:subscription_sid]}/SubscribedEvents/#{@solution[:type]}"

    
end

Instance Method Details

#deleteBoolean

Delete the SubscribedEventInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



239
240
241
242
243
244
245
246
247
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 239

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 SubscribedEventInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 252

def 

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

#fetchSubscribedEventInstance

Fetch the SubscribedEventInstance

Returns:



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 271

def fetch

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

#fetch_with_metadataSubscribedEventInstance

Fetch the SubscribedEventInstanceMetadata

Returns:



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 291

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    subscribed_event_instance = SubscribedEventInstance.new(
        @version,
        response.body,
        subscription_sid: @solution[:subscription_sid],
        type: @solution[:type],
    )
    .new(
        @version,
        subscribed_event_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



384
385
386
387
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 384

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

#to_sObject

Provide a user friendly representation



377
378
379
380
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 377

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

#update(schema_version: :unset) ⇒ SubscribedEventInstance

Update the SubscribedEventInstance

Parameters:

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

    The schema version that the Subscription should use.

Returns:



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 318

def update(
    schema_version: :unset
)

    data = Twilio::Values.of({
        'SchemaVersion' => schema_version,
    })

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

#update_with_metadata(schema_version: :unset) ⇒ SubscribedEventInstance

Update the SubscribedEventInstanceMetadata

Parameters:

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

    The schema version that the Subscription should use.

Returns:



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 345

def (
  schema_version: :unset
)

    data = Twilio::Values.of({
        'SchemaVersion' => schema_version,
    })

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