Class: Aceroute::Order
Instance Attribute Summary collapse
-
#cid ⇒ Object
Returns the value of attribute cid.
-
#customer ⇒ Object
in msec (not sec) since epoch.
-
#description ⇒ Object
any freeform text here.
-
#duration ⇒ Object
any freeform text here.
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
in msec (not sec) since epoch.
-
#purchase_order ⇒ Object
any freeform text here.
-
#scheduled ⇒ Object
any freeform text here.
-
#start_time ⇒ Object
in msec (not sec) since epoch.
-
#summary ⇒ Object
any freeform text here.
-
#worker ⇒ Object
any freeform text here.
Class Method Summary collapse
-
.delete(id) ⇒ Object
Deletes Aceroute::Location of given id from Aceroute.
Instance Method Summary collapse
-
#create! ⇒ Aceroute::Order
Persists Aceroute::Order object to Aceroute API.
-
#destroy!(id = nil) ⇒ Object
Deletes this Aceroute::Order object (self) from Aceroute.
-
#initialize(customer, location, start_time, description = nil, duration = 10, scheduled = true, worker = nil, summary = nil, purchase_order = nil) ⇒ Aceroute::Order
constructor
Creates a new Aceroute::Order object.
Constructor Details
#initialize(customer, location, start_time, description = nil, duration = 10, scheduled = true, worker = nil, summary = nil, purchase_order = nil) ⇒ Aceroute::Order
Creates a new Aceroute::Order object. Note this does not persist the Location to Aceroute, that can be done by calling the create! method on the new object.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aceroute/order.rb', line 24 def initialize(customer, location, start_time, description = nil, duration = 10, scheduled = true, worker = nil, summary = nil, purchase_order = nil) self.customer = customer self.location = location self.start_time = start_time #FIXME: taking a DateTime argument is friendlier #self.start_time = start_time.to_i * 1000 #DateTime object self.description = description self.duration = duration self.scheduled = scheduled self.worker = worker self.summary = summary self.purchase_order = purchase_order end |
Instance Attribute Details
#cid ⇒ Object
Returns the value of attribute cid.
5 6 7 |
# File 'lib/aceroute/order.rb', line 5 def cid @cid end |
#customer ⇒ Object
in msec (not sec) since epoch
3 4 5 |
# File 'lib/aceroute/order.rb', line 3 def customer @customer end |
#description ⇒ Object
any freeform text here
4 5 6 |
# File 'lib/aceroute/order.rb', line 4 def description @description end |
#duration ⇒ Object
any freeform text here
4 5 6 |
# File 'lib/aceroute/order.rb', line 4 def duration @duration end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/aceroute/order.rb', line 5 def id @id end |
#location ⇒ Object
in msec (not sec) since epoch
3 4 5 |
# File 'lib/aceroute/order.rb', line 3 def location @location end |
#purchase_order ⇒ Object
any freeform text here
4 5 6 |
# File 'lib/aceroute/order.rb', line 4 def purchase_order @purchase_order end |
#scheduled ⇒ Object
any freeform text here
4 5 6 |
# File 'lib/aceroute/order.rb', line 4 def scheduled @scheduled end |
#start_time ⇒ Object
in msec (not sec) since epoch
3 4 5 |
# File 'lib/aceroute/order.rb', line 3 def start_time @start_time end |
#summary ⇒ Object
any freeform text here
4 5 6 |
# File 'lib/aceroute/order.rb', line 4 def summary @summary end |
#worker ⇒ Object
any freeform text here
4 5 6 |
# File 'lib/aceroute/order.rb', line 4 def worker @worker end |
Class Method Details
.delete(id) ⇒ Object
Deletes Aceroute::Location of given id from Aceroute
73 74 75 76 77 |
# File 'lib/aceroute/order.rb', line 73 def self.delete(id) req = "<data><del><id>#{id}</id></del></data>" ret = Aceroute::call_api("order.delete", req) ret.success == "true" ? true : false #maybe raise error here instead end |
Instance Method Details
#create! ⇒ Aceroute::Order
Persists Aceroute::Order object to Aceroute API.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/aceroute/order.rb', line 43 def create! recs = "<data> <event> <cid>#{self.customer.cid}</cid> <nm>#{self.description}</nm> <dur>#{self.duration}</dur> <schd>#{self.scheduled ? 1 : 0}</schd> <start_epoch>#{self.start_time}</start_epoch> <lid>#{self.location.id}</lid> <cntid>#{0}</cntid> <rid>#{self.worker}</rid> <dtl>#{self.summary}</dtl> <po>#{self.purchase_order}</po> </event> </data>" data = Aceroute::call_api("order.create", recs) order = data.event update_attrs(order) return self end |