huginn_bigcommerce_product_agent 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af097d968dbd6e4c5b16bd27be4b48a685625056f23e4863e749b8e2382ee06f
4
- data.tar.gz: e441b45253fde8999a4480bf2f9dbd419cd228d21c3e05dad47d45d8f4dbbe08
3
+ metadata.gz: 89cfc257bee7acf8c2a48655ce32e2e4bd9aa91f09a0e17fb19a54224fc764f4
4
+ data.tar.gz: ea56efe75b854b60a42bcb6f26b7a105f0910ec7e629dc08e7d2c927d7a91900
5
5
  SHA512:
6
- metadata.gz: c8fc484fc9c277ce1deb6b1ec3baed84f74a607e12b2667eb4fcfc5c160511623364d9c8d962f3367f713fd1da6b430da128160a45a5f575badfd5efb01f6af6
7
- data.tar.gz: 8546a2251a5a077eb00ad8cbbf9aa605b121ce251565121f5a36bdffa65099f1e67e26f217a7f64b0ada326410cfa271b459945fdadc02ac5f0e68cc8b46a1c5
6
+ metadata.gz: 266955d42682aaf2e8f92f5685ac915767a75070b7cdb6957d7e6b0a23e11ed7854070b04a7218bea809b7269702a2f51fb33d4813e355debcc435684adcb5b6
7
+ data.tar.gz: 19fef7e12d26c6ac94945204e375d3c86bc016eae304f435851e222ef026e4eb1066159b4601b9d92ee546cb9f21803ee41cb809c0d958207408e5fbe5af7e8e
@@ -37,10 +37,10 @@ module BigcommerceProductAgent
37
37
  e.response[:status],
38
38
  'update product',
39
39
  'Failed to update product batch',
40
+ payload.map { |p|
41
+ { id: p["id"], sku: p[:sku] }
42
+ },
40
43
  {
41
- product_identifiers: payload.map { |p|
42
- { id: p[:id], sku: p[:sku] }
43
- },
44
44
  errors: JSON.parse(e.response[:body])['errors'],
45
45
  },
46
46
  e
@@ -94,7 +94,7 @@ module BigcommerceProductAgent
94
94
  end
95
95
 
96
96
  # When using sku:in you must specify the fields you want returned.
97
- def get_by_skus(skus, include = %w[custom_fields modifiers], include_fields = %w[sku])
97
+ def get_by_skus(skus, include = %w[custom_fields modifiers], include_fields = %w[sku categories])
98
98
  products = []
99
99
  skus.each do |sku|
100
100
  begin
@@ -115,7 +115,8 @@ module BigcommerceProductAgent
115
115
  {
116
116
  related_skus: skus,
117
117
  errors: JSON.parse(e.response[:body])['errors'],
118
- }
118
+ },
119
+ e
119
120
  )
120
121
  end
121
122
  end
@@ -330,7 +330,7 @@ module Agents
330
330
  'upsert_products',
331
331
  e.message,
332
332
  nil,
333
- { sku: product_data.map { |p| p['sku'] } },
333
+ { sku: product_data.map { |p| p[:sku] } },
334
334
  e
335
335
  ))
336
336
  end
@@ -342,11 +342,20 @@ module Agents
342
342
  bc_payload = nil
343
343
 
344
344
  begin
345
+ # if track inventory on the agent is true set track inventory to product level track inventory
345
346
  track_inventory = boolify(options['track_inventory']).nil? ? true : boolify(options['track_inventory'])
347
+ if (track_inventory)
348
+ track_inventory = boolify(raw_product['trackInventory'])
349
+ end
346
350
  bc_payload = get_mapper(:ProductMapper).map_payload(raw_product, additional_data, track_inventory)
347
351
  bc_payload['id'] = bc_product['id'] unless bc_product.nil? || bc_product['id'].nil?
348
352
  # NOTE: bc_product will be nil when this is called with `to_create` products
349
353
 
354
+ if bc_payload[:categories].empty?
355
+ # If categories is empty keep existing categories because categories should never be empty
356
+ bc_payload[:categories] = bc_product['categories'] unless bc_product.nil? || bc_product['categories'].nil?
357
+ end
358
+
350
359
  if bc_payload[:type] == 'digital'
351
360
  bc_payload[:name].concat(' (Digital)')
352
361
  end
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: 2.1.0
4
+ version: 2.2.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: 2021-05-25 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler