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

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/trunking/v1/trunk.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb

Defined Under Namespace

Classes: CredentialListContext, CredentialListInstance, CredentialListList, CredentialListPage, IpAccessControlListContext, IpAccessControlListInstance, IpAccessControlListList, IpAccessControlListPage, OriginationUrlContext, OriginationUrlInstance, OriginationUrlList, OriginationUrlPage, PhoneNumberContext, PhoneNumberInstance, PhoneNumberList, PhoneNumberPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ TrunkContext

Initialize the TrunkContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The sid



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 195

def initialize(version, sid)
  super(version)

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

  # Dependents
  @origination_urls = nil
  @credentials_lists = nil
  @ip_access_control_lists = nil
  @phone_numbers = nil
end

Instance Method Details

#credentials_lists(sid = :unset) ⇒ CredentialListList, CredentialListContext

Access the credentials_lists

Returns:

Raises:

  • (ArgumentError)


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

def credentials_lists(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return CredentialListContext.new(@version, @solution[:sid], sid, )
  end

  unless @credentials_lists
    @credentials_lists = CredentialListList.new(@version, trunk_sid: @solution[:sid], )
  end

  @credentials_lists
end

#deleteBoolean

Deletes the TrunkInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



227
228
229
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 227

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

#fetchTrunkInstance

Fetch a TrunkInstance

Returns:



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 212

def fetch
  params = Twilio::Values.of({})

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

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

#ip_access_control_lists(sid = :unset) ⇒ IpAccessControlListList, IpAccessControlListContext

Access the ip_access_control_lists

Returns:

Raises:

  • (ArgumentError)


315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 315

def ip_access_control_lists(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return IpAccessControlListContext.new(@version, @solution[:sid], sid, )
  end

  unless @ip_access_control_lists
    @ip_access_control_lists = IpAccessControlListList.new(@version, trunk_sid: @solution[:sid], )
  end

  @ip_access_control_lists
end

#origination_urls(sid = :unset) ⇒ OriginationUrlList, OriginationUrlContext

Access the origination_urls

Returns:

Raises:

  • (ArgumentError)


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

def origination_urls(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return OriginationUrlContext.new(@version, @solution[:sid], sid, )
  end

  unless @origination_urls
    @origination_urls = OriginationUrlList.new(@version, trunk_sid: @solution[:sid], )
  end

  @origination_urls
end

#phone_numbers(sid = :unset) ⇒ PhoneNumberList, PhoneNumberContext

Access the phone_numbers

Returns:

Raises:

  • (ArgumentError)


333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 333

def phone_numbers(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return PhoneNumberContext.new(@version, @solution[:sid], sid, )
  end

  unless @phone_numbers
    @phone_numbers = PhoneNumberList.new(@version, trunk_sid: @solution[:sid], )
  end

  @phone_numbers
end

#to_sObject

Provide a user friendly representation



349
350
351
352
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 349

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

#update(friendly_name: :unset, domain_name: :unset, disaster_recovery_url: :unset, disaster_recovery_method: :unset, recording: :unset, secure: :unset) ⇒ TrunkInstance

Update the TrunkInstance

Parameters:

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

    A human-readable name for the Trunk.

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

    The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and ‘-` and must always end with `pstn.twilio.com`. See [Termination Settings](www.twilio.com/docs/sip-trunking/getting-started#termination) for more information.

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

    The HTTP URL that Twilio will request if an error occurs while sending SIP traffic towards your configured Origination URL. Twilio will retrieve TwiML from this URL and execute those instructions like any other normal TwiML call. See [Disaster Recovery](www.twilio.com/docs/sip-trunking/getting-started#disaster-recovery) for more information.

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

    The HTTP method Twilio will use when requesting the ‘DisasterRecoveryUrl`. Either `GET` or `POST`.

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

    The recording settings for this trunk. If turned on, all calls going through this trunk will be recorded and the recording can either start when the call is ringing or when the call is answered. See [Recording](www.twilio.com/docs/sip-trunking/getting-started#recording) for more information.

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

    The Secure Trunking settings for this trunk. If turned on, all calls going through this trunk will be secure using SRTP for media and TLS for signalling. If turned off, then RTP will be used for media. See [Secure Trunking](www.twilio.com/docs/sip-trunking/getting-started#securetrunking) for more information.

Returns:



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 256

def update(friendly_name: :unset, domain_name: :unset, disaster_recovery_url: :unset, disaster_recovery_method: :unset, recording: :unset, secure: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'DomainName' => domain_name,
      'DisasterRecoveryUrl' => disaster_recovery_url,
      'DisasterRecoveryMethod' => disaster_recovery_method,
      'Recording' => recording,
      'Secure' => secure,
  })

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

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