Class: Gemgento::Sync
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gemgento::Sync
- Defined in:
- app/models/gemgento/sync.rb
Overview
Class Method Summary collapse
- .attributes ⇒ Object
- .categories ⇒ Object
- .customers ⇒ Object
- .end_all ⇒ Object
- .everything ⇒ Object
- .inventory ⇒ Object
- .is_active?(subject = nil) ⇒ Boolean
- .locations ⇒ Object
- .orders ⇒ Object
- .products(skip_existing = false) ⇒ Object
- .stores ⇒ Object
Instance Method Summary collapse
Class Method Details
.attributes ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/models/gemgento/sync.rb', line 25 def self.attributes current = create_current('attributes') Gemgento::API::SOAP::Catalog::ProductAttributeSet.fetch_all Gemgento::API::SOAP::Catalog::ProductAttribute.fetch_all Gemgento::API::SOAP::Catalog::ProductAttributeMedia.fetch_all_media_types current.complete end |
.categories ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/models/gemgento/sync.rb', line 16 def self.categories current = create_current('categories') Gemgento::API::SOAP::Catalog::Category.fetch_all Gemgento::API::SOAP::Catalog::Category.set_product_categories current.complete end |
.customers ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/gemgento/sync.rb', line 52 def self.customers last_updated = Sync.where('subject IN (?) AND is_complete = ?', %w[customers everything], 1).order('created_at DESC').first last_updated = last_updated.created_at.to_s(:db) unless last_updated.nil? current = create_current('customers') Gemgento::API::SOAP::Customer::Customer.fetch_all_customer_groups Gemgento::API::SOAP::Customer::Customer.fetch_all(last_updated_filter(last_updated)) current.complete end |
.end_all ⇒ Object
106 107 108 |
# File 'app/models/gemgento/sync.rb', line 106 def self.end_all Sync.update_all('is_complete = 1') end |
.everything ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/models/gemgento/sync.rb', line 73 def self.everything current = create_current('everything') Gemgento::API::SOAP::Directory::Country.fetch_all Gemgento::API::SOAP::Directory::Region.fetch_all Gemgento::API::SOAP::Miscellaneous::Store.fetch_all Gemgento::API::SOAP::Catalog::Category.fetch_all Gemgento::API::SOAP::Catalog::ProductAttributeSet.fetch_all Gemgento::API::SOAP::Catalog::ProductAttribute.fetch_all Gemgento::API::SOAP::Catalog::ProductAttributeMedia.fetch_all_media_types Gemgento::API::SOAP::Catalog::Product.fetch_all Gemgento::API::SOAP::Catalog::Category.set_product_categories Gemgento::API::SOAP::CatalogInventory::StockItem.fetch_all Gemgento::API::SOAP::Customer::Customer.fetch_all_customer_groups Gemgento::API::SOAP::Customer::Customer.fetch_all Gemgento::API::SOAP::Sales::Order.fetch_all current.complete end |
.inventory ⇒ Object
46 47 48 49 50 |
# File 'app/models/gemgento/sync.rb', line 46 def self.inventory current = create_current('inventory') Gemgento::API::SOAP::CatalogInventory::StockItem.fetch_all current.complete end |
.is_active?(subject = nil) ⇒ Boolean
98 99 100 101 102 103 104 |
# File 'app/models/gemgento/sync.rb', line 98 def self.is_active?(subject = nil) if subject.nil? return !Sync.active.empty? else return !Sync.where('subject IN (?)', subject).active.empty? end end |
.locations ⇒ Object
7 8 9 10 |
# File 'app/models/gemgento/sync.rb', line 7 def self.locations Gemgento::API::SOAP::Directory::Country.fetch_all Gemgento::API::SOAP::Directory::Region.fetch_all end |
.orders ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'app/models/gemgento/sync.rb', line 63 def self.orders last_updated = Sync.where('subject IN (?) AND is_complete = ?', %w[orders everything], 1).order('created_at DESC').first last_updated = last_updated.created_at.to_s(:db) unless last_updated.nil? current = create_current('orders') Gemgento::API::SOAP::Sales::Order.fetch_all last_updated current.complete end |
.products(skip_existing = false) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/gemgento/sync.rb', line 35 def self.products(skip_existing = false) last_updated = Sync.where('subject IN (?) AND is_complete = ?', %w[products everything], 1).order('created_at DESC').first last_updated = last_updated.created_at.to_s(:db) unless last_updated.nil? current = create_current('products') Gemgento::API::SOAP::Catalog::Product.fetch_all last_updated Gemgento::API::SOAP::Catalog::Category.set_product_categories current.complete end |
Instance Method Details
#complete ⇒ Object
93 94 95 96 |
# File 'app/models/gemgento/sync.rb', line 93 def complete self.is_complete = true self.save end |