Class: Twilio::REST::Trunking::V1::TrunkContext::OriginationUrlInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, trunk_sid: nil, sid: nil) ⇒ OriginationUrlInstance

Initialize the OriginationUrlInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • trunk_sid (String) (defaults to: nil)

    The SID of the Trunk that owns the Origination URL.

  • sid (String) (defaults to: nil)

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



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 286

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'sid' => payload['sid'],
      'trunk_sid' => payload['trunk_sid'],
      'weight' => payload['weight'].to_i,
      'enabled' => payload['enabled'],
      'sip_url' => payload['sip_url'],
      'friendly_name' => payload['friendly_name'],
      'priority' => payload['priority'].to_i,
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



322
323
324
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 322

def 
  @properties['account_sid']
end

#contextOriginationUrlContext

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

Returns:



313
314
315
316
317
318
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 313

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

#date_createdTime

Returns The RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was created



370
371
372
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 370

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was last updated



376
377
378
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 376

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the OriginationUrlInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



396
397
398
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 396

def delete
  context.delete
end

#enabledBoolean

Returns Whether the URL is enabled.

Returns:

  • (Boolean)

    Whether the URL is enabled



346
347
348
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 346

def enabled
  @properties['enabled']
end

#fetchOriginationUrlInstance

Fetch a OriginationUrlInstance

Returns:



389
390
391
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 389

def fetch
  context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource



358
359
360
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 358

def friendly_name
  @properties['friendly_name']
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
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Trunking.V1.OriginationUrlInstance #{values}>"
end

#priorityString

Returns The relative importance of the URI.

Returns:

  • (String)

    The relative importance of the URI



364
365
366
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 364

def priority
  @properties['priority']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



328
329
330
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 328

def sid
  @properties['sid']
end

#sip_urlString

Returns The SIP address you want Twilio to route your Origination calls to.

Returns:

  • (String)

    The SIP address you want Twilio to route your Origination calls to



352
353
354
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 352

def sip_url
  @properties['sip_url']
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
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Trunking.V1.OriginationUrlInstance #{values}>"
end

#trunk_sidString

Returns The SID of the Trunk that owns the Origination URL.

Returns:

  • (String)

    The SID of the Trunk that owns the Origination URL



334
335
336
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 334

def trunk_sid
  @properties['trunk_sid']
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:



415
416
417
418
419
420
421
422
423
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 415

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

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource



382
383
384
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 382

def url
  @properties['url']
end

#weightString

Returns The value that determines the relative load the URI should receive compared to others with the same priority.

Returns:

  • (String)

    The value that determines the relative load the URI should receive compared to others with the same priority



340
341
342
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 340

def weight
  @properties['weight']
end