Class: Twilio::REST::Trunking::V1::TrunkContext::OriginationUrlContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, trunk_sid, sid) ⇒ OriginationUrlContext

Initialize the OriginationUrlContext

Parameters:

  • version (Version)

    Version that contains the resource

  • trunk_sid (String)

    The SID of the Trunk from which to update the OriginationUrl.

  • sid (String)

    The unique string that we created to identify the OriginationUrl resource to update.



252
253
254
255
256
257
258
259
260
261
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 252

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

    # Path Solution
    @solution = { trunk_sid: trunk_sid, sid: sid,  }
    @uri = "/Trunks/#{@solution[:trunk_sid]}/OriginationUrls/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the OriginationUrlInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



265
266
267
268
269
270
271
272
273
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 265

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 OriginationUrlInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 278

def 

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

#fetchOriginationUrlInstance

Fetch the OriginationUrlInstance

Returns:



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 297

def fetch

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

#fetch_with_metadataOriginationUrlInstance

Fetch the OriginationUrlInstanceMetadata

Returns:



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

def 

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

#inspectObject

Provide a detailed, user friendly representation



434
435
436
437
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 434

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

#to_sObject

Provide a user friendly representation



427
428
429
430
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 427

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

#update(weight: :unset, priority: :unset, enabled: :unset, friendly_name: :unset, sip_url: :unset) ⇒ OriginationUrlInstance

Update the OriginationUrlInstance

Parameters:

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

    The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority.

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

    The relative importance of the URI. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI.

  • enabled (Boolean) (defaults to: :unset)

    Whether the URL is enabled. The default is ‘true`.

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

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

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

    The SIP address you want Twilio to route your Origination calls to. This must be a ‘sip:` schema. `sips` is NOT supported.

Returns:



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
373
374
375
376
377
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 348

def update(
  weight: :unset, 
  priority: :unset, 
  enabled: :unset, 
  friendly_name: :unset, 
  sip_url: :unset
)

    data = Twilio::Values.of({
        'Weight' => weight,
        'Priority' => priority,
        'Enabled' => enabled,
        'FriendlyName' => friendly_name,
        'SipUrl' => sip_url,
    })

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

#update_with_metadata(weight: :unset, priority: :unset, enabled: :unset, friendly_name: :unset, sip_url: :unset) ⇒ OriginationUrlInstance

Update the OriginationUrlInstanceMetadata

Parameters:

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

    The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority.

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

    The relative importance of the URI. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI.

  • enabled (Boolean) (defaults to: :unset)

    Whether the URL is enabled. The default is ‘true`.

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

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

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

    The SIP address you want Twilio to route your Origination calls to. This must be a ‘sip:` schema. `sips` is NOT supported.

Returns:



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 387

def (
  weight: :unset, 
  priority: :unset, 
  enabled: :unset, 
  friendly_name: :unset, 
  sip_url: :unset
)

    data = Twilio::Values.of({
        'Weight' => weight,
        'Priority' => priority,
        'Enabled' => enabled,
        'FriendlyName' => friendly_name,
        'SipUrl' => sip_url,
    })

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