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/recording.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, RecordingContext, RecordingInstance, RecordingList, RecordingPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ TrunkContext

Initialize the TrunkContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

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



172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 172

def initialize(version, sid)
    super(version)

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

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

Instance Method Details

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

Access the credentials_lists

Returns:

Raises:

  • (ArgumentError)


262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 262

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

Delete the TrunkInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



189
190
191
192
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 189

def delete

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

#fetchTrunkInstance

Fetch the TrunkInstance

Returns:



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

def fetch

    payload = @version.fetch('GET', @uri)
    TrunkInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

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

Access the ip_access_control_lists

Returns:

Raises:

  • (ArgumentError)


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

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)


319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 319

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)


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

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

#recordingsRecordingList, RecordingContext

Access the recordings



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

def recordings
    RecordingContext.new(
            @version,
            @solution[:sid]
            )
end

#to_sObject

Provide a user friendly representation



337
338
339
340
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 337

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, transfer_mode: :unset, secure: :unset, cnam_lookup_enabled: :unset, transfer_caller_id: :unset) ⇒ TrunkInstance

Update the TrunkInstance

Parameters:

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

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

  • 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 end with `pstn.twilio.com`. See [Termination Settings](www.twilio.com/docs/sip-trunking#termination) for more information.

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

    The URL we should call using the ‘disaster_recovery_method` if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See [Disaster Recovery](www.twilio.com/docs/sip-trunking#disaster-recovery) for more information.

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

    The HTTP method we should use to call the ‘disaster_recovery_url`. Can be: `GET` or `POST`.

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

    Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See [Secure Trunking](www.twilio.com/docs/sip-trunking#securetrunking) for more information.

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

    Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](www.twilio.com/docs/sip-trunking#CNAM) for more information.

  • transfer_caller_id (TransferCallerId) (defaults to: :unset)

Returns:



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 218

def update(
    friendly_name: :unset, 
    domain_name: :unset, 
    disaster_recovery_url: :unset, 
    disaster_recovery_method: :unset, 
    transfer_mode: :unset, 
    secure: :unset, 
    cnam_lookup_enabled: :unset, 
    transfer_caller_id: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'DomainName' => domain_name,
        'DisasterRecoveryUrl' => disaster_recovery_url,
        'DisasterRecoveryMethod' => disaster_recovery_method,
        'TransferMode' => transfer_mode,
        'Secure' => secure,
        'CnamLookupEnabled' => cnam_lookup_enabled,
        'TransferCallerId' => transfer_caller_id,
    })

    payload = @version.update('POST', @uri, data: data)
    TrunkInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end