huginn_bigcommerce_product_agent 1.3.5 → 1.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6700d6660d8c8da8a1d5609089a551b9817b3f0a85ade4dc1c3acfea47f8e42
|
4
|
+
data.tar.gz: ea53fad929271123c7d11408dcc85d9c320bc29c11915de2b1057279e0efbc8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 392ffc7923f825d4e04545d29b3eb9cbcdb75022b8a9d62f91f6898115422ef0b8afe0e44bdcfb7f9347e802b325c8a4300f39c1c244831230aa12bcda5f05e0
|
7
|
+
data.tar.gz: c083cc8d1f3a0e8c487ee56527f96fe37c4e4ca295b400b9f931f3471e6c7e25d52076c40a2309795db4b40bb3d4c50d1e2a327eb73bdd5b8054b0b5f968c0ec
|
data/lib/client/product.rb
CHANGED
@@ -26,8 +26,8 @@ module BigcommerceProductAgent
|
|
26
26
|
|
27
27
|
def upsert(payload, params={})
|
28
28
|
begin
|
29
|
-
if payload[
|
30
|
-
return update(payload[
|
29
|
+
if payload[:id]
|
30
|
+
return update(payload[:id], payload, params)
|
31
31
|
else
|
32
32
|
return create(payload, params)
|
33
33
|
end
|
@@ -103,15 +103,6 @@ module Agents
|
|
103
103
|
def handle_variants(event)
|
104
104
|
product = event.payload
|
105
105
|
|
106
|
-
wrapper_skus = {
|
107
|
-
physical: get_mapper(:ProductMapper).get_wrapper_sku_physical(product),
|
108
|
-
digital: get_mapper(:ProductMapper).get_wrapper_sku_digital(product),
|
109
|
-
}
|
110
|
-
bc_products = @product.get_by_skus(
|
111
|
-
wrapper_skus.map {|k,v| v},
|
112
|
-
%w[custom_fields options]
|
113
|
-
)
|
114
|
-
|
115
106
|
split = get_mapper(:ProductMapper).split_digital_and_physical(
|
116
107
|
product,
|
117
108
|
interpolated['custom_fields_map']
|
@@ -119,6 +110,15 @@ module Agents
|
|
119
110
|
physical = split[:physical]
|
120
111
|
digital = split[:digital]
|
121
112
|
|
113
|
+
wrapper_skus = {
|
114
|
+
physical: get_mapper(:ProductMapper).get_wrapper_sku(physical),
|
115
|
+
digital: get_mapper(:ProductMapper).get_wrapper_sku(digital),
|
116
|
+
}
|
117
|
+
|
118
|
+
bc_products = @product.get_by_skus(
|
119
|
+
wrapper_skus.map {|k,v| v},
|
120
|
+
%w[custom_fields options]
|
121
|
+
)
|
122
122
|
# upsert wrapper products
|
123
123
|
split.each do |type, product|
|
124
124
|
is_digital = type == :digital ? true : false
|
@@ -25,7 +25,7 @@ module BigcommerceProductAgent
|
|
25
25
|
|
26
26
|
result = {
|
27
27
|
name: name,
|
28
|
-
sku:
|
28
|
+
sku: product ? product['sku'] : default_sku,
|
29
29
|
is_default: product['isDefault'],
|
30
30
|
type: product['isDigital'] == true || is_digital ? 'digital' : 'physical',
|
31
31
|
description: product['description'],
|
@@ -47,21 +47,16 @@ module BigcommerceProductAgent
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.get_wrapper_sku(product)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
def self.get_wrapper_sku_physical(product)
|
54
|
-
self.get_wrapper_sku(product)
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.get_wrapper_sku_digital(product)
|
58
|
-
"#{self.get_wrapper_sku_physical(product)}-DIGITAL"
|
50
|
+
if product
|
51
|
+
"#{product['sku']}-W"
|
52
|
+
end
|
59
53
|
end
|
60
54
|
|
61
55
|
def self.payload(sku, product, product_id = nil, additional_data = {}, is_digital = false)
|
62
56
|
variant = self.get_variant_by_sku(sku, product)
|
63
57
|
payload = self.map(product, variant, additional_data, is_digital, sku)
|
64
|
-
payload[
|
58
|
+
payload[:id] = product_id unless product_id.nil?
|
59
|
+
payload[:sku] = self.get_wrapper_sku(product)
|
65
60
|
|
66
61
|
return payload
|
67
62
|
end
|
@@ -106,6 +101,7 @@ module BigcommerceProductAgent
|
|
106
101
|
if digitals.length > 0
|
107
102
|
clone = Marshal.load(Marshal.dump(product))
|
108
103
|
clone['model'] = digitals
|
104
|
+
clone['sku'] = clone['model'].select {|m| m['isDefault'] = true}.first['sku']
|
109
105
|
self.merge_additional_properties(clone, field_map)
|
110
106
|
result[:digital] = clone
|
111
107
|
end
|
@@ -115,6 +111,7 @@ module BigcommerceProductAgent
|
|
115
111
|
if physicals.length > 0
|
116
112
|
clone = Marshal.load(Marshal.dump(product))
|
117
113
|
clone['model'] = physicals
|
114
|
+
clone['sku'] = clone['model'].select {|m| m['isDefault'] = true}.first['sku']
|
118
115
|
self.merge_additional_properties(clone, field_map)
|
119
116
|
result[:physical] = clone
|
120
117
|
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: 1.
|
4
|
+
version: 1.4.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-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|