item_models 0.0.16 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bb9091dc58e62a90422baf821b798b08387d1b13e4c9bfbf3d519e26dda5cae
4
- data.tar.gz: 3675c282105208b2d61e91c187479232110fe9278c076684517c768faf161c4e
3
+ metadata.gz: d872a325665c20b099296417ca9dc897438119060e8a7afdfba68af020ad42cf
4
+ data.tar.gz: 98d4410bda21cf5bec2e2064dabe9c5b290c518140105b6b26fa837b17bf9211
5
5
  SHA512:
6
- metadata.gz: a02f15bfc3f2f3cbac0b036acad9fac5a30c85c365b4b047ca937b5bb54338de3166b6ab07469779ca1eb55acd07ec58acc31b825654d8aa1620b41f49442321
7
- data.tar.gz: 63e1a4e82230dec57a8f3090f34cac08a45bf71021f71ad9ef8ca9217f2d782138554d0cb0d891310e0956f50044d8191981d5ac424bb39f4afc8ca396287b7d
6
+ metadata.gz: 6e352df5cebe787d50cee89fd1b9fbfbc469182ad884827f4c828de9240c03baabc3565dcee5ba7f53e55f9d488f8c44ef7955026974de5ca71d4fa85cd8d27e
7
+ data.tar.gz: 8290b73f9aad00ee65f029138c7087f341e8402f841011ce77ff558856e62f19fce841a5577741149633625a0307b3c5b99822372becfe79e14f87b8ff664bda
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ItemModels
4
- VERSION = '0.0.16'
4
+ VERSION = '0.0.18'
5
5
  end
data/lib/models/item.rb CHANGED
@@ -8,4 +8,9 @@ class Item < ItemApplicationRecord
8
8
  has_many :item_listings
9
9
  has_many :bundles
10
10
  has_many :images
11
+ has_many :option_types, foreign_key: :item_id
12
+
13
+ def assign_from_profile(profile)
14
+ self.profile_id = profile.id
15
+ end
11
16
  end
@@ -21,4 +21,12 @@ class ItemListing < ItemApplicationRecord
21
21
  has_one :category,
22
22
  dependent: :destroy,
23
23
  autosave: true
24
+
25
+ def assign_from_item(item)
26
+ self.item_id = item.id
27
+ end
28
+
29
+ def assign_from_account(account)
30
+ self.channel_id = account.channel_id
31
+ end
24
32
  end
@@ -10,4 +10,8 @@ class ItemListingBrand < ItemApplicationRecord
10
10
  class_name: 'ShopeeBrand',
11
11
  foreign_key: :shopee_brand_id,
12
12
  optional: true
13
+ belongs_to :tokopedia,
14
+ class_name: 'ShopeeBrand',
15
+ foreign_key: :shopee_brand_id,
16
+ optional: true
13
17
  end
@@ -10,4 +10,8 @@ class ItemListingCategory < ItemApplicationRecord
10
10
  class_name: 'ShopeeCategory',
11
11
  foreign_key: :shopee_category_id,
12
12
  optional: true
13
+ belongs_to :tokopedia,
14
+ class_name: 'TokopediaCategory',
15
+ foreign_key: :tokopedia_category_id,
16
+ optional: true
13
17
  end
@@ -10,4 +10,8 @@ class ItemListingVariantCustomField < ItemApplicationRecord
10
10
  class_name: 'ShopeeItemVariantCustomField',
11
11
  foreign_key: :shopee_item_variant_custom_field_id,
12
12
  optional: true
13
+ belongs_to :tokopedia,
14
+ class_name: 'TokopediaItemVariantCustomField',
15
+ foreign_key: :tokopedia_custom_field_id,
16
+ optional: true
13
17
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class OptionType < ItemApplicationRecord
4
+ self.table_name = 'item_variant_option_types'
5
+
6
+ belongs_to :item
7
+ has_many :options, class_name: 'VariantOption', foreign_key: :option_type_id
8
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TokopediaCategory < ItemApplicationRecord
4
+ self.table_name = 'channel_tokopedia_categories'
5
+
6
+ belongs_to :parent_category,
7
+ class_name: 'TokopediaCategory',
8
+ foreign_key: :parent_category_id,
9
+ optional: true
10
+ belongs_to :primary_category,
11
+ class_name: 'TokopediaCategory',
12
+ foreign_key: :primary_category_id,
13
+ optional: true
14
+ has_many :child_categories,
15
+ class_name: 'TokopediaCategory',
16
+ foreign_key: :parent_category_id,
17
+ dependent: :destroy
18
+
19
+ has_many :item_channel_association_categories,
20
+ class_name: '::ItemListingCategory',
21
+ foreign_key: :tokopedia_category_id
22
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TokopediaItemVariantCustomField < ItemApplicationRecord
4
+ self.table_name = 'channel_tokopedia_item_variant_custom_fields'
5
+ end
@@ -13,4 +13,11 @@ class Variant < ItemApplicationRecord
13
13
  has_many :item_listing_variant_custom_field, foreign_key: :variant_id
14
14
  has_many :item_listing_custom_field, foreign_key: :variant_id
15
15
  has_one :master_catalog, foreign_key: :variant_id
16
+ has_many :option_associations, class_name: 'VariantOptionAssociation', foreign_key: :variant_id
17
+ has_many :options, through: :option_associations, source: :variant_option
18
+
19
+ def assign_from_item(item)
20
+ self.item_id = item.id
21
+ self.profile_id = item.profile_id
22
+ end
16
23
  end
@@ -35,4 +35,17 @@ class VariantListing < ItemApplicationRecord
35
35
  "channel_association_id = ? AND variant_id = ? AND account_id = ?", self.channel_association_id, self.variant_id, self.profile_channel_association_id
36
36
  )
37
37
  end
38
+
39
+ def assign_from_variant(variant)
40
+ self.variant_id = variant.id
41
+ end
42
+
43
+ def assign_from_item_listing(item)
44
+ self.channel_association_id = item.id
45
+ end
46
+
47
+ def assign_from_account(account)
48
+ self.profile_channel_association_id = account.id
49
+ self.channel_id = account.channel_id
50
+ end
38
51
  end
@@ -6,4 +6,6 @@ class VariantOptionAssociation < ItemApplicationRecord
6
6
  include ::Restorable
7
7
 
8
8
  belongs_to :variant_option, foreign_key: :option_id
9
+ belongs_to :variant, foreign_key: :variant_id
10
+ belongs_to :option_type, foreign_key: :option_type_id
9
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: item_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexander
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-03 00:00:00.000000000 Z
11
+ date: 2022-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - lib/models/item_listing_variant_image.rb
79
79
  - lib/models/master_catalog.rb
80
80
  - lib/models/master_catalog_image.rb
81
+ - lib/models/option_type.rb
81
82
  - lib/models/shopee_brand.rb
82
83
  - lib/models/shopee_category.rb
83
84
  - lib/models/shopee_item_custom_field.rb
@@ -85,6 +86,8 @@ files:
85
86
  - lib/models/shopee_item_variant_custom_field.rb
86
87
  - lib/models/shopee_logistic_address.rb
87
88
  - lib/models/shopee_shipping_provider.rb
89
+ - lib/models/tokopedia_category.rb
90
+ - lib/models/tokopedia_item_variant_custom_field.rb
88
91
  - lib/models/variant.rb
89
92
  - lib/models/variant_image.rb
90
93
  - lib/models/variant_listing.rb