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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce068992ff7f5e99b7f7656d246d104b60bc1a12c836c84d3c0156e0fadc9c67
4
- data.tar.gz: eadfb8e593e0e44a806f6cbcffbbe8f0b6d364f73215ffd2565c91be80c6b885
3
+ metadata.gz: e2bb363c3f6595b5bd3c82cedfd4d4f6365688019ce85bc553773b1cc1143818
4
+ data.tar.gz: da6ed2760e1f4089172003b8bed69f8200741308ce87ca1f54f8c3757c655661
5
5
  SHA512:
6
- metadata.gz: 3b8cbc08bc80f5cf0e811fa61874545ce54cb2ee4af113cc3f43fc102959690b32d8e7ce8ec027e29d836c60db78d4d7c50aca414ca24149f66dae1756879032
7
- data.tar.gz: a1ee6941129e2df489daa52077f5bd9daa57943ebc6328880a8cbf7b8747a3c59ebdd16634f9ed8398f48e2490ffee278c0360d472b8989c45c6fa629d27da52
6
+ metadata.gz: f680c9c58911f44e6bd0e4c559cba9923bd268d66364bb7235b6b2a3ef4c55deb47bbde896b447b70dff1dd54ef800765a35fcf73587cbce36b1cc9877eb5937
7
+ data.tar.gz: 6eebe42237c789f9ff5691ec423edda3b1168fe6e78243e0716b2be760f38631a9722d63860dac12086a81b17c3e922fc56b0c80edf1475f761c3854197b994e
@@ -42,7 +42,11 @@ module BigcommerceProductAgent
42
42
  end
43
43
 
44
44
  def delete(product_id, meta_field_id)
45
- client.delete(uri(product_id: product_id, meta_field_id: meta_field_id))
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
@@ -4,8 +4,12 @@ module BigcommerceProductAgent
4
4
  @uri_base = 'catalog/products/:product_id'
5
5
 
6
6
  def update(id, payload, params={})
7
- response = client.put(uri(product_id: id), payload.to_json) do |request|
8
- request.params.update(params) if params
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
- response = client.post(uri, payload.to_json) do |request|
21
- request.params.update(params) if params
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
- begin
29
- if payload[:id]
30
- return update(payload[:id], payload, params)
31
- else
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
- response = client.post(uri(product_id: product_id), option.to_json)
37
- return response.body['data']
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
@@ -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
- rescue Faraday::Error::ClientError => e
19
- puts e.inspect
20
- raise e
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
- @meta_field.delete(field[:resource_id], field[:id])
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.7.0
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-07-07 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler