Module: Aceroute
- Includes:
- HTTParty
- Defined in:
- lib/aceroute.rb,
lib/aceroute/core.rb,
lib/aceroute/version.rb
Constant Summary
- VERSION =
"0.1.2"
- @@API_KEY =
ENV['ACEROUTE_API_TOKEN']
- @@query_params =
{ token: @@API_KEY, updsince: '0' }
Instance Attribute Summary (collapse)
-
- (Object) http_result
Returns the value of attribute http_result.
Class Method Summary (collapse)
-
+ (Hash) create_customer(customer)
Create a new customer.
-
+ (Object) create_location(location)
Create a new location.
-
+ (Object) create_order(order)
Create new order.
-
+ (Object) delete_customer(customer_id)
Delete a customer.
-
+ (Object) delete_location(location_id)
Delete a location.
-
+ (Object) delete_order(order_id)
Delete an order.
-
+ (Hash) list_customers
List all customers.
-
+ (Object) list_order_types
List order types.
-
+ (Object) list_orders
List all orders.
-
+ (Object) list_service_types
List service types.
-
+ (Object) list_workers
List all workers.
Instance Attribute Details
- (Object) http_result
Returns the value of attribute http_result
8 9 10 |
# File 'lib/aceroute/core.rb', line 8 def http_result @http_result end |
Class Method Details
+ (Hash) create_customer(customer)
Create a new customer
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/aceroute/core.rb', line 37 def self.create_customer(customer) recs = "<data> <cst> <nm>#{customer[:name]}</nm> <locnm>#{customer[:address][:description]}</locnm> <adr>#{customer[:address][:address1]}</adr> <adr2>#{customer[:address][:address2]}</adr2> <cntnm>#{customer[:address][:name]}</cntnm> <tel>#{customer[:address][:phone]}</tel> <eml>#{customer[:email]}</eml> </cst> </data>" data = self.call_api("customer.create", recs) address = data.locs.loc customer = data.cnts.cnt return customer, address end |
+ (Object) create_location(location)
Create a new location
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/aceroute/core.rb', line 75 def self.create_location(location) recs = "<data><loc><id>#{location[:id]}</id> <cid>#{location[:customer][:cid]}</cid> <nm>#{location[:description]}</nm> <adr>#{location[:address1]}</adr> <adr2>#{location[:address2]}</adr2> </loc></data>" data = self.call_api("customer.location.save", recs) loc = data.loc end |
+ (Object) create_order(order)
Create new order
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/aceroute/core.rb', line 136 def self.create_order(order) recs = "<data> <event> <cid>#{order[:cid]}</cid> <nm>#{order[:nm]}</nm> <dur>#{order[:dur]}</dur> <schd>#{order[:schd]}</schd> <start_epoch>#{order[:start_epoch]}</start_epoch> <lid>#{order[:lid]}</lid> <cntid>#{order[:cntid]}</cntid> <rid>#{order[:rid]}</rid> <dtl>#{order[:dtl]}</dtl> <po>#{order[:po]}</po> </event> </data>" puts recs data = self.call_api("order.create", recs) puts data order = data.event end |
+ (Object) delete_customer(customer_id)
Delete a customer
60 61 62 63 |
# File 'lib/aceroute/core.rb', line 60 def self.delete_customer(customer_id) recs = "<data><del><id>#{customer_id}</id></del></data>" self.call_api("customer.delete", recs) end |
+ (Object) delete_location(location_id)
Delete a location
90 91 92 93 |
# File 'lib/aceroute/core.rb', line 90 def self.delete_location(location_id) recs = "<data><del><id>#{location_id}</id></del></data>" types = self.call_api("customer.location.delete", recs).otype end |
+ (Object) delete_order(order_id)
Delete an order
158 159 160 161 |
# File 'lib/aceroute/core.rb', line 158 def self.delete_order(order_id) recs = "<data><del><id>#{order_id}</id></del></data>" self.call_api("order.delete", recs) end |
+ (Hash) list_customers
List all customers
21 22 23 |
# File 'lib/aceroute/core.rb', line 21 def self.list_customers self.call_api("customer.list", nil) end |
+ (Object) list_order_types
List order types
97 98 99 |
# File 'lib/aceroute/core.rb', line 97 def self.list_order_types self.call_api("order.type.list", nil) end |
+ (Object) list_orders
List all orders
116 117 118 |
# File 'lib/aceroute/core.rb', line 116 def self.list_orders workers = self.call_api("order.list", nil).event end |
+ (Object) list_service_types
List service types
103 104 105 |
# File 'lib/aceroute/core.rb', line 103 def self.list_service_types self.call_api("product.type.list", nil) end |
+ (Object) list_workers
List all workers
110 111 112 |
# File 'lib/aceroute/core.rb', line 110 def self.list_workers workers = self.call_api("worker.list", nil).res end |