class Aceroute::Location

Attributes

address1[RW]
address2[RW]
cid[RW]
description[RW]
id[RW]
name[RW]
phone[RW]

Public Class Methods

delete(id) click to toggle source

Deletes Aceroute::Location of given id from Aceroute @param id [Integer]

# File lib/aceroute/location.rb, line 55
def self.delete(id)
  req = "<data><del><id>#{id}</id></del></data>"
  ret = Aceroute::call_api("customer.location.delete", req)
  ret.success == "true" ? true : false  #maybe raise error here instead
end
new(address1, address2, description, name, phone, cid = nil, id= nil) click to toggle source

Creates a new Aceroute::Location object. Note this does not persist the Location to Aceroute, that can be done by calling the create! method on the new object.

@param address1 [String] customer address line 1 (street)
@param address2 [String] customer address line 2 (eg apartment number)
@param description [String] description of address (eg 'Home')
@param name [String] name of address (eg 'Home')
@param phone [String] phone number associated with this address
@param cid [Integer] Aceroute customer id, optional; associates this Location with that Customer
@param id [Integer] Aceroute location id, optional; useful for instantiating Location objects from Aceroute API response
@return [Aceroute::Location]
# File lib/aceroute/location.rb, line 22
def initialize(address1, address2, description, name, phone, cid = nil, id= nil)
  self.address1 = address1
  self.address2 = address2
  self.description = description
  self.name = name
  self.phone = phone
  self.cid = cid
  self.id = id
end

Public Instance Methods

create!() click to toggle source

Persists Aceroute::Location object to Aceroute API. @return [Aceroute::Location]

# File lib/aceroute/location.rb, line 35
def create!
  recs = "<data><loc><id>0</id>
    <cid>#{self.cid}</cid>
    <nm>#{self.description}</nm>
    <adr>#{self.address1}</adr>
    <adr2>#{self.address2}</adr2>
    </loc></data>"
  data = Aceroute::call_api("customer.location.save", recs)
  loc = data.loc
  update_attrs(loc)
  return self
end
destroy!(id = nil) click to toggle source

Deletes this Aceroute::Location object (self) from Aceroute

# File lib/aceroute/location.rb, line 49
def destroy!(id = nil)
  Location.delete(id ? id : self.id)
end