Class: Bandwidth::PhoneNumber
- Inherits:
-
Object
- Object
- Bandwidth::PhoneNumber
- Extended by:
- ClientWrapper
- Includes:
- ApiItem
- Defined in:
- lib/bandwidth/phone_number.rb
Overview
The Phone Numbers resource lets you get phone numbers for use with your programs and manage numbers you already have.
Class Method Summary collapse
-
.create(client, data) ⇒ PhoneNumber
Allocate a number so you can use it.
-
.get(client, id) ⇒ Object
Get information about one number return [PhoneNumber] phone number information.
-
.list(client, query = nil) ⇒ Array
Get a list of your numbers.
Instance Method Summary collapse
-
#delete ⇒ Object
(also: #destroy)
Removes a number from your account.
-
#update(data) ⇒ Object
Make changes to a number you have.
Methods included from ClientWrapper
Methods included from ApiItem
#[], #[]=, #initialize, #to_data
Class Method Details
.create(client, data) ⇒ PhoneNumber
Allocate a number so you can use it
37 38 39 40 41 |
# File 'lib/bandwidth/phone_number.rb', line 37 def self.create(client, data) headers = client.make_request(:post, client.concat_user_path(PHONENUMBER_PATH), data)[1] id = Client.get_id_from_location_header(headers[:location]) self.get(client, id) end |
.get(client, id) ⇒ Object
Get information about one number return [PhoneNumber] phone number information
14 15 16 17 |
# File 'lib/bandwidth/phone_number.rb', line 14 def self.get(client, id) item = client.make_request(:get, client.concat_user_path("#{PHONENUMBER_PATH}/#{id}"))[0] PhoneNumber.new(item, client) end |
.list(client, query = nil) ⇒ Array
Get a list of your numbers
26 27 28 29 30 |
# File 'lib/bandwidth/phone_number.rb', line 26 def self.list(client, query = nil) client.make_request(:get, client.concat_user_path(PHONENUMBER_PATH), query)[0].map do |item| PhoneNumber.new(item, client) end end |
Instance Method Details
#delete ⇒ Object Also known as: destroy
Removes a number from your account
55 56 57 |
# File 'lib/bandwidth/phone_number.rb', line 55 def delete() @client.make_request(:delete, @client.concat_user_path("#{PHONENUMBER_PATH}/#{id}"))[0] end |
#update(data) ⇒ Object
Make changes to a number you have
48 49 50 |
# File 'lib/bandwidth/phone_number.rb', line 48 def update(data) @client.make_request(:post, @client.concat_user_path("#{PHONENUMBER_PATH}/#{id}"), data)[0] end |