Class: Magento::CustomerAddress
- Defined in:
- lib/magento/customer_address.rb
Overview
www.magentocommerce.com/wiki/doc/webservices-api/api/customer_address 100 Invalid address data. Details in error message. 101 Customer not exists. 102 Address not exists. 103 Address not deleted. Details in error message.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.create(customer_id, attributes) ⇒ Object
customer_address.create Create customer address.
-
.delete(*args) ⇒ Object
customer_address.delete Delete customer address.
- .find_by_customer_id(id) ⇒ Object
- .find_by_id(id) ⇒ Object
-
.info(*args) ⇒ Object
customer_address.info Retrieve customer address data.
-
.list(*args) ⇒ Object
Retrieve customer addresses.
-
.update(*args) ⇒ Object
customer_address.update Update customer address data.
Instance Method Summary collapse
- #country ⇒ Object
- #delete ⇒ Object
- #region ⇒ Object
- #update_attribute(name, value) ⇒ Object
- #update_attributes(attrs) ⇒ Object
Methods included from Base::ClassMethods
Methods included from Base::InstanceMethods
#id, #id=, #initialize, #method_missing, #object_attributes=
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Magento::Base::InstanceMethods
Class Method Details
.create(customer_id, attributes) ⇒ Object
customer_address.create Create customer address
Return: int
Arguments:
int customerId - customer ID array addressData - adress data (country, zip, city, etc…)
33 34 35 36 37 38 |
# File 'lib/magento/customer_address.rb', line 33 def create(customer_id, attributes) id = commit("create", customer_id, attributes) record = new(attributes) record.id = id record end |
.delete(*args) ⇒ Object
customer_address.delete Delete customer address
Return: boolean
Arguments:
int addressId - customer address ID
73 74 75 |
# File 'lib/magento/customer_address.rb', line 73 def delete(*args) commit("delete", *args) end |
.find_by_customer_id(id) ⇒ Object
81 82 83 |
# File 'lib/magento/customer_address.rb', line 81 def find_by_customer_id(id) list(id) end |
.find_by_id(id) ⇒ Object
77 78 79 |
# File 'lib/magento/customer_address.rb', line 77 def find_by_id(id) info(id) end |
.info(*args) ⇒ Object
customer_address.info Retrieve customer address data
Return: array
Arguments:
int addressId - customer address ID
48 49 50 |
# File 'lib/magento/customer_address.rb', line 48 def info(*args) new(commit("info", *args)) end |
.list(*args) ⇒ Object
Retrieve customer addresses
Return: array
Arguments:
int customerId - Customer Id
17 18 19 20 21 22 |
# File 'lib/magento/customer_address.rb', line 17 def list(*args) results = commit("list", *args) results.collect do |result| new(result) end end |
.update(*args) ⇒ Object
customer_address.update Update customer address data
Return: boolean
Arguments:
int addressId - customer address ID array addressData - adress data (country, zip, city, etc…)
61 62 63 |
# File 'lib/magento/customer_address.rb', line 61 def update(*args) commit("update", *args) end |
Instance Method Details
#country ⇒ Object
87 88 89 |
# File 'lib/magento/customer_address.rb', line 87 def country Magento::Country.find_by_id(self.country_id) end |
#delete ⇒ Object
95 96 97 |
# File 'lib/magento/customer_address.rb', line 95 def delete self.class.delete(self.id) end |
#region ⇒ Object
91 92 93 |
# File 'lib/magento/customer_address.rb', line 91 def region Magento::Region.find_by_country_and_id(self.country_id, self.region_id) end |
#update_attribute(name, value) ⇒ Object
99 100 101 102 |
# File 'lib/magento/customer_address.rb', line 99 def update_attribute(name, value) @attributes[name] = value self.class.update(self.id, Hash[*[name.to_sym, value]]) end |
#update_attributes(attrs) ⇒ Object
104 105 106 107 |
# File 'lib/magento/customer_address.rb', line 104 def update_attributes(attrs) attrs.each_pair { |k, v| @attributes[k] = v } self.class.update(self.id, attrs) end |