item_builder 0.1.43 → 0.1.44

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: 49e8a0ba80c8a73c29b9d53439a55575ae6faed6f5a7d5ae19b5b8e4101e8b3f
4
- data.tar.gz: 1bf2017d6d0c2afdf9d83a60ab0f5ad4a6c3000aa9b97a57946d5c80f3ee94d1
3
+ metadata.gz: 20043fbc1916ef6f98c6429d101469353b46a0d9f8106be6ea94193a685aeb84
4
+ data.tar.gz: d4a1aefc9f150740af16fad42a5734088e3f584ce6b896a2c4b6b645fe4d629d
5
5
  SHA512:
6
- metadata.gz: 893107b4c5642f15c5d05a500afb5eb6b1e87a53a749c75d73b6efb24b0fb78b6095790b8b0f2aa4cf677f223fe5c9a965e7f59ae2e6b94c4ab7918ec8fc4197
7
- data.tar.gz: f826724734d4abe3427c06a2a9618aa2bae96e6f61a58e3adb1de3c9553629c19b05ea3911c7b44e1fe8cf7779424cb7c6166759b41e8c1287dfdf0a167a03bb
6
+ metadata.gz: 692cf4418adce24b9ff97045629804663b4043bf6bcf1305b87037f084d819b5d111a3674e79e1f4140e6aabe49d4107db13d94cebe2fe8fb4103ea785315f45
7
+ data.tar.gz: 1fc6d2ecb1425e180a7a069ca7f227fbb472664b50688be36176d5590e6ffa86d8ff4cc165eb3833df8d438fcf154f38bcab24e9a1bce199340feeaa8cb05ca9
@@ -20,7 +20,9 @@ class ItemBuilder
20
20
 
21
21
  def perform
22
22
  if channel_name == "Shopify"
23
- base.merge(to_h, shopify_inventory_location[listing.local_id])
23
+ dataSIL = shopify_inventory_location[listing.local_id]
24
+
25
+ base.merge(to_h, dataSIL) if dataSIL.present?
24
26
  else
25
27
  to_h.merge(base)
26
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
- @listing = listing
19
- @sku = listing.local_id
20
- datas[@sku] = response_process
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
- hash[:inventory_item_id] = inventory_item_id.to_i
102
- hash[:location_id] = location_id.to_i
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilder
4
- VERSION = '0.1.43'
4
+ VERSION = '0.1.44'
5
5
  end
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.43
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-08-05 00:00:00.000000000 Z
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.0.9
168
+ rubygems_version: 3.2.3
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Item builder