Class: Aceroute::Customer
Instance Attribute Summary collapse
-
#cid ⇒ Object
Returns the value of attribute cid.
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#locations ⇒ Object
Returns the value of attribute locations.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.delete(id) ⇒ Object
Deletes Aceroute::Customer of given id from Aceroute.
Instance Method Summary collapse
-
#create! ⇒ Aceroute::Customer
Persists Customer object to Aceroute API.
-
#destroy!(id = nil) ⇒ Object
Deletes this Aceroute::Customer object (self) from Aceroute;.
-
#initialize(name, email, location = {}, cid = nil) ⇒ Aceroute::Customer
constructor
Creates a new Aceroute::Customer object.
Constructor Details
#initialize(name, email, location = {}, cid = nil) ⇒ Aceroute::Customer
Creates a new Aceroute::Customer object. Note this does not persist the Customer to Aceroute, that can be done by calling the create! method on the new object.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/aceroute/customer.rb', line 16 def initialize(name, email, location = {}, cid = nil) self.locations = [] #create getters/setters for each param self.email = email self.name = name self.cid = cid if !location.empty? locations << Aceroute::Location.new(location[:address1], location[:address2], location[:description], location[:name], location[:phone]) end end |
Instance Attribute Details
#cid ⇒ Object
Returns the value of attribute cid.
6 7 8 |
# File 'lib/aceroute/customer.rb', line 6 def cid @cid end |
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/aceroute/customer.rb', line 4 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/aceroute/customer.rb', line 6 def id @id end |
#locations ⇒ Object
Returns the value of attribute locations.
3 4 5 |
# File 'lib/aceroute/customer.rb', line 3 def locations @locations end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/aceroute/customer.rb', line 5 def name @name end |
Class Method Details
.delete(id) ⇒ Object
Deletes Aceroute::Customer of given id from Aceroute
62 63 64 65 66 |
# File 'lib/aceroute/customer.rb', line 62 def self.delete(id) recs = "<data><del><id>#{id}</id></del></data>" ret = Aceroute::call_api("customer.delete", recs) ret.success == "true" ? true : false end |
Instance Method Details
#create! ⇒ Aceroute::Customer
Persists Customer object to Aceroute API.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/aceroute/customer.rb', line 32 def create! recs = "<data> <cst> <nm>#{self.name}</nm> <locnm>#{self.locations.first.description}</locnm> <adr>#{self.locations.first.address1}</adr> <adr2>#{self.locations.first.address2}</adr2> <cntnm>#{self.locations.first.name}</cntnm> <tel>#{self.locations.first.phone}</tel> <eml>#{self.email}</eml> </cst> </data>" #puts recs data = Aceroute::call_api("customer.create", recs) location = data.locs.loc customer = data.cnts.cnt update_attrs(customer) self.cid = customer.cid locations.first.update_attrs(location) return self end |