gemgento 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/README.md +9 -0
- data/Rakefile +21 -0
- data/app/adapters/gemgento/magento/address_adapter.rb +37 -0
- data/app/adapters/gemgento/magento/customer_adapter.rb +24 -0
- data/app/adapters/gemgento/magento/line_item_adapter.rb +41 -0
- data/app/adapters/gemgento/magento/order_adapter.rb +97 -0
- data/app/adapters/gemgento/magento/order_status_adapter.rb +24 -0
- data/app/adapters/gemgento/magento/payment_adapter.rb +38 -0
- data/app/adapters/gemgento/magento/product_adapater.rb +24 -0
- data/app/adapters/gemgento/magento/quote_adapter.rb +17 -0
- data/app/adapters/gemgento/magento/shipment_adapter.rb +74 -0
- data/app/adapters/gemgento/magento/shipment_item_adapter.rb +39 -0
- data/app/adapters/gemgento/magento/shipment_track_adapter.rb +31 -0
- data/app/adapters/gemgento/magento_adapter.rb +17 -0
- data/app/assets/fonts/FuturaStd-Bold.otf +0 -0
- data/app/assets/fonts/FuturaStd-Book.otf +0 -0
- data/app/assets/fonts/FuturaStd-Light.otf +0 -0
- data/app/assets/fonts/FuturaStd-Medium.otf +0 -0
- data/app/assets/fonts/Verlag-Black.otf +0 -0
- data/app/assets/fonts/Verlag-BlackItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Bold.otf +0 -0
- data/app/assets/fonts/Verlag-BoldItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Book.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic-2.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic-3.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Light.otf +0 -0
- data/app/assets/fonts/Verlag-LightItalic.otf +0 -0
- data/app/assets/fonts/Verlag-XLight.otf +0 -0
- data/app/assets/fonts/Verlag-XLightItalic.otf +0 -0
- data/app/assets/images/about_store.jpg +0 -0
- data/app/assets/images/gemgento-icon-bolt.png +0 -0
- data/app/assets/javascripts/gemgento/active_admin.js.coffee +42 -0
- data/app/assets/javascripts/gemgento/checkout/address.coffee +23 -0
- data/app/assets/javascripts/gemgento/gemgento.js +1 -0
- data/app/assets/javascripts/gemgento/global.js.coffee +31 -0
- data/app/assets/stylesheets/gemgento/active_admin.css.scss +549 -0
- data/app/assets/stylesheets/gemgento/default-views/_address.scss +11 -0
- data/app/assets/stylesheets/gemgento/default-views/_category.scss +54 -0
- data/app/assets/stylesheets/gemgento/default-views/_checkout.scss +28 -0
- data/app/assets/stylesheets/gemgento/default-views/_footer.scss +13 -0
- data/app/assets/stylesheets/gemgento/default-views/_form.scss +127 -0
- data/app/assets/stylesheets/gemgento/default-views/_header.scss +32 -0
- data/app/assets/stylesheets/gemgento/default-views/_layout.css.scss +157 -0
- data/app/assets/stylesheets/gemgento/default-views/_pages.css.scss +83 -0
- data/app/assets/stylesheets/gemgento/default-views/_product.scss +57 -0
- data/app/assets/stylesheets/gemgento/default-views/_shopping_bag.scss +87 -0
- data/app/assets/stylesheets/gemgento/default-views/_subheader.css.scss +30 -0
- data/app/assets/stylesheets/gemgento/default-views/application.css.scss +1 -0
- data/app/controllers/concerns/gemgento/api/v1/base.rb +15 -0
- data/app/controllers/concerns/gemgento/api/v1/product_filters.rb +33 -0
- data/app/controllers/gemgento/addresses_controller.rb +14 -0
- data/app/controllers/gemgento/api/v1/categories_controller.rb +13 -0
- data/app/controllers/gemgento/api/v1/products_controller.rb +23 -0
- data/app/controllers/gemgento/api/v1/search_controller.rb +14 -0
- data/app/controllers/gemgento/application_controller.rb +5 -0
- data/app/controllers/gemgento/cart_controller.rb +99 -0
- data/app/controllers/gemgento/categories_controller.rb +37 -0
- data/app/controllers/gemgento/checkout/address_controller.rb +48 -0
- data/app/controllers/gemgento/checkout/confirm_controller.rb +72 -0
- data/app/controllers/gemgento/checkout/coupons_controller.rb +42 -0
- data/app/controllers/gemgento/checkout/gift_card_controller.rb +39 -0
- data/app/controllers/gemgento/checkout/gift_controller.rb +32 -0
- data/app/controllers/gemgento/checkout/login_controller.rb +123 -0
- data/app/controllers/gemgento/checkout/payment_controller.rb +70 -0
- data/app/controllers/gemgento/checkout/paypal_controller.rb +23 -0
- data/app/controllers/gemgento/checkout/shipping_controller.rb +46 -0
- data/app/controllers/gemgento/checkout/shipping_payment_controller.rb +58 -0
- data/app/controllers/gemgento/checkout/thank_you_controller.rb +45 -0
- data/app/controllers/gemgento/checkout_controller.rb +120 -0
- data/app/controllers/gemgento/countries_controller.rb +17 -0
- data/app/controllers/gemgento/errors_controller.rb +7 -0
- data/app/controllers/gemgento/footer_items_controller.rb +16 -0
- data/app/controllers/gemgento/home_controller.rb +7 -0
- data/app/controllers/gemgento/magento/addresses_controller.rb +61 -0
- data/app/controllers/gemgento/magento/base_controller.rb +18 -0
- data/app/controllers/gemgento/magento/categories_controller.rb +103 -0
- data/app/controllers/gemgento/magento/email/sales/credit_memos_controller.rb +21 -0
- data/app/controllers/gemgento/magento/email/sales/invoices_controller.rb +21 -0
- data/app/controllers/gemgento/magento/email/sales/orders_controller.rb +20 -0
- data/app/controllers/gemgento/magento/email/sales/shipments_controller.rb +25 -0
- data/app/controllers/gemgento/magento/emails_controller.rb +11 -0
- data/app/controllers/gemgento/magento/inventory_controller.rb +30 -0
- data/app/controllers/gemgento/magento/orders_controller.rb +12 -0
- data/app/controllers/gemgento/magento/price_rules_controller.rb +22 -0
- data/app/controllers/gemgento/magento/product_attribute_sets_controller.rb +37 -0
- data/app/controllers/gemgento/magento/product_attributes_controller.rb +70 -0
- data/app/controllers/gemgento/magento/products_controller.rb +240 -0
- data/app/controllers/gemgento/magento/recurring_profiles_controller.rb +42 -0
- data/app/controllers/gemgento/magento/stores_controller.rb +21 -0
- data/app/controllers/gemgento/magento/user_groups_controller.rb +23 -0
- data/app/controllers/gemgento/magento/users_controller.rb +63 -0
- data/app/controllers/gemgento/order_export_controller.rb +21 -0
- data/app/controllers/gemgento/orders_controller.rb +12 -0
- data/app/controllers/gemgento/products_controller.rb +12 -0
- data/app/controllers/gemgento/regions_controller.rb +18 -0
- data/app/controllers/gemgento/search_controller.rb +16 -0
- data/app/controllers/gemgento/shipments_controller.rb +5 -0
- data/app/controllers/gemgento/stock_notifications_controller.rb +22 -0
- data/app/controllers/gemgento/subscribers_controller.rb +35 -0
- data/app/controllers/gemgento/sync_controller.rb +50 -0
- data/app/controllers/gemgento/user/addresses_controller.rb +79 -0
- data/app/controllers/gemgento/user/base_controller.rb +14 -0
- data/app/controllers/gemgento/user/home_controller.rb +9 -0
- data/app/controllers/gemgento/user/orders_controller.rb +17 -0
- data/app/controllers/gemgento/user/passwords_controller.rb +18 -0
- data/app/controllers/gemgento/user/recurring_profiles_controller.rb +31 -0
- data/app/controllers/gemgento/user/registration_session_controller.rb +103 -0
- data/app/controllers/gemgento/user/registrations_controller.rb +28 -0
- data/app/controllers/gemgento/user/saved_credit_cards_controller.rb +56 -0
- data/app/controllers/gemgento/user/sessions_controller.rb +50 -0
- data/app/controllers/gemgento/user/wishlist_items_controller.rb +55 -0
- data/app/controllers/gemgento/users_controller.rb +36 -0
- data/app/helpers/gemgento/application_helper.rb +125 -0
- data/app/helpers/gemgento/categories_helper.rb +39 -0
- data/app/helpers/gemgento/checkout/payment_helper.rb +5 -0
- data/app/helpers/gemgento/products_helper.rb +23 -0
- data/app/jobs/gemgento/import_job.rb +12 -0
- data/app/mailers/gemgento/sales_mailer.rb +80 -0
- data/app/models/admin_user.rb +7 -0
- data/app/models/concerns/gemgento/product_touches.rb +26 -0
- data/app/models/gemgento.rb +5 -0
- data/app/models/gemgento/adapter/sellect/customer.rb +34 -0
- data/app/models/gemgento/adapter/sellect/order.rb +378 -0
- data/app/models/gemgento/adapter/sellect/product.rb +250 -0
- data/app/models/gemgento/adapter/sellect_adapter.rb +16 -0
- data/app/models/gemgento/adapter/shopify/address.rb +40 -0
- data/app/models/gemgento/adapter/shopify/category.rb +51 -0
- data/app/models/gemgento/adapter/shopify/customer.rb +66 -0
- data/app/models/gemgento/adapter/shopify/order.rb +334 -0
- data/app/models/gemgento/adapter/shopify/product.rb +377 -0
- data/app/models/gemgento/adapter/shopify/product_category_position.rb +58 -0
- data/app/models/gemgento/adapter/shopify_adapter.rb +63 -0
- data/app/models/gemgento/address.rb +206 -0
- data/app/models/gemgento/api_job.rb +68 -0
- data/app/models/gemgento/asset.rb +185 -0
- data/app/models/gemgento/asset_file.rb +57 -0
- data/app/models/gemgento/asset_type.rb +8 -0
- data/app/models/gemgento/bundle.rb +5 -0
- data/app/models/gemgento/bundle/item.rb +17 -0
- data/app/models/gemgento/bundle/option.rb +20 -0
- data/app/models/gemgento/category.rb +235 -0
- data/app/models/gemgento/country.rb +21 -0
- data/app/models/gemgento/gift_message.rb +8 -0
- data/app/models/gemgento/image_import.rb +141 -0
- data/app/models/gemgento/import.rb +125 -0
- data/app/models/gemgento/inventory.rb +60 -0
- data/app/models/gemgento/inventory_import.rb +51 -0
- data/app/models/gemgento/line_item.rb +142 -0
- data/app/models/gemgento/line_item_option.rb +10 -0
- data/app/models/gemgento/magento_db.rb +35 -0
- data/app/models/gemgento/magento_response.rb +10 -0
- data/app/models/gemgento/order.rb +56 -0
- data/app/models/gemgento/order_status.rb +7 -0
- data/app/models/gemgento/payment.rb +50 -0
- data/app/models/gemgento/price_rule.rb +258 -0
- data/app/models/gemgento/price_tier.rb +36 -0
- data/app/models/gemgento/product.rb +607 -0
- data/app/models/gemgento/product_attribute.rb +48 -0
- data/app/models/gemgento/product_attribute_option.rb +39 -0
- data/app/models/gemgento/product_attribute_set.rb +22 -0
- data/app/models/gemgento/product_attribute_value.rb +26 -0
- data/app/models/gemgento/product_category.rb +34 -0
- data/app/models/gemgento/product_import.rb +359 -0
- data/app/models/gemgento/quote.rb +586 -0
- data/app/models/gemgento/recurring_profile.rb +28 -0
- data/app/models/gemgento/region.rb +14 -0
- data/app/models/gemgento/relation.rb +10 -0
- data/app/models/gemgento/relation_type.rb +7 -0
- data/app/models/gemgento/saved_credit_card.rb +45 -0
- data/app/models/gemgento/search.rb +14 -0
- data/app/models/gemgento/session.rb +49 -0
- data/app/models/gemgento/shipment.rb +38 -0
- data/app/models/gemgento/shipment_comment.rb +19 -0
- data/app/models/gemgento/shipment_item.rb +11 -0
- data/app/models/gemgento/shipment_track.rb +21 -0
- data/app/models/gemgento/stock_notification.rb +17 -0
- data/app/models/gemgento/store.rb +31 -0
- data/app/models/gemgento/store_tag.rb +8 -0
- data/app/models/gemgento/subscriber.rb +30 -0
- data/app/models/gemgento/swatch.rb +9 -0
- data/app/models/gemgento/sync.rb +134 -0
- data/app/models/gemgento/tag.rb +64 -0
- data/app/models/gemgento/user.rb +161 -0
- data/app/models/gemgento/user_group.rb +13 -0
- data/app/models/gemgento/wishlist_item.rb +11 -0
- data/app/services/gemgento/magento_api.rb +173 -0
- data/app/services/gemgento/price.rb +67 -0
- data/app/validators/gemgento/credit_card_validator.rb +50 -0
- data/app/validators/gemgento/image_import_validator.rb +100 -0
- data/app/validators/gemgento/inventory_import_validator.rb +73 -0
- data/app/validators/gemgento/inventory_validator.rb +14 -0
- data/app/validators/gemgento/product_import_validator.rb +163 -0
- data/app/views/admin/product_positions/_index.html.haml +14 -0
- data/app/views/devise/registrations/edit.haml +37 -0
- data/app/views/gemgento/addresses/_address.json.jbuilder +6 -0
- data/app/views/gemgento/addresses/region_options.html.haml +1 -0
- data/app/views/gemgento/api/v1/categories/_category.json.jbuilder +52 -0
- data/app/views/gemgento/api/v1/categories/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/categories/show.json.jbuilder +7 -0
- data/app/views/gemgento/api/v1/products/_attributes.json.jbuilder +9 -0
- data/app/views/gemgento/api/v1/products/_product.json.jbuilder +18 -0
- data/app/views/gemgento/api/v1/products/_relationships.json.jbuilder +48 -0
- data/app/views/gemgento/api/v1/products/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/products/show.json.jbuilder +7 -0
- data/app/views/gemgento/api/v1/search/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/search/show.json.jbuilder +8 -0
- data/app/views/gemgento/assets/_asset.json.jbuilder +13 -0
- data/app/views/gemgento/cart/show.html.haml +67 -0
- data/app/views/gemgento/categories/_category.json.jbuilder +9 -0
- data/app/views/gemgento/categories/_product_tile.html.haml +16 -0
- data/app/views/gemgento/categories/index.html.haml +10 -0
- data/app/views/gemgento/categories/index.json.jbuilder +1 -0
- data/app/views/gemgento/categories/show.html.haml +16 -0
- data/app/views/gemgento/categories/show.json.jbuilder +1 -0
- data/app/views/gemgento/checkout/_checkout_header.html.haml +17 -0
- data/app/views/gemgento/checkout/address/error.js.erb +1 -0
- data/app/views/gemgento/checkout/address/show.html.haml +88 -0
- data/app/views/gemgento/checkout/address/success.js.erb +1 -0
- data/app/views/gemgento/checkout/confirm/error.js.erb +0 -0
- data/app/views/gemgento/checkout/confirm/show.html.haml +60 -0
- data/app/views/gemgento/checkout/confirm/success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_guest_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_guest_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/registration_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/registration_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/show.html.haml +50 -0
- data/app/views/gemgento/checkout/payment/error.js.erb +1 -0
- data/app/views/gemgento/checkout/payment/show.html.haml +56 -0
- data/app/views/gemgento/checkout/payment/success.js.erb +1 -0
- data/app/views/gemgento/checkout/shipping/error.js.erb +0 -0
- data/app/views/gemgento/checkout/shipping/show.html.haml +26 -0
- data/app/views/gemgento/checkout/shipping/success.js.erb +1 -0
- data/app/views/gemgento/checkout/shipping_payment/show.haml +52 -0
- data/app/views/gemgento/checkout/thank_you/show.html.haml +6 -0
- data/app/views/gemgento/countries/_country.json.jbuilder +4 -0
- data/app/views/gemgento/countries/index.json.jbuilder +3 -0
- data/app/views/gemgento/countries/show.json.jbuilder +1 -0
- data/app/views/gemgento/home/index.html.haml +1 -0
- data/app/views/gemgento/order/add_item.js.erb +0 -0
- data/app/views/gemgento/order/no_inventory.js.erb +1 -0
- data/app/views/gemgento/order/remove_item.js.erb +0 -0
- data/app/views/gemgento/order/update_item.js.erb +0 -0
- data/app/views/gemgento/order_export/index.html.haml +2 -0
- data/app/views/gemgento/order_items/_order_item.json.jbuilder +7 -0
- data/app/views/gemgento/orders/_order.json.jbuilder +29 -0
- data/app/views/gemgento/products/_product.json.jbuilder +40 -0
- data/app/views/gemgento/products/index.html.haml +19 -0
- data/app/views/gemgento/products/show.html.haml +67 -0
- data/app/views/gemgento/products/show.json.jbuilder +1 -0
- data/app/views/gemgento/sales_mailer/credit_memo_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/invoice_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/order_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/shipment_email.html.haml +1 -0
- data/app/views/gemgento/search/index.html.haml +8 -0
- data/app/views/gemgento/shared/_asset.json.jbuilder +35 -0
- data/app/views/gemgento/shared/_asset_file.json.jbuilder +19 -0
- data/app/views/gemgento/shared/_asset_type.json.jbuilder +13 -0
- data/app/views/gemgento/shared/_error_messages.haml +7 -0
- data/app/views/gemgento/shared/_flash_messages.haml +4 -0
- data/app/views/gemgento/shared/_footer.haml +7 -0
- data/app/views/gemgento/shared/_header.haml +23 -0
- data/app/views/gemgento/shared/_mini_bag.haml +36 -0
- data/app/views/gemgento/shared/_product_image.haml +8 -0
- data/app/views/gemgento/shipments/_shipment.json.jbuilder +12 -0
- data/app/views/gemgento/subscribers/create.js.erb +2 -0
- data/app/views/gemgento/subscribers/errors.js.erb +1 -0
- data/app/views/gemgento/user/_user.json.jbuilder +2 -0
- data/app/views/gemgento/user/addresses/_form.haml +39 -0
- data/app/views/gemgento/user/addresses/errors.js.erb +1 -0
- data/app/views/gemgento/user/addresses/index.haml +33 -0
- data/app/views/gemgento/user/addresses/new.haml +11 -0
- data/app/views/gemgento/user/addresses/success.js.erb +1 -0
- data/app/views/gemgento/user/confirmations/new.haml +9 -0
- data/app/views/gemgento/user/home/index.haml +8 -0
- data/app/views/gemgento/user/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/gemgento/user/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/gemgento/user/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/gemgento/user/orders/index.html.haml +29 -0
- data/app/views/gemgento/user/orders/show.html.haml +87 -0
- data/app/views/gemgento/user/passwords/edit.html.erb +18 -0
- data/app/views/gemgento/user/passwords/new.html.haml +21 -0
- data/app/views/gemgento/user/registration_session/new.haml +67 -0
- data/app/views/gemgento/user/registrations/new.html.haml +28 -0
- data/app/views/gemgento/user/saved_credit_cards/_form.haml +69 -0
- data/app/views/gemgento/user/saved_credit_cards/index.haml +25 -0
- data/app/views/gemgento/user/saved_credit_cards/new.haml +13 -0
- data/app/views/gemgento/user/sessions/new.html.haml +29 -0
- data/app/views/gemgento/user/shared/_links.erb +25 -0
- data/app/views/gemgento/user/shared/_user_header.haml +8 -0
- data/app/views/gemgento/user/wishlist_items/index.html.haml +20 -0
- data/app/views/kaminari/_first_page.html.haml +9 -0
- data/app/views/kaminari/_gap.html.haml +8 -0
- data/app/views/kaminari/_last_page.html.haml +9 -0
- data/app/views/kaminari/_next_page.html.haml +9 -0
- data/app/views/kaminari/_page.html.haml +10 -0
- data/app/views/kaminari/_paginator.html.haml +18 -0
- data/app/views/kaminari/_prev_page.html.haml +9 -0
- data/app/views/layouts/_footer.html.haml +5 -0
- data/app/views/layouts/_header.html.haml +39 -0
- data/app/views/layouts/gemgento.html.haml +22 -0
- data/app/workers/gemgento/apply_price_rule.rb +24 -0
- data/app/workers/gemgento/cart/add_item_worker.rb +23 -0
- data/app/workers/gemgento/cart/update_item_worker.rb +18 -0
- data/bin/rails +12 -0
- data/config/gemgento_config.yml +12 -0
- data/config/initializers/active_admin.rb +14 -0
- data/config/initializers/active_touch.rb +3 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/boolean_typecasting.rb +37 -0
- data/config/initializers/devise.rb +49 -0
- data/config/initializers/gemgento_config.rb +67 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/state_machine.rb +7 -0
- data/config/locales/en.yml +24 -0
- data/config/routes.rb +138 -0
- data/db/migrate/20151201231300_add_validation_indexes_to_gemgento_products.rb +22 -0
- data/db/migrate/20160122174450_gemgento2.rb +969 -0
- data/db/migrate/20160217142910_create_gemgento_imports.rb +15 -0
- data/db/migrate/20160219235858_add_timestamps_to_gemgento_asset_files.rb +6 -0
- data/gemgento.gemspec +44 -0
- data/lib/devise/models/validatable.rb +76 -0
- data/lib/gemgento.rb +24 -0
- data/lib/gemgento/admin/admin_user.rb +29 -0
- data/lib/gemgento/admin/api_jobs.rb +30 -0
- data/lib/gemgento/admin/image_import.rb +87 -0
- data/lib/gemgento/admin/inventory_import.rb +81 -0
- data/lib/gemgento/admin/product_import.rb +138 -0
- data/lib/gemgento/admin/product_positions.rb +49 -0
- data/lib/gemgento/admin/stores.rb +33 -0
- data/lib/gemgento/admin/subscribers.rb +31 -0
- data/lib/gemgento/admin/syncs.rb +26 -0
- data/lib/gemgento/api/soap/authnetcim/payment.rb +127 -0
- data/lib/gemgento/api/soap/catalog/category.rb +237 -0
- data/lib/gemgento/api/soap/catalog/product.rb +481 -0
- data/lib/gemgento/api/soap/catalog/product_attribute.rb +147 -0
- data/lib/gemgento/api/soap/catalog/product_attribute_media.rb +202 -0
- data/lib/gemgento/api/soap/catalog/product_attribute_set.rb +80 -0
- data/lib/gemgento/api/soap/catalog/product_tag.rb +146 -0
- data/lib/gemgento/api/soap/catalog/product_tier_price.rb +21 -0
- data/lib/gemgento/api/soap/catalog/search.rb +27 -0
- data/lib/gemgento/api/soap/catalog_inventory/stock_item.rb +87 -0
- data/lib/gemgento/api/soap/catalog_rule/rule.rb +54 -0
- data/lib/gemgento/api/soap/checkout/cart.rb +85 -0
- data/lib/gemgento/api/soap/checkout/coupon.rb +37 -0
- data/lib/gemgento/api/soap/checkout/customer.rb +87 -0
- data/lib/gemgento/api/soap/checkout/payment.rb +59 -0
- data/lib/gemgento/api/soap/checkout/product.rb +138 -0
- data/lib/gemgento/api/soap/checkout/shipping.rb +37 -0
- data/lib/gemgento/api/soap/customer/address.rb +143 -0
- data/lib/gemgento/api/soap/customer/customer.rb +200 -0
- data/lib/gemgento/api/soap/directory/country.rb +49 -0
- data/lib/gemgento/api/soap/directory/region.rb +50 -0
- data/lib/gemgento/api/soap/enterprise_gift_message/gift_message.rb +26 -0
- data/lib/gemgento/api/soap/gift_card.rb +35 -0
- data/lib/gemgento/api/soap/globalcollect/saved_cc.rb +58 -0
- data/lib/gemgento/api/soap/miscellaneous/store.rb +47 -0
- data/lib/gemgento/api/soap/sales/order.rb +249 -0
- data/lib/gemgento/api/soap/sales/order_shipment.rb +122 -0
- data/lib/gemgento/api/soap/sales/recurring_profile.rb +88 -0
- data/lib/gemgento/api/soap/stock_notification.rb +27 -0
- data/lib/gemgento/engine.rb +61 -0
- data/lib/gemgento/version.rb +3 -0
- data/lib/generators/gemgento/assets_generator.rb +11 -0
- data/lib/generators/gemgento/install_generator.rb +34 -0
- data/lib/generators/gemgento/templates/active_admin.css.scss +1 -0
- data/lib/generators/gemgento/templates/active_admin.js.coffee +1 -0
- data/lib/generators/gemgento/templates/active_admin.rb +3 -0
- data/lib/generators/gemgento/views_generator.rb +10 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +20 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/gemgento_config.yml +22 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/gemgento/price_tiers.rb +8 -0
- data/spec/factories/gemgento/product_attribute_sets.rb +22 -0
- data/spec/factories/gemgento/product_attributes.rb +5 -0
- data/spec/factories/gemgento/products.rb +14 -0
- data/spec/factories/gemgento/stores.rb +12 -0
- data/spec/factories/gemgento/user_groups.rb +6 -0
- data/spec/factories/gemgento/users.rb +13 -0
- data/spec/factories/gemgento_imports.rb +12 -0
- data/spec/model/gemgento/price_tier_spec.rb +45 -0
- data/spec/rails_helper.rb +55 -0
- data/spec/services/gemgento/price_spec.rb +152 -0
- data/spec/spec_helper.rb +87 -0
- metadata +919 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
module Gemgento
|
|
2
|
+
|
|
3
|
+
# @author Gemgento LLC
|
|
4
|
+
class Address < ActiveRecord::Base
|
|
5
|
+
belongs_to :addressable, polymorphic: true, class_name: 'Gemgento::Address'
|
|
6
|
+
belongs_to :country, class_name: 'Gemgento::Country'
|
|
7
|
+
belongs_to :region, class_name: 'Gemgento::Region'
|
|
8
|
+
|
|
9
|
+
has_one :shopify_adapter, class_name: 'Adapter::ShopifyAdapter', as: :gemgento_model
|
|
10
|
+
|
|
11
|
+
attr_accessor :address1, :address2, :address3, :copy_to_user
|
|
12
|
+
|
|
13
|
+
validates :region, presence: true, if: Proc.new { |address| !address.country.nil? && address.country.regions.any? }
|
|
14
|
+
validates_uniqueness_of :addressable_id,
|
|
15
|
+
scope: [:addressable_type, :street, :city, :country, :region, :postcode, :telephone],
|
|
16
|
+
message: 'address is not unique',
|
|
17
|
+
if: :is_addressable_user?
|
|
18
|
+
|
|
19
|
+
after_find :explode_street_address
|
|
20
|
+
before_validation :strip_whitespace, :implode_street_address
|
|
21
|
+
|
|
22
|
+
before_create :create_magento_address, if: :create_magento_address?
|
|
23
|
+
before_update :update_magento_address, if: :update_magento_address?
|
|
24
|
+
before_destroy :destroy_magento_address, if: :update_magento_address?
|
|
25
|
+
|
|
26
|
+
after_save :enforce_single_default, if: :is_addressable_user?
|
|
27
|
+
after_save :copy_from_addressable_to_user, if: :copy_from_addressable_to_user?
|
|
28
|
+
|
|
29
|
+
default_scope -> { order(is_billing: :desc, is_shipping: :desc, updated_at: :desc) }
|
|
30
|
+
|
|
31
|
+
# Return the Address as JSON.
|
|
32
|
+
#
|
|
33
|
+
# @param options [Hash] an optional hash of options.
|
|
34
|
+
# @return [String]
|
|
35
|
+
def as_json(options = nil)
|
|
36
|
+
result = super
|
|
37
|
+
result['address1'] = self.address1
|
|
38
|
+
result['address2'] = self.address2
|
|
39
|
+
result['address3'] = self.address3
|
|
40
|
+
result['country'] = self.country.name unless self.country.nil?
|
|
41
|
+
result['region'] = self.region.code unless self.region.nil?
|
|
42
|
+
return result
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Duplicate address from addressable user to user.
|
|
46
|
+
#
|
|
47
|
+
# @return [Gemgento::Address] the newly created Address.
|
|
48
|
+
def copy_from_addressable_to_user
|
|
49
|
+
address = duplicate
|
|
50
|
+
address.addressable = self.addressable.user
|
|
51
|
+
address.is_billing = self.is_billing
|
|
52
|
+
address.is_shipping = self.is_shipping
|
|
53
|
+
address.sync_needed = true
|
|
54
|
+
address.save
|
|
55
|
+
|
|
56
|
+
return address
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @return [Boolean]
|
|
60
|
+
def copy_from_addressable_to_user?
|
|
61
|
+
self.copy_to_user.to_bool && self.addressable.try(:user).is_a?(Gemgento::User)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Set the street attribute. Override required to explode the street into address lines.
|
|
65
|
+
def street=(value)
|
|
66
|
+
super
|
|
67
|
+
explode_street_address
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Duplicate an address. Different from dup because it avoids unique magento attributes and includes
|
|
71
|
+
# country and region associations.
|
|
72
|
+
#
|
|
73
|
+
# @return [Gemgento::Address] newly duplicated address
|
|
74
|
+
def duplicate
|
|
75
|
+
address = self.dup
|
|
76
|
+
address.region = self.region
|
|
77
|
+
address.country = self.country
|
|
78
|
+
address.magento_id = nil
|
|
79
|
+
address.addressable = nil
|
|
80
|
+
address.is_billing = false
|
|
81
|
+
address.is_shipping = false
|
|
82
|
+
address.increment_id = nil
|
|
83
|
+
address.sync_needed = false
|
|
84
|
+
|
|
85
|
+
return address
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def is_addressable_user?
|
|
89
|
+
self.addressable.is_a?(Gemgento::User)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Check if a Magento address can be created.
|
|
93
|
+
#
|
|
94
|
+
# @return [Boolean]
|
|
95
|
+
def create_magento_address?
|
|
96
|
+
self.magento_id.nil? && self.is_addressable_user?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Check if a Magento address can be updated.
|
|
100
|
+
#
|
|
101
|
+
# @return [Boolean]
|
|
102
|
+
def update_magento_address?
|
|
103
|
+
!self.magento_id.nil? && self.is_addressable_user?
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
private
|
|
107
|
+
|
|
108
|
+
# Strip attributes where leading/trailing whitespace could pose problems.
|
|
109
|
+
#
|
|
110
|
+
# @return [void]
|
|
111
|
+
def strip_whitespace
|
|
112
|
+
self.first_name = self.first_name.strip unless self.first_name.nil?
|
|
113
|
+
self.last_name = self.last_name.strip unless self.last_name.nil?
|
|
114
|
+
self.city = self.city.strip unless self.city.nil?
|
|
115
|
+
self.postcode = self.postcode.strip unless self.postcode.nil?
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Split the street attribute into 3 address line attributes. Magento stores street addresses lines as a
|
|
119
|
+
# single attribute that uses line breaks to differentiate the lines.
|
|
120
|
+
#
|
|
121
|
+
# @return [void]
|
|
122
|
+
def explode_street_address
|
|
123
|
+
return if self.street.nil?
|
|
124
|
+
|
|
125
|
+
address = self.street.split("\n")
|
|
126
|
+
self.address1 = address[0] unless address[0].blank?
|
|
127
|
+
self.address2 = address[1] unless address[1].blank?
|
|
128
|
+
self.address3 = address[2] unless address[2].blank?
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Combine the 3 address line attributes into a single street attribute. Magento stores street addresses lines as a
|
|
132
|
+
# single attribute that uses line breaks to differentiate the lines.
|
|
133
|
+
#
|
|
134
|
+
# @return [void]
|
|
135
|
+
def implode_street_address
|
|
136
|
+
street = []
|
|
137
|
+
street << self.address1 unless self.address1.blank?
|
|
138
|
+
street << self.address2 unless self.address2.blank?
|
|
139
|
+
street << self.address3 unless self.address3.blank?
|
|
140
|
+
self.street = street.join("\n") unless street.blank?
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Create an associated address in Magento.
|
|
144
|
+
#
|
|
145
|
+
# @return [Boolean]
|
|
146
|
+
def create_magento_address
|
|
147
|
+
return true unless self.create_magento_address?
|
|
148
|
+
|
|
149
|
+
response = API::SOAP::Customer::Address.create(self)
|
|
150
|
+
|
|
151
|
+
if response.success?
|
|
152
|
+
self.magento_id = response.body[:result]
|
|
153
|
+
return true
|
|
154
|
+
else
|
|
155
|
+
errors.add(:base, response.body[:faultstring])
|
|
156
|
+
return false
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Update associated address in Magento.
|
|
161
|
+
#
|
|
162
|
+
# @return [Boolean]
|
|
163
|
+
def update_magento_address
|
|
164
|
+
return true unless self.update_magento_address?
|
|
165
|
+
|
|
166
|
+
response = API::SOAP::Customer::Address.update(self)
|
|
167
|
+
|
|
168
|
+
if response.success?
|
|
169
|
+
return true
|
|
170
|
+
else
|
|
171
|
+
errors.add(:base, response.body[:faultstring])
|
|
172
|
+
return false
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Destroy the address in Magento. This is the before destroy callback.
|
|
177
|
+
#
|
|
178
|
+
# @return [void]
|
|
179
|
+
def destroy_magento_address
|
|
180
|
+
return true unless self.update_magento_address?
|
|
181
|
+
|
|
182
|
+
response = API::SOAP::Customer::Address.delete(self.magento_id)
|
|
183
|
+
|
|
184
|
+
if response.success?
|
|
185
|
+
return true
|
|
186
|
+
else
|
|
187
|
+
errors.add(:base, response.body[:faultstring])
|
|
188
|
+
return false
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Make sure the user has only one default Address for the type (shipping/billing).
|
|
193
|
+
#
|
|
194
|
+
# @return [void]
|
|
195
|
+
def enforce_single_default
|
|
196
|
+
if self.is_billing
|
|
197
|
+
self.addressable.addresses.where('id != ?', self.id).update_all(is_billing: false)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
if self.is_shipping
|
|
201
|
+
self.addressable.addresses.where('id != ?', self.id).update_all(is_shipping: false)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
end
|
|
206
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module Gemgento
|
|
2
|
+
|
|
3
|
+
# @author Gemgento LLC
|
|
4
|
+
class ApiJob < ActiveRecord::Base
|
|
5
|
+
belongs_to :source, polymorphic: true
|
|
6
|
+
|
|
7
|
+
state_machine :state, initial: 'pending', use_transactions: false do
|
|
8
|
+
event :ready do
|
|
9
|
+
transition from: 'pending', to: 'ready'
|
|
10
|
+
end
|
|
11
|
+
event :active do
|
|
12
|
+
transition from: 'ready', to: 'active'
|
|
13
|
+
end
|
|
14
|
+
event :complete do
|
|
15
|
+
transition from: 'active', to: 'complete'
|
|
16
|
+
transition from: 'ready', to: 'complete'
|
|
17
|
+
transition from: 'error', to: 'complete'
|
|
18
|
+
end
|
|
19
|
+
event :error do
|
|
20
|
+
transition from: 'active', to: 'error'
|
|
21
|
+
transition from: 'ready', to: 'error'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
before_transition to: 'ready', do: :is_ready!
|
|
25
|
+
before_transition to: 'complete', do: :is_completed!
|
|
26
|
+
after_transition to: 'error', do: :error!
|
|
27
|
+
after_transition to: 'complete', do: :finalize!
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Determine if the ApiJob is ready to be activated. This method needs to be overridden in the child class.
|
|
31
|
+
#
|
|
32
|
+
# @return [void]
|
|
33
|
+
def is_ready!
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Determine if the ApiJob is completed. This method needs to be overridden in the child class.
|
|
37
|
+
#
|
|
38
|
+
# @return [void]
|
|
39
|
+
def is_completed!
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Print the ApiJob details after the ApiJob has transitioned to the error state.
|
|
43
|
+
#
|
|
44
|
+
# @return [void]
|
|
45
|
+
def error!
|
|
46
|
+
puts(self.inspect)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Lock the ApiJob after it has transitioned to the complete state.
|
|
50
|
+
#
|
|
51
|
+
# @return [void]
|
|
52
|
+
def finalize!
|
|
53
|
+
self.update_attribute('locked', true)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Perform the ApiJob. This is meant to be overridden in the child class. The requirements of overriding this
|
|
57
|
+
# method are to transition the ApiJob into the active state before doing anything, then upon completion, transition
|
|
58
|
+
# to either the complete or error state.
|
|
59
|
+
#
|
|
60
|
+
# @return [void]
|
|
61
|
+
def activate(payload)
|
|
62
|
+
self.active
|
|
63
|
+
# perform action here
|
|
64
|
+
self.complete
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
|
|
3
|
+
module Gemgento
|
|
4
|
+
|
|
5
|
+
# @author Gemgento LLC
|
|
6
|
+
class Asset < ActiveRecord::Base
|
|
7
|
+
include Gemgento::ProductTouches
|
|
8
|
+
|
|
9
|
+
belongs_to :product, class_name: 'Gemgento::Product'
|
|
10
|
+
belongs_to :store, class_name: 'Gemgento::Store'
|
|
11
|
+
belongs_to :asset_file, class_name: 'Gemgento::AssetFile'
|
|
12
|
+
|
|
13
|
+
has_and_belongs_to_many :asset_types, join_table: 'gemgento_assets_asset_types'
|
|
14
|
+
|
|
15
|
+
validates :asset_file, :product_id, :store_id, presence: true
|
|
16
|
+
validates_uniqueness_of :product_id, scope: [:asset_file_id, :store_id, :file]
|
|
17
|
+
|
|
18
|
+
before_save :create_magento_product_attribute_media, if: -> { sync_needed? && file.blank? }
|
|
19
|
+
before_save :update_magento_product_attribute_media, if: -> { sync_needed? && !file.blank? }
|
|
20
|
+
|
|
21
|
+
before_destroy :delete_magento, :destroy_file
|
|
22
|
+
|
|
23
|
+
default_scope -> { includes(:asset_file).order(:position).references(:asset_file) }
|
|
24
|
+
|
|
25
|
+
# Associate an image file with the Asset. If the same file is already associated to a related Asset in a
|
|
26
|
+
# different store, then the Asset will be associated with the existing AssetFile.
|
|
27
|
+
#
|
|
28
|
+
# @param file [File, TempFile] a file to be associated with the Asset
|
|
29
|
+
# @return [void]
|
|
30
|
+
def set_file(file)
|
|
31
|
+
matching_file = nil
|
|
32
|
+
matching_asset = nil
|
|
33
|
+
|
|
34
|
+
self.product.assets.each do |asset|
|
|
35
|
+
next if asset.asset_file.nil?
|
|
36
|
+
next if asset.store == self.store && asset.id != self.id # don't compare AssetFiles from the same store unless it's the same Asset
|
|
37
|
+
|
|
38
|
+
if File.exist?(asset.asset_file.file.path(:original)) && FileUtils.compare_file(asset.asset_file.file.path(:original), file)
|
|
39
|
+
matching_file = asset.asset_file
|
|
40
|
+
matching_asset = asset
|
|
41
|
+
break
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if matching_file.nil?
|
|
46
|
+
begin
|
|
47
|
+
matching_file = AssetFile.new
|
|
48
|
+
matching_file.file = file
|
|
49
|
+
matching_file.save
|
|
50
|
+
rescue
|
|
51
|
+
matching_file = nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
matching_asset = Asset.new
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
self.asset_file = matching_file
|
|
58
|
+
self.file = matching_asset.file if self.file.blank? && !matching_asset.file.blank?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Return the image file associated with the Asset.
|
|
62
|
+
#
|
|
63
|
+
# @return [Paperclip::Attachment, nil]
|
|
64
|
+
def image
|
|
65
|
+
if self.asset_file.nil?
|
|
66
|
+
nil
|
|
67
|
+
else
|
|
68
|
+
self.asset_file.file
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Associate AssetTypes to the Asset.
|
|
73
|
+
#
|
|
74
|
+
# @param asset_type_codes [Array(String)] asset type codes
|
|
75
|
+
# @return [void]
|
|
76
|
+
def set_types_by_codes(asset_type_codes)
|
|
77
|
+
applied_asset_types = []
|
|
78
|
+
|
|
79
|
+
# loop through each return category and add it to the product if needed
|
|
80
|
+
asset_type_codes.each do |asset_type_code|
|
|
81
|
+
next if asset_type_code.blank?
|
|
82
|
+
|
|
83
|
+
asset_type = AssetType.find_by(
|
|
84
|
+
product_attribute_set: self.product.product_attribute_set,
|
|
85
|
+
code: asset_type_code,
|
|
86
|
+
)
|
|
87
|
+
next if asset_type.nil?
|
|
88
|
+
|
|
89
|
+
self.asset_types << asset_type unless self.asset_types.include? asset_type # don't duplicate the asset types
|
|
90
|
+
applied_asset_types << asset_type.id
|
|
91
|
+
|
|
92
|
+
# an AssetType can only be associated to one asset for every
|
|
93
|
+
asset_type.assets.where(product_id: self.product_id, store_id: self.store_id).where('gemgento_assets.id != ?', self.id).find_each do |asset|
|
|
94
|
+
asset.asset_types.destroy(asset_type)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# destroy any asset type associations that were not in the list
|
|
99
|
+
self.asset_types.delete(AssetType.where('id NOT IN (?)', applied_asset_types))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Find a products asset by the AssetType code
|
|
103
|
+
#
|
|
104
|
+
# @param product [Product]
|
|
105
|
+
# @param code [String]
|
|
106
|
+
# @param store [Integer, nil]
|
|
107
|
+
# @return [Asset, nil]
|
|
108
|
+
def self.find_by_code(product, code, store = nil)
|
|
109
|
+
product.assets
|
|
110
|
+
.joins(:asset_types)
|
|
111
|
+
.where(store: store || Gemgento::Store.current)
|
|
112
|
+
.where(gemgento_asset_types: { code: code, product_attribute_set_id: product.product_attribute_set_id })
|
|
113
|
+
.first
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def as_json(options = {})
|
|
117
|
+
result = super
|
|
118
|
+
|
|
119
|
+
result[:styles] = {'original' => self.image.url(:original)}
|
|
120
|
+
|
|
121
|
+
self.image.styles.keys.to_a.each do |style|
|
|
122
|
+
result[:styles][style] = self.image.url(style.to_sym)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
result[:types] = []
|
|
126
|
+
self.asset_types.each do |asset_type|
|
|
127
|
+
result[:types] << asset_type.code unless result[:types].include? asset_type.code
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
return result
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
private
|
|
134
|
+
|
|
135
|
+
# Create an associated ProductAttributeMedia in Magento.
|
|
136
|
+
#
|
|
137
|
+
# @return [Boolean]
|
|
138
|
+
def create_magento_product_attribute_media
|
|
139
|
+
response = API::SOAP::Catalog::ProductAttributeMedia.create(self)
|
|
140
|
+
|
|
141
|
+
if response.success?
|
|
142
|
+
self.file = response.body[:result]
|
|
143
|
+
return true
|
|
144
|
+
else
|
|
145
|
+
errors.add(:base, response.body[:faultstring])
|
|
146
|
+
return false
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Create an associated ProductAttributeMedia in Magento.
|
|
151
|
+
#
|
|
152
|
+
# @return [Boolean]
|
|
153
|
+
def update_magento_product_attribute_media
|
|
154
|
+
response = API::SOAP::Catalog::ProductAttributeMedia.update(self)
|
|
155
|
+
|
|
156
|
+
if response.success?
|
|
157
|
+
return true
|
|
158
|
+
else
|
|
159
|
+
errors.add(:base, response.body[:faultstring])
|
|
160
|
+
return false
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Destroy the Asset in Magento. This is a before destroy callback.
|
|
165
|
+
#
|
|
166
|
+
# @return [void]
|
|
167
|
+
def delete_magento
|
|
168
|
+
if !self.file.blank? && (!self.asset_file.nil? && self.asset_file.assets.where('gemgento_assets.id != ?', self.id).empty?)
|
|
169
|
+
API::SOAP::Catalog::ProductAttributeMedia.remove(self)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
self.asset_types.clear
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Destroy the associated AssetFile if it is not used by other Assets. This is a before destroy callback.
|
|
176
|
+
#
|
|
177
|
+
# @return [void]
|
|
178
|
+
def destroy_file
|
|
179
|
+
if !self.asset_file.nil? && self.asset_file.assets.where('gemgento_assets.id != ?', self.id).empty?
|
|
180
|
+
self.asset_file.destroy
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
end
|
|
185
|
+
end
|