huginn_bigcommerce_product_agent 1.7.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/client/meta_field.rb +5 -1
- data/lib/client/product.rb +16 -13
- data/lib/client/product_option.rb +6 -2
- data/lib/client/variant.rb +3 -4
- data/lib/huginn_bigcommerce_product_agent/bigcommerce_product_agent.rb +4 -1
- data/lib/mapper/product_mapper.rb +1 -0
- data/lib/mapper/variant_mapper.rb +1 -1
- 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: e2bb363c3f6595b5bd3c82cedfd4d4f6365688019ce85bc553773b1cc1143818
|
4
|
+
data.tar.gz: da6ed2760e1f4089172003b8bed69f8200741308ce87ca1f54f8c3757c655661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f680c9c58911f44e6bd0e4c559cba9923bd268d66364bb7235b6b2a3ef4c55deb47bbde896b447b70dff1dd54ef800765a35fcf73587cbce36b1cc9877eb5937
|
7
|
+
data.tar.gz: 6eebe42237c789f9ff5691ec423edda3b1168fe6e78243e0716b2be760f38631a9722d63860dac12086a81b17c3e922fc56b0c80edf1475f761c3854197b994e
|
data/lib/client/meta_field.rb
CHANGED
@@ -42,7 +42,11 @@ module BigcommerceProductAgent
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def delete(product_id, meta_field_id)
|
45
|
-
|
45
|
+
begin
|
46
|
+
client.delete(uri(product_id: product_id, meta_field_id: meta_field_id))
|
47
|
+
rescue Faraday::Error::ClientError => e
|
48
|
+
raise e, "\n#{e.message}\nFailed to delete meta_field with id = #{meta_field_id}\nfor product with id = #{product_id}\n", e.backtrace
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
data/lib/client/product.rb
CHANGED
@@ -4,8 +4,12 @@ module BigcommerceProductAgent
|
|
4
4
|
@uri_base = 'catalog/products/:product_id'
|
5
5
|
|
6
6
|
def update(id, payload, params={})
|
7
|
-
|
8
|
-
|
7
|
+
begin
|
8
|
+
response = client.put(uri(product_id: id), payload.to_json) do |request|
|
9
|
+
request.params.update(params) if params
|
10
|
+
end
|
11
|
+
rescue Faraday::Error::ClientError => e
|
12
|
+
raise e, "\n#{e.message}\nFailed to update product with payload = #{payload.to_json}\n", e.backtrace
|
9
13
|
end
|
10
14
|
|
11
15
|
return response.body['data']
|
@@ -17,23 +21,22 @@ module BigcommerceProductAgent
|
|
17
21
|
end
|
18
22
|
|
19
23
|
def create(payload, params={})
|
20
|
-
|
21
|
-
|
24
|
+
begin
|
25
|
+
response = client.post(uri, payload.to_json) do |request|
|
26
|
+
request.params.update(params) if params
|
27
|
+
end
|
28
|
+
rescue Faraday::Error::ClientError => e
|
29
|
+
raise e, "\n#{e.message}\nFailed to create product with payload = #{payload.to_json}\n", e.backtrace
|
22
30
|
end
|
23
31
|
|
24
32
|
return response.body['data']
|
25
33
|
end
|
26
34
|
|
27
35
|
def upsert(payload, params={})
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
return create(payload, params)
|
33
|
-
end
|
34
|
-
rescue Faraday::Error::ClientError => e
|
35
|
-
puts e.inspect
|
36
|
-
raise e
|
36
|
+
if payload[:id]
|
37
|
+
return update(payload[:id], payload, params)
|
38
|
+
else
|
39
|
+
return create(payload, params)
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
@@ -33,8 +33,12 @@ module BigcommerceProductAgent
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def create(product_id, option)
|
36
|
-
|
37
|
-
|
36
|
+
begin
|
37
|
+
response = client.post(uri(product_id: product_id), option.to_json)
|
38
|
+
return response.body['data']
|
39
|
+
rescue Faraday::Error::ClientError => e
|
40
|
+
raise e, "\n#{e.message}\nFailed to upsert product_option = #{option.to_json}\nfor product with id = #{product_id}\n", e.backtrace
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
data/lib/client/variant.rb
CHANGED
@@ -15,10 +15,9 @@ module BigcommerceProductAgent
|
|
15
15
|
begin
|
16
16
|
response = client.put(uri, payload.to_json)
|
17
17
|
return response.body['data']
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
18
|
+
rescue Faraday::Error::ClientError => e
|
19
|
+
raise e, "\n#{e.message}\nFailed to upsert variant with payload = #{payload.to_json}\n", e.backtrace
|
20
|
+
end
|
22
21
|
end
|
23
22
|
|
24
23
|
def get_by_skus(skus, include = %w[custom_fields modifiers])
|
@@ -152,6 +152,7 @@ module Agents
|
|
152
152
|
# Ignatius Press -- some products have the same name and must be disambiguated.
|
153
153
|
# ...by adding a list of the product types (hardback, paperback, etc.) to their names
|
154
154
|
if boolify(options['should_disambiguate'])
|
155
|
+
product['page_title'] = product['name']
|
155
156
|
product['name'] += " |~ " + product['model'].map { |m|
|
156
157
|
m['additionalProperty'].find { |p|
|
157
158
|
p['propertyID'] == 'option'
|
@@ -426,7 +427,9 @@ module Agents
|
|
426
427
|
end
|
427
428
|
|
428
429
|
delete_fields.each do |field|
|
429
|
-
|
430
|
+
if field[:resource_id] && field[:id]
|
431
|
+
@meta_field.delete(field[:resource_id], field[:id])
|
432
|
+
end
|
430
433
|
end
|
431
434
|
|
432
435
|
meta_fields
|
@@ -46,6 +46,7 @@ module BigcommerceProductAgent
|
|
46
46
|
preorder_release_date: product['releaseDate'] && product['releaseDate'].to_datetime ? product['releaseDate'].to_datetime.strftime("%FT%T%:z") : nil,
|
47
47
|
preorder_message: self.get_availability(product) == 'preorder' ? product['availability'] : '',
|
48
48
|
is_preorder_only: self.get_availability(product) == 'preorder' ? true : false,
|
49
|
+
page_title: product['page_title'] || '',
|
49
50
|
}
|
50
51
|
result[:upc] = product['gtin12'] if product['gtin12']
|
51
52
|
|
@@ -9,7 +9,7 @@ module BigcommerceProductAgent
|
|
9
9
|
price: variant['offers'] && variant['offers'][0] ? variant['offers'][0]['price'] : '0',
|
10
10
|
cost_price: nil,
|
11
11
|
sale_price: nil,
|
12
|
-
retail_price: nil,
|
12
|
+
retail_price: variant['offers'] && variant['offers'][0] ? variant['offers'][0]['price'] : nil,
|
13
13
|
weight: variant['weight'] ? variant['weight']['value'] : '0',
|
14
14
|
width: variant['width'] ? variant['width']['value'] : '0',
|
15
15
|
depth: variant['depth'] ? variant['depth']['value'] : '0',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_bigcommerce_product_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Spizziri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|