item_builder 0.1.47 → 0.1.51
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/active_service.rb +0 -1
- data/lib/item_builder/modes/simple_service.rb +0 -1
- data/lib/item_builder/modes.rb +1 -3
- data/lib/item_builder/version.rb +1 -1
- data/lib/item_builder.rb +22 -43
- 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: 69fd543a88549b7f8e3cd3d9314b9373971251c77a7d6c18f40afd48eeb017e2
|
4
|
+
data.tar.gz: 691182911781462cc4a0261892404502baddcb9cb2d74e9ef7d491563db17014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c17a80b92159a623786861ed21c8a33ca6c3ab58c32686c241879406f964789dc0395ade3700d38da293f08a0d350316469e28e99e6d0a06fcdb53d5ee1eda1
|
7
|
+
data.tar.gz: 02ea415d4ce6a832a1c832d2a67b7bcbde7c0c73c1fafa739472d18db8b3362ced51c7801209ef7a1628f73342d28e6da5388b52ffbbf11c2157b59284b5a30c
|
@@ -28,7 +28,6 @@ class ItemBuilder
|
|
28
28
|
stock_allocs: stock_allocs, variant_listings: variant_listings,
|
29
29
|
bundles: bundles, item_bundle_variants: item_bundle_variants,
|
30
30
|
existing_alloc_stocks: existing_alloc_stocks,
|
31
|
-
reserved_stocks: reserved_stocks,
|
32
31
|
zilingo_quantity: zilingo_quantity,
|
33
32
|
zalora_reserved_stock: zalora_reserved_stock
|
34
33
|
).to_h
|
@@ -22,7 +22,6 @@ class ItemBuilder
|
|
22
22
|
stock_allocs: stock_allocs, variant_listings: variant_listings,
|
23
23
|
bundles: bundles, item_bundle_variants: item_bundle_variants,
|
24
24
|
existing_alloc_stocks: existing_alloc_stocks,
|
25
|
-
reserved_stocks: reserved_stocks,
|
26
25
|
zilingo_quantity: zilingo_quantity
|
27
26
|
).to_h
|
28
27
|
end
|
data/lib/item_builder/modes.rb
CHANGED
@@ -16,7 +16,6 @@ class ItemBuilder
|
|
16
16
|
attr_reader :item_bundle_variants
|
17
17
|
attr_reader :existing_alloc_stocks
|
18
18
|
attr_reader :variant_listings
|
19
|
-
attr_reader :reserved_stocks
|
20
19
|
attr_reader :zilingo_quantity
|
21
20
|
attr_reader :lazada_quantity
|
22
21
|
attr_reader :zalora_reserved_stock
|
@@ -31,7 +30,6 @@ class ItemBuilder
|
|
31
30
|
@item_bundle_variants = args.fetch(:item_bundle_variants, [])
|
32
31
|
@existing_alloc_stocks = args.fetch(:existing_alloc_stocks, [])
|
33
32
|
@variant_listings = args.fetch(:variant_listings, [])
|
34
|
-
@reserved_stocks = args.fetch(:reserved_stocks, [])
|
35
33
|
@zilingo_quantity = args.fetch(:zilingo_quantity, [])
|
36
34
|
@lazada_quantity = args.fetch(:lazada_quantity, [])
|
37
35
|
@zalora_reserved_stock = args.fetch(:zalora_reserved_stock, [])
|
@@ -76,7 +74,7 @@ class ItemBuilder
|
|
76
74
|
|
77
75
|
def warehouse
|
78
76
|
if wh_id.present?
|
79
|
-
wh_spaces.where(warehouse_id: wh_id).first
|
77
|
+
wh_spaces.where(warehouse_id: wh_id).where(item_variant_id: listing.variant_id).first
|
80
78
|
else
|
81
79
|
wh_spaces.select { |ws| ws.item_variant_id == listing.variant_id }.first
|
82
80
|
end
|
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
|
|
@@ -72,8 +68,7 @@ class ItemBuilder
|
|
72
68
|
listing: listing, wh_spaces: wh_spaces, variants: variants,
|
73
69
|
stock_allocs: stock_allocs, variant_listings: variant_listings,
|
74
70
|
bundles: bundles, item_bundle_variants: item_bundle_variants,
|
75
|
-
existing_alloc_stocks: existing_alloc_stocks,
|
76
|
-
reserved_stocks: reserved_stocks, wh_id: wh_id
|
71
|
+
existing_alloc_stocks: existing_alloc_stocks, wh_id: wh_id
|
77
72
|
}
|
78
73
|
end
|
79
74
|
|
@@ -85,7 +80,7 @@ class ItemBuilder
|
|
85
80
|
modes[mode].new(qty_simple_params(listing)).perform
|
86
81
|
elsif listing.channel_id == 18 && mode == :active
|
87
82
|
modes[mode].new(qty_simple_params(listing)
|
88
|
-
.merge(zilingo_quantity: zilingo_quantity)
|
83
|
+
.merge(zilingo_quantity: @zilingo_quantity)
|
89
84
|
).perform
|
90
85
|
else
|
91
86
|
modes[mode].new(listing: listing).perform
|
@@ -181,24 +176,8 @@ class ItemBuilder
|
|
181
176
|
}
|
182
177
|
end
|
183
178
|
|
184
|
-
def order_host
|
185
|
-
url = ENV['ORDERS_URL'] || 'orders.forstok.com'
|
186
|
-
url + '/api/v3/item_line/reserved_stock'
|
187
|
-
end
|
188
|
-
|
189
|
-
def reserved_params
|
190
|
-
"account_id=#{account_id}
|
191
|
-
&item_variant_ids=#{variant_ids.join(',')}"
|
192
|
-
end
|
193
|
-
|
194
|
-
def reserved_stocks
|
195
|
-
@reserved_stocks ||= JSON.parse(RestClient.get(
|
196
|
-
"#{order_host}?#{reserved_params}"
|
197
|
-
).body) if [3].include?(listings[0].channel_id)
|
198
|
-
end
|
199
|
-
|
200
179
|
def wh_mapping
|
201
|
-
wh_mapping ||= WarehouseMapping.where(
|
180
|
+
@wh_mapping ||= WarehouseMapping.where(
|
202
181
|
profile_channel_association_id: account_id
|
203
182
|
).first
|
204
183
|
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.51
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|