huginn_bigcommerce_product_agent 1.6.0 → 1.10.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6e30baa91c2309f76692a19fcba067b76749dbf0a43a608c01c8b67e77e2151
|
4
|
+
data.tar.gz: c234d8636bf50a12cf170494d7a479cc171482b54c724307c317e059233e723f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d787746d57c3eb0a1643da3b586c4e2ad31860912409b0b17e7e44cf5f23d986f5c834231bd54eb2c18249639e02fa0860858e6c609820d1c6e84172c95e078
|
7
|
+
data.tar.gz: 2b045dcce2130e261a4fbf3912efe019d87cfb169788d922315a4f8fd016f4addc82eb238be1964cdb7c8bb5ae80342aae82f46d75b7c3263b047eef713065c0
|
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])
|
@@ -29,7 +29,8 @@ module Agents
|
|
29
29
|
'meta_fields_map' => {},
|
30
30
|
'meta_fields_namespace' => '',
|
31
31
|
'mode' => modes[0],
|
32
|
-
'not_purchasable_format_list' => []
|
32
|
+
'not_purchasable_format_list' => [],
|
33
|
+
'should_disambiguate' => false
|
33
34
|
}
|
34
35
|
end
|
35
36
|
|
@@ -67,6 +68,11 @@ module Agents
|
|
67
68
|
if options['not_purchasable_format_list'].present? && !options['not_purchasable_format_list'].is_a?(Array)
|
68
69
|
errors.add(:base, 'not_purchasable_format_list must be an Array')
|
69
70
|
end
|
71
|
+
|
72
|
+
if options.has_key?('should_disambiguate') && boolify(options['should_disambiguate']).nil?
|
73
|
+
errors.add(:base, 'when provided, `should_disambiguate` must be either true or false')
|
74
|
+
end
|
75
|
+
|
70
76
|
end
|
71
77
|
|
72
78
|
def working?
|
@@ -143,6 +149,17 @@ module Agents
|
|
143
149
|
product['name'] = "#{product['name']} (Digital)"
|
144
150
|
end
|
145
151
|
|
152
|
+
# Ignatius Press -- some products have the same name and must be disambiguated.
|
153
|
+
# ...by adding a list of the product types (hardback, paperback, etc.) to their names
|
154
|
+
if boolify(options['should_disambiguate'])
|
155
|
+
product['page_title'] = product['name']
|
156
|
+
product['name'] += " |~ " + product['model'].map { |m|
|
157
|
+
m['additionalProperty'].find { |p|
|
158
|
+
p['propertyID'] == 'option'
|
159
|
+
}['value']
|
160
|
+
}.join(", ")
|
161
|
+
end
|
162
|
+
|
146
163
|
wrapper_sku = wrapper_skus[type]
|
147
164
|
bc_product = bc_products[wrapper_sku]
|
148
165
|
variant_option_name = get_mapper(:OptionMapper).variant_option_name
|
@@ -410,7 +427,9 @@ module Agents
|
|
410
427
|
end
|
411
428
|
|
412
429
|
delete_fields.each do |field|
|
413
|
-
|
430
|
+
if field[:resource_id] && field[:id]
|
431
|
+
@meta_field.delete(field[:resource_id], field[:id])
|
432
|
+
end
|
414
433
|
end
|
415
434
|
|
416
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
|
|
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.10.1
|
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-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|