Class: BandwidthIris::Order

Inherits:
Object
  • Object
show all
Extended by:
ClientWrapper
Includes:
ApiItem
Defined in:
lib/bandwidth-iris/order.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClientWrapper

wrap_client_arg

Methods included from ApiItem

#[], #[]=, #initialize, #to_data

Class Method Details

.create(client, item) ⇒ Object



8
9
10
11
# File 'lib/bandwidth-iris/order.rb', line 8

def self.create(client, item)
  data = client.make_request(:post, client.(ORDER_PATH), {:order => item})[0][:order]
  Order.new(data, client)
end

.get(client, id) ⇒ Object



14
15
16
17
# File 'lib/bandwidth-iris/order.rb', line 14

def self.get(client, id)
  data = client.make_request(:get, "#{client.concat_account_path(ORDER_PATH)}/#{id}")[0][:order]
  Order.new(data, client)
end

.list(client, query = nil) ⇒ Object



20
21
22
23
24
25
# File 'lib/bandwidth-iris/order.rb', line 20

def self.list(client, query = nil)
  list = client.make_request(:get, client.(ORDER_PATH), query)[0][:orders][:order]
  return [] if !list
  list = if list.is_a?(Array) then list else [list]  end
  list.map {|i| Order.new(i, client)}
end

Instance Method Details

#add_notes(note) ⇒ Object



42
43
44
45
46
# File 'lib/bandwidth-iris/order.rb', line 42

def add_notes(note)
  r = @client.make_request(:post, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/notes", {:note => note})
  note_id = Client.get_id_from_location_header(r[1][:location])
  (get_notes().select {|n| n[:id].to_s == note_id }).first
end

#get_area_codesObject



48
49
50
51
52
# File 'lib/bandwidth-iris/order.rb', line 48

def get_area_codes()
  list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/areaCodes")[0][:telephone_details_report]
  return [] if !list
  if list.is_a?(Array) then list else [list]  end
end

#get_historyObject



70
71
72
73
74
# File 'lib/bandwidth-iris/order.rb', line 70

def get_history()
  list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/history")[0][:order_history]
  return [] if !list
  if list.is_a?(Array) then list else [list]  end
end

#get_notesObject



32
33
34
35
36
37
38
39
40
# File 'lib/bandwidth-iris/order.rb', line 32

def get_notes()
  list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/notes")[0][:note]
  return [] if !list
  if list.is_a?(Array)
    list
  else
    [list]
  end
end

#get_npa_npxObject



54
55
56
57
58
# File 'lib/bandwidth-iris/order.rb', line 54

def get_npa_npx()
  list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/npaNxx")[0][:telephone_details_report]
  return [] if !list
  if list.is_a?(Array) then list else [list]  end
end

#get_tnsObject



66
67
68
# File 'lib/bandwidth-iris/order.rb', line 66

def get_tns()
  @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/tns")[0]
end

#get_totalsObject



60
61
62
63
64
# File 'lib/bandwidth-iris/order.rb', line 60

def get_totals()
  list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/totals")[0][:telephone_details_report]
  return [] if !list
  if list.is_a?(Array) then list else [list]  end
end

#update(data) ⇒ Object



28
29
30
# File 'lib/bandwidth-iris/order.rb', line 28

def update(data)
  @client.make_request(:put, "#{@client.concat_account_path(ORDER_PATH)}/#{id}", {:order => data})[0]
end