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 fetch the OriginationUrl.

  • sid (String)

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


182
183
184
185
186
187
188
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 182

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


207
208
209
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 207

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

#fetchOriginationUrlInstance

Fetch the OriginationUrlInstance

Returns:


193
194
195
196
197
198
199
200
201
202
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 193

def fetch
  payload = @version.fetch('GET', @uri)

  OriginationUrlInstance.new(
      @version,
      payload,
      trunk_sid: @solution[:trunk_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation


254
255
256
257
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 254

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

#to_sObject

Provide a user friendly representation


247
248
249
250
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 247

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:


226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb', line 226

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,
  })

  payload = @version.update('POST', @uri, data: data)

  OriginationUrlInstance.new(
      @version,
      payload,
      trunk_sid: @solution[:trunk_sid],
      sid: @solution[:sid],
  )
end