item_builder 0.1.40 → 0.1.44
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/get_quantity_service.rb +6 -3
- data/lib/item_builder/modes/quantity_service.rb +3 -2
- data/lib/item_builder/shopify_quantity_service.rb +16 -7
- data/lib/item_builder/version.rb +1 -1
- data/lib/item_builder/zalora_quantity_service.rb +2 -0
- data/lib/item_builder.rb +6 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20043fbc1916ef6f98c6429d101469353b46a0d9f8106be6ea94193a685aeb84
|
4
|
+
data.tar.gz: d4a1aefc9f150740af16fad42a5734088e3f584ce6b896a2c4b6b645fe4d629d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 692cf4418adce24b9ff97045629804663b4043bf6bcf1305b87037f084d819b5d111a3674e79e1f4140e6aabe49d4107db13d94cebe2fe8fb4103ea785315f45
|
7
|
+
data.tar.gz: 1fc6d2ecb1425e180a7a069ca7f227fbb472664b50688be36176d5590e6ffa86d8ff4cc165eb3833df8d438fcf154f38bcab24e9a1bce199340feeaa8cb05ca9
|
@@ -122,9 +122,12 @@ class ItemBuilder
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def params(allocated_stock)
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
{
|
126
|
+
channel_id: allocated_stock.variant_listing.channel_id,
|
127
|
+
item_variant_id: allocated_stock.variant_listing.variant_id,
|
128
|
+
start_at: allocated_stock.start_at.to_date.beginning_of_day,
|
129
|
+
end_at: allocated_stock.end_at.to_date.end_of_day
|
130
|
+
}.to_query
|
128
131
|
end
|
129
132
|
|
130
133
|
# one_alloc_rsvd_stock fungsi untuk mendapatkan satu
|
@@ -13,7 +13,6 @@ class ItemBuilder
|
|
13
13
|
include Modes
|
14
14
|
|
15
15
|
QUANTITY_CHANNEL = {}.tap do |hash|
|
16
|
-
hash[3] = :Lazada
|
17
16
|
hash[2] = :Shopify
|
18
17
|
hash[13] = :Zalora
|
19
18
|
hash[18] = :Zilingo
|
@@ -21,7 +20,9 @@ class ItemBuilder
|
|
21
20
|
|
22
21
|
def perform
|
23
22
|
if channel_name == "Shopify"
|
24
|
-
|
23
|
+
dataSIL = shopify_inventory_location[listing.local_id]
|
24
|
+
|
25
|
+
base.merge(to_h, dataSIL) if dataSIL.present?
|
25
26
|
else
|
26
27
|
to_h.merge(base)
|
27
28
|
end
|
@@ -13,11 +13,15 @@ class ItemBuilder
|
|
13
13
|
|
14
14
|
def perform
|
15
15
|
datas = {}
|
16
|
-
|
17
16
|
@listings.each do |listing|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
if listing.local_id.present?
|
18
|
+
@listing = listing
|
19
|
+
@sku = listing.local_id
|
20
|
+
resp = response_process
|
21
|
+
next if resp[:inventory_item_id].nil? || resp[:inventory_item_id] == 0
|
22
|
+
|
23
|
+
datas[@sku] = resp
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
# update variant real_local_id database icava
|
@@ -98,8 +102,12 @@ class ItemBuilder
|
|
98
102
|
def response_process
|
99
103
|
hash = Hash.new
|
100
104
|
|
101
|
-
|
102
|
-
|
105
|
+
begin
|
106
|
+
hash[:inventory_item_id] = inventory_item_id.to_i
|
107
|
+
hash[:location_id] = location_id.to_i
|
108
|
+
rescue
|
109
|
+
hash
|
110
|
+
end
|
103
111
|
|
104
112
|
hash
|
105
113
|
end
|
@@ -107,8 +115,9 @@ class ItemBuilder
|
|
107
115
|
def rest_client(params, rescued_codes = 200)
|
108
116
|
RestClient::Request.execute(params.merge(timeout: 3)) do |response|
|
109
117
|
code = response.code
|
118
|
+
resp = response.body.to_str
|
110
119
|
unless Array.wrap(rescued_codes).include?(code)
|
111
|
-
raise "Response Code is #{code}"
|
120
|
+
raise "Response Code is #{code}" unless resp.include?('Response code = 404')
|
112
121
|
end
|
113
122
|
|
114
123
|
response
|
data/lib/item_builder/version.rb
CHANGED
@@ -47,6 +47,8 @@ class ItemBuilder
|
|
47
47
|
raise "Response Code is #{resp.dig('response_code')}"
|
48
48
|
elsif resp.dig('ErrorResponse', 'Head', 'ErrorMessage') == 'E009: Access Denied'
|
49
49
|
return nil
|
50
|
+
elsif resp.dig('ErrorResponse').present?
|
51
|
+
return nil
|
50
52
|
end
|
51
53
|
|
52
54
|
success_handle(resp)
|
data/lib/item_builder.rb
CHANGED
@@ -38,6 +38,8 @@ class ItemBuilder
|
|
38
38
|
|
39
39
|
def quantity_simple_mode
|
40
40
|
listings.map do |listing|
|
41
|
+
next unless listing.local_id.present?
|
42
|
+
|
41
43
|
if listing.channel_id == 18
|
42
44
|
new_param = qty_simple_params(listing)
|
43
45
|
.merge(zilingo_quantity: zilingo_quantity)
|
@@ -56,7 +58,7 @@ class ItemBuilder
|
|
56
58
|
else
|
57
59
|
modes[mode].new(qty_simple_params(listing)).perform
|
58
60
|
end
|
59
|
-
end
|
61
|
+
end.compact
|
60
62
|
end
|
61
63
|
|
62
64
|
def qty_simple_params(listing)
|
@@ -71,6 +73,8 @@ class ItemBuilder
|
|
71
73
|
|
72
74
|
def default
|
73
75
|
listings.map do |listing|
|
76
|
+
next unless listing.local_id.present?
|
77
|
+
|
74
78
|
if listing.channel_id == 2 && mode == :active
|
75
79
|
modes[mode].new(qty_simple_params(listing)).perform
|
76
80
|
elsif listing.channel_id == 18 && mode == :active
|
@@ -130,7 +134,7 @@ class ItemBuilder
|
|
130
134
|
end
|
131
135
|
|
132
136
|
def listings
|
133
|
-
@listings ||= VariantListing.where(id: listing_ids)
|
137
|
+
@listings ||= VariantListing.joins(:variant).where(id: listing_ids)
|
134
138
|
end
|
135
139
|
|
136
140
|
def skus
|
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.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okaaryanata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
|
-
rubygems_version: 3.
|
168
|
+
rubygems_version: 3.2.3
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: Item builder
|