module RubyPsigate # DOC - TODO class Address include RubyPsigate::HashVariables hashable :billing, %w( Bname Bcompany Baddress1 Baddress2 Bcity Bprovince Bpostalcode Bcountry Phone Fax ) hashable :shipping, %w( Sname Scompany Saddress1 Saddress2 Scity Sprovince Spostalcode Scountry ) hashable :account, %w( Name Company Address1 Address2 City Province PostalCode Country Phone Fax ) attr_accessor :firstname, :lastname, :line1, :line2, :city, :state, :country, :zipcode, :telephone, :fax, :company alias_method :province, :state alias_method :province=, :state= alias_method :postalcode, :zipcode alias_method :postalcode=, :zipcode= alias_method :address1, :line1 alias_method :address2, :line2 alias_method :phone, :telephone def initialize(options={}) @firstname = options[:firstname] @lastname = options[:lastname] @line1 = options[:line1] @line2 = options[:line2] @city = options[:city] @state = options[:state] @country = options[:country] @zipcode = options[:zipcode] @telephone = options[:telephone] @fax = options[:fax] @company = options[:company] super end def name "#{firstname} #{lastname}".strip end def to_hash(type = nil) result = super result = result.delete_if { |key, value| value.nil? } # Delete empty hash values result end # For billing alias_method :bname, :name alias_method :bcompany, :company alias_method :baddress1, :address1 alias_method :baddress2, :address2 alias_method :bcity, :city alias_method :bprovince, :province alias_method :bpostalcode, :postalcode alias_method :bcountry, :country # For shipping alias_method :sname, :name alias_method :scompany, :company alias_method :saddress1, :address1 alias_method :saddress2, :address2 alias_method :scity, :city alias_method :sprovince, :province alias_method :spostalcode, :postalcode alias_method :scountry, :country end end