Class: BandwidthIris::PortIn
- Inherits:
-
Object
- Object
- BandwidthIris::PortIn
show all
- Extended by:
- ClientWrapper
- Includes:
- ApiItem
- Defined in:
- lib/bandwidth-iris/port_in.rb
Class Method Summary
collapse
Instance Method Summary
collapse
wrap_client_arg
Methods included from ApiItem
#[], #[]=, #initialize, #to_data
Class Method Details
.create(client, item) ⇒ Object
9
10
11
12
13
|
# File 'lib/bandwidth-iris/port_in.rb', line 9
def self.create(client, item)
item = client.make_request(:post, client.concat_account_path(PORT_IN_PATH), {:lnp_order => item})[0]
item[:id] = item[:order_id]
PortIn.new(item, client)
end
|
.list(client, query = nil) ⇒ Object
28
29
30
|
# File 'lib/bandwidth-iris/port_in.rb', line 28
def self.list(client, query=nil)
list_from_page_url(client, client.concat_account_path(PORT_IN_PATH), query)
end
|
.list_from_page_url(client, url, query = nil) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/bandwidth-iris/port_in.rb', line 16
def self.list_from_page_url(client, url, query=nil)
response = client.make_request(:get, url, query)[0]
items = response[:lnp_port_info_for_given_status]
items = items.is_a?(Array) ? items : [items]
PaginatedResult.new(
items.map { |item| PortIn.new(item, client) },
response[:links]
) do |next_url|
list_from_page_url(client, next_url)
end
end
|
Instance Method Details
#add_notes(note) ⇒ Object
55
56
57
58
59
|
# File 'lib/bandwidth-iris/port_in.rb', line 55
def add_notes(note)
r = @client.make_request(:post, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/notes", {:note => note})
note_id = Client.(r[1][:location])
(get_notes().select {|n| n[:id].to_s == note_id }).first
end
|
#create_file(io, media_type = nil) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/bandwidth-iris/port_in.rb', line 61
def create_file(io, media_type = nil)
connection = @client.create_connection()
buf = io.read()
response = connection.post("/#{@client.api_version}#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}") do |req|
req.['Content-Length'] = buf.size.to_s
req.['Content-Type'] = media_type || 'application/octet-stream'
req.body = buf
end
r = @client.check_response(response)
r[:filename]
end
|
#delete ⇒ Object
41
42
43
|
# File 'lib/bandwidth-iris/port_in.rb', line 41
def delete()
@client.make_request(:delete,"#{@client.concat_account_path(PORT_IN_PATH)}/#{id}")
end
|
#get_file(file_name) ⇒ Object
90
91
92
93
94
|
# File 'lib/bandwidth-iris/port_in.rb', line 90
def get_file(file_name)
connection = @client.create_connection()
response = connection.get("/#{@client.api_version}#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}/#{CGI.escape(file_name)}")
[response.body, response.['Content-Type'] || 'application/octet-stream']
end
|
86
87
88
|
# File 'lib/bandwidth-iris/port_in.rb', line 86
def get_file_metadata(file_name)
@client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}/#{CGI.escape(file_name)}/metadata")[0]
end
|
#get_files(metadata = false) ⇒ Object
96
97
98
|
# File 'lib/bandwidth-iris/port_in.rb', line 96
def get_files(metadata = false)
@client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}", {:metadata => metadata})[0][:file_data]
end
|
#get_notes ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'lib/bandwidth-iris/port_in.rb', line 45
def get_notes()
list = @client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/notes")[0][:note]
return [] if !list
if list.is_a?(Array)
list
else
[list]
end
end
|
#tns ⇒ Object
33
34
35
|
# File 'lib/bandwidth-iris/port_in.rb', line 33
def tns
Array(@client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{order_id}/tns")[0][:telephone_number])
end
|
#update(data) ⇒ Object
37
38
39
|
# File 'lib/bandwidth-iris/port_in.rb', line 37
def update(data)
@client.make_request(:put,"#{@client.concat_account_path(PORT_IN_PATH)}/#{id}", {:lnp_order_supp => data})
end
|
#update_file(file_name, file, media_type) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/bandwidth-iris/port_in.rb', line 74
def update_file(file_name, file, media_type)
connection = @client.create_connection()
buf = io.read()
response = connection.put("/#{@client.api_version}#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}/#{URI.encode(file_name)}") do |req|
req.['Content-Length'] = buf.size.to_s
req.['Content-Type'] = media_type || 'application/octet-stream'
req.body = buf
end
@client.check_response(response)
end
|