item_builder 0.1.48 → 0.1.52

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7466c11e90ea16a599fe729ade0dd42c06a237505f4f167cc6b1d067da23d79
4
- data.tar.gz: 0414a129507a7e55a1fa5ffab08f29b70e10292c856f5c48c4dcfadf4def70f4
3
+ metadata.gz: 06f0ac99623b592c04907d6109f8bc31f760dbda87384366c8c41cb0d3819ab0
4
+ data.tar.gz: e8705bd03dabd76ced2ee13ca0626f631e8015c2a31fffc8bdaa9e214a6f2cea
5
5
  SHA512:
6
- metadata.gz: bc0f76ff7d8572691d6a65d5d1f3016af21f627cbfcd1beabab235e004c3cb53330eac0b7f93dc802ac19ef5cf215a231be240676fdef5545f774b5ba1989f8a
7
- data.tar.gz: 9cdaf496fa275f4a759163a4615e6fab983ffac7587129a38fe23bf9b23173f652c8e2ee0a845bae3824f4c844bbf29d874c6bface83134cd11eb536db37f351
6
+ metadata.gz: 952521e982b28396d459ca0302edcf3bfa7c5ffe63fe1458ab7d33a0d37be5876154a5f1c12496aa4ef000d0e331f4d85ac47ebd25e8aa6b4a88f444509b1dff
7
+ data.tar.gz: ac13a66b436d5a307c29adc0c1a26de4c218de3bf2caf84c3eeb24080027867424c5cea159bb33e0eade84ec7c617e518dda935ab9a17f7c1a45f2b5453318fc
@@ -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
@@ -6,7 +6,7 @@ class ItemBuilder
6
6
  module Quantity
7
7
  class LazadaService < Base
8
8
  def perform
9
- available_quantity + local_qty
9
+ available_quantity
10
10
  end
11
11
  end
12
12
  end
@@ -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
@@ -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, [])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilder
4
- VERSION = '0.1.48'
4
+ VERSION = '0.1.52'
5
5
  end
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
- if listing.channel_id == 18
45
- new_param = qty_simple_params(listing)
46
- .merge(zilingo_quantity: zilingo_quantity)
47
-
48
- modes[mode].new(new_param).perform
49
- elsif listing.channel_id == 13
50
- new_param = qty_simple_params(listing)
51
- .merge(zalora_reserved_stock: zalora_reserved_stock)
52
-
53
- modes[mode].new(new_param).perform
54
- elsif listing.channel_id == 2
55
- new_param = qty_simple_params(listing)
56
- .merge({shopify_inventory_location: shopify_inventory_location})
57
-
58
- modes[mode].new(new_param).perform
59
- elsif listing.channel_id == 3
60
- new_param = qty_simple_params(listing)
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.48
4
+ version: 0.1.52
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-20 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler