Class: Gemgento::API::SOAP::Customer::Address
- Inherits:
-
Object
- Object
- Gemgento::API::SOAP::Customer::Address
- Defined in:
- lib/gemgento/api/soap/customer/address.rb
Class Method Summary collapse
-
.create(address) ⇒ Gemgento::MagentoResponse
Create a Customer Address in Magento.
-
.delete(address_id) ⇒ Gemgento::MagentoResponse
Delete a Customer Address in Magento.
-
.fetch(user) ⇒ Void
Fetch Customer Addresses for a User and sync them to Gemgento.
-
.fetch_all ⇒ Void
Fetch Customer Addresses for all Gemgento Users from Magento.
-
.info(address_id) ⇒ Gemgento::MagentoReponse
Get Magento Address data.
-
.list(customer_id) ⇒ Gemgento::MagentoResponse
Get a list of all Magento Addresses for a specific customer.
-
.update(address) ⇒ Gemgento::MagentoResponse
Update a Customer Address in Magento.
Class Method Details
.create(address) ⇒ Gemgento::MagentoResponse
Create a Customer Address in Magento.
61 62 63 64 65 66 67 |
# File 'lib/gemgento/api/soap/customer/address.rb', line 61 def self.create(address) = { customer_id: address.addressable.magento_id, address_data: compose_address_data(address) } MagentoApi.create_call(:customer_address_create, ) end |
.delete(address_id) ⇒ Gemgento::MagentoResponse
Delete a Customer Address in Magento.
84 85 86 |
# File 'lib/gemgento/api/soap/customer/address.rb', line 84 def self.delete(address_id) MagentoApi.create_call(:customer_address_update, {address_id: address_id}) end |
.fetch(user) ⇒ Void
Fetch Customer Addresses for a User and sync them to Gemgento.
20 21 22 23 24 25 26 27 28 |
# File 'lib/gemgento/api/soap/customer/address.rb', line 20 def self.fetch(user) response = list(user.magento_id) if response.success? && response.body[:result][:item] response.body[:result][:item].each do |address| sync_magento_to_local(address, user) end end end |
.fetch_all ⇒ Void
Fetch Customer Addresses for all Gemgento Users from Magento.
10 11 12 13 14 |
# File 'lib/gemgento/api/soap/customer/address.rb', line 10 def self.fetch_all User.all.each do |user| fetch(user) end end |
.info(address_id) ⇒ Gemgento::MagentoReponse
Get Magento Address data.
52 53 54 55 |
# File 'lib/gemgento/api/soap/customer/address.rb', line 52 def self.info(address_id) MagentoApi.create_call(:customer_address_list, { address_id: address_id }) # response.body[:result][:info] end |
.list(customer_id) ⇒ Gemgento::MagentoResponse
Get a list of all Magento Addresses for a specific customer.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gemgento/api/soap/customer/address.rb', line 34 def self.list(customer_id) response = MagentoApi.create_call(:customer_address_list, {customer_id: customer_id}) if response.success? if response.body[:result][:item].nil? response.body[:result][:item] = [] elsif !response.body[:result][:item].is_a? Array response.body[:result][:item] = [response.body[:result][:item]] end end return response end |
.update(address) ⇒ Gemgento::MagentoResponse
Update a Customer Address in Magento.
73 74 75 76 77 78 79 |
# File 'lib/gemgento/api/soap/customer/address.rb', line 73 def self.update(address) = { address_id: address.magento_id, address_data: compose_address_data(address) } MagentoApi.create_call(:customer_address_update, ) end |