Class: Gemgento::Adapter::Shopify::Address
- Inherits:
-
Object
- Object
- Gemgento::Adapter::Shopify::Address
- Defined in:
- app/models/gemgento/adapter/shopify/address.rb
Class Method Summary collapse
-
.import(shopify_address, user, skip_existing = false) ⇒ Gemgento::Address
Import Shopify address to Gemgento.
Class Method Details
.import(shopify_address, user, skip_existing = false) ⇒ Gemgento::Address
Import Shopify address to Gemgento
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/gemgento/adapter/shopify/address.rb', line 10 def self.import(shopify_address, user, skip_existing = false) if shopify_adapter = Gemgento::Adapter::ShopifyAdapter.find_by_shopify_model(shopify_address) address = shopify_adapter.gemgento_model return address if skip_existing else address = Gemgento::Address.new end address.addressable = user address.address1 = shopify_address.address1 address.address2 = shopify_address.address2 address.city = shopify_address.city address.company = shopify_address.company address.country = Gemgento::Country.find_by(iso2_code: shopify_address.country_code) address.first_name = shopify_address.first_name address.last_name = shopify_address.last_name address.telephone = shopify_address.phone address.region = Gemgento::Region.find_by(code: shopify_address.province_code) address.postcode = shopify_address.zip address.is_billing = shopify_address.default ? true : false address.is_shipping = shopify_address.default ? true : false address.sync_needed = true address.save Gemgento::Adapter::ShopifyAdapter.create_association(address, shopify_address) if address.shopify_adapter.nil? return address end |