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
18
# File 'lib/bandwidth-iris/order.rb', line 14

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

.get_order_response(client, id) ⇒ Object



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

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

.get_tns_by_order_id(client, id) ⇒ Object

‘get order` no longer returns an `id`, which means the subsequent `get_tns` call will fail This is a workaround to provide the “get tns by order id” functionality



38
39
40
# File 'lib/bandwidth-iris/order.rb', line 38

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

.list(client, query = nil) ⇒ Object



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

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



57
58
59
60
61
# File 'lib/bandwidth-iris/order.rb', line 57

def add_notes(note)
  r = @client.make_request(:post, "#{@client.(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



63
64
65
66
67
# File 'lib/bandwidth-iris/order.rb', line 63

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

#get_historyObject



85
86
87
88
89
# File 'lib/bandwidth-iris/order.rb', line 85

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

#get_notesObject



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

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

#get_npa_npxObject



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

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

#get_tnsObject



81
82
83
# File 'lib/bandwidth-iris/order.rb', line 81

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

#get_totalsObject



75
76
77
78
79
# File 'lib/bandwidth-iris/order.rb', line 75

def get_totals()
  list = @client.make_request(:get, "#{@client.(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



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

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