Class: Twilio::REST::Notify::V1::ServiceContext::BindingContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/notify/v1/service/binding.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ BindingContext

Initialize the BindingContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the [Service](www.twilio.com/docs/notify/api/service-resource) to fetch the resource from.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Binding resource to fetch.



300
301
302
303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 300

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

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

    
end

Instance Method Details

#deleteBoolean

Delete the BindingInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



313
314
315
316
317
318
319
320
321
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 313

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 BindingInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 326

def 

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

#fetchBindingInstance

Fetch the BindingInstance

Returns:



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 345

def fetch

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

#fetch_with_metadataBindingInstance

Fetch the BindingInstanceMetadata

Returns:



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 365

def 

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

#inspectObject

Provide a detailed, user friendly representation



398
399
400
401
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 398

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

#to_sObject

Provide a user friendly representation



391
392
393
394
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 391

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