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.(ORDER_PATH)}/#{id}")[0][:order]
  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



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

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



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



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

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_codes ⇒ Object



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

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_history ⇒ Object



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

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_notes ⇒ Object



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

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_npx ⇒ Object



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

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_tns ⇒ Object



73
74
75
# File 'lib/bandwidth-iris/order.rb', line 73

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

#get_totals ⇒ Object



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

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



35
36
37
# File 'lib/bandwidth-iris/order.rb', line 35

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