Class: Twilio::REST::Proxy::V1::ServiceContext::PhoneNumberContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ PhoneNumberContext

Initialize the PhoneNumberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the parent [Service](www.twilio.com/docs/proxy/api/service) of the PhoneNumber resource to update.

  • sid (String)

    The Twilio-provided string that uniquely identifies the PhoneNumber resource to update.



240
241
242
243
244
245
246
247
248
249
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 240

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

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

    
end

Instance Method Details

#deleteBoolean

Delete the PhoneNumberInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



253
254
255
256
257
258
259
260
261
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 253

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 PhoneNumberInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 266

def 

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

#fetchPhoneNumberInstance

Fetch the PhoneNumberInstance

Returns:



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 285

def fetch

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

#fetch_with_metadataPhoneNumberInstance

Fetch the PhoneNumberInstanceMetadata

Returns:



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 305

def 

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

#inspectObject

Provide a detailed, user friendly representation



398
399
400
401
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 398

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

#to_sObject

Provide a user friendly representation



391
392
393
394
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 391

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

#update(is_reserved: :unset) ⇒ PhoneNumberInstance

Update the PhoneNumberInstance

Parameters:

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

    Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](www.twilio.com/docs/proxy/reserved-phone-numbers) for more information.

Returns:



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 332

def update(
  is_reserved: :unset
)

    data = Twilio::Values.of({
        'IsReserved' => is_reserved,
    })

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

#update_with_metadata(is_reserved: :unset) ⇒ PhoneNumberInstance

Update the PhoneNumberInstanceMetadata

Parameters:

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

    Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](www.twilio.com/docs/proxy/reserved-phone-numbers) for more information.

Returns:



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb', line 359

def (
  is_reserved: :unset
)

    data = Twilio::Values.of({
        'IsReserved' => is_reserved,
    })

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