item_builder 0.1.46 → 0.1.50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/item_builder/modes.rb +7 -1
- data/lib/item_builder/version.rb +1 -1
- data/lib/item_builder.rb +36 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85cdb400a2a96b3ec48a7c3595dc11cd6c98bab1c22057b603697482981496d8
|
4
|
+
data.tar.gz: a6f283e3c3670a6d190846c3b0951d8ef5847e5f5e17ca39789c1d2b65cf06eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 542f97bacef6a7cab57a646d9b919bc09b025eb893e6063095d644641469610436d82f6e6176b33fcb8808c65a6a19206f5dfe94ca00b9c6030622859d26e1bd
|
7
|
+
data.tar.gz: 416d6c22f105c24ea3e943fdef89495342fc2f654ba719bed64d2612480a4b9fcff9ed53ab6c96554886578a667a6eb5992d550a7bca7cfabb925ae4786cc387
|
data/lib/item_builder/modes.rb
CHANGED
@@ -21,6 +21,7 @@ class ItemBuilder
|
|
21
21
|
attr_reader :lazada_quantity
|
22
22
|
attr_reader :zalora_reserved_stock
|
23
23
|
attr_reader :shopify_inventory_location
|
24
|
+
attr_reader :wh_id
|
24
25
|
def initialize(args)
|
25
26
|
@listing = args.fetch(:listing)
|
26
27
|
@wh_spaces = args.fetch(:wh_spaces, [])
|
@@ -35,6 +36,7 @@ class ItemBuilder
|
|
35
36
|
@lazada_quantity = args.fetch(:lazada_quantity, [])
|
36
37
|
@zalora_reserved_stock = args.fetch(:zalora_reserved_stock, [])
|
37
38
|
@shopify_inventory_location = args.fetch(:shopify_inventory_location, [])
|
39
|
+
@wh_id = args.fetch(:wh_id, [])
|
38
40
|
end
|
39
41
|
|
40
42
|
def base
|
@@ -73,7 +75,11 @@ class ItemBuilder
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def warehouse
|
76
|
-
|
78
|
+
if wh_id.present?
|
79
|
+
wh_spaces.where(warehouse_id: wh_id).where(item_variant_id: listing.variant_id).first
|
80
|
+
else
|
81
|
+
wh_spaces.select { |ws| ws.item_variant_id == listing.variant_id }.first
|
82
|
+
end
|
77
83
|
end
|
78
84
|
|
79
85
|
def variant
|
data/lib/item_builder/version.rb
CHANGED
data/lib/item_builder.rb
CHANGED
@@ -23,6 +23,8 @@ class ItemBuilder
|
|
23
23
|
attr_reader :wh_spaces
|
24
24
|
attr_reader :variants
|
25
25
|
attr_reader :variant_ids
|
26
|
+
attr_reader :wh_mapping
|
27
|
+
attr_reader :wh_id
|
26
28
|
|
27
29
|
def initialize(listing_ids, mode)
|
28
30
|
@listing_ids = listing_ids
|
@@ -41,29 +43,23 @@ class ItemBuilder
|
|
41
43
|
listings.map do |listing|
|
42
44
|
next unless listing.local_id.present?
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
.merge({lazada_quantity: lazada_quantity})
|
62
|
-
|
63
|
-
modes[mode].new(new_param).perform
|
64
|
-
else
|
65
|
-
modes[mode].new(qty_simple_params(listing)).perform
|
66
|
-
end
|
46
|
+
param =
|
47
|
+
if listing.channel_id == 18
|
48
|
+
qty_simple_params(listing)
|
49
|
+
.merge(zilingo_quantity: zilingo_quantity)
|
50
|
+
elsif listing.channel_id == 13
|
51
|
+
qty_simple_params(listing)
|
52
|
+
.merge(zalora_reserved_stock: zalora_reserved_stock)
|
53
|
+
elsif listing.channel_id == 2
|
54
|
+
qty_simple_params(listing)
|
55
|
+
.merge({shopify_inventory_location: shopify_inventory_location})
|
56
|
+
elsif listing.channel_id == 3
|
57
|
+
qty_simple_params(listing)
|
58
|
+
.merge({lazada_quantity: lazada_quantity})
|
59
|
+
else
|
60
|
+
qty_simple_params(listing)
|
61
|
+
end
|
62
|
+
modes[mode].new(param).perform
|
67
63
|
end.compact
|
68
64
|
end
|
69
65
|
|
@@ -73,7 +69,7 @@ class ItemBuilder
|
|
73
69
|
stock_allocs: stock_allocs, variant_listings: variant_listings,
|
74
70
|
bundles: bundles, item_bundle_variants: item_bundle_variants,
|
75
71
|
existing_alloc_stocks: existing_alloc_stocks,
|
76
|
-
reserved_stocks: reserved_stocks
|
72
|
+
reserved_stocks: reserved_stocks, wh_id: @wh_id
|
77
73
|
}
|
78
74
|
end
|
79
75
|
|
@@ -85,7 +81,7 @@ class ItemBuilder
|
|
85
81
|
modes[mode].new(qty_simple_params(listing)).perform
|
86
82
|
elsif listing.channel_id == 18 && mode == :active
|
87
83
|
modes[mode].new(qty_simple_params(listing)
|
88
|
-
.merge(zilingo_quantity: zilingo_quantity)
|
84
|
+
.merge(zilingo_quantity: @zilingo_quantity)
|
89
85
|
).perform
|
90
86
|
else
|
91
87
|
modes[mode].new(listing: listing).perform
|
@@ -187,7 +183,7 @@ class ItemBuilder
|
|
187
183
|
end
|
188
184
|
|
189
185
|
def reserved_params
|
190
|
-
"account_id=#{
|
186
|
+
"account_id=#{account_id}
|
191
187
|
&item_variant_ids=#{variant_ids.join(',')}"
|
192
188
|
end
|
193
189
|
|
@@ -196,4 +192,18 @@ class ItemBuilder
|
|
196
192
|
"#{order_host}?#{reserved_params}"
|
197
193
|
).body) if [3].include?(listings[0].channel_id)
|
198
194
|
end
|
195
|
+
|
196
|
+
def wh_mapping
|
197
|
+
@wh_mapping ||= WarehouseMapping.where(
|
198
|
+
profile_channel_association_id: account_id
|
199
|
+
).first
|
200
|
+
end
|
201
|
+
|
202
|
+
def account_id
|
203
|
+
account_id ||= listings[0].profile_channel_association_id
|
204
|
+
end
|
205
|
+
|
206
|
+
def wh_id
|
207
|
+
@wh_id ||= wh_mapping&.warehouse_id
|
208
|
+
end
|
199
209
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.50
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okaaryanata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|