huginn_bigcommerce_product_agent 1.3.0 → 1.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 911e20cea1ee097a95874f55f2366599eaed196c55e8da885e4c4273fc99baa2
|
4
|
+
data.tar.gz: f9d92d1e656157743a633d32eb6ae97ebc7dc942e2d1ade910613a6775df77b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b04f1cdb14008d9ab24cf33aef05f330804cb3d8f95ae4726e228f3ced6882759b987321c6cea4c24f4802592aeec284c8cb7439e3352b7469d8496fdfe0942
|
7
|
+
data.tar.gz: dc30b25ad1a9c020a47f8057362941da29b51f29bc0df6cc3e9c10ca456b92242ae5a2436b1554e2f1fc36a7941b0ddfa6852b0c5fc9a14ad0f4bff6ae42f4b1
|
@@ -112,7 +112,10 @@ module Agents
|
|
112
112
|
%w[custom_fields options]
|
113
113
|
)
|
114
114
|
|
115
|
-
split = get_mapper(:ProductMapper).split_digital_and_physical(
|
115
|
+
split = get_mapper(:ProductMapper).split_digital_and_physical(
|
116
|
+
product,
|
117
|
+
interpolated['custom_fields_map']
|
118
|
+
)
|
116
119
|
physical = split[:physical]
|
117
120
|
digital = split[:digital]
|
118
121
|
|
@@ -84,7 +84,7 @@ module BigcommerceProductAgent
|
|
84
84
|
product['model'].any? {|m| m['isDigital'] != true}
|
85
85
|
end
|
86
86
|
|
87
|
-
def self.split_digital_and_physical(product)
|
87
|
+
def self.split_digital_and_physical(product, field_map)
|
88
88
|
result = {}
|
89
89
|
|
90
90
|
digitals = product['model'].select {|m| m['isDigital'] == true}
|
@@ -92,6 +92,7 @@ module BigcommerceProductAgent
|
|
92
92
|
if digitals.length > 0
|
93
93
|
clone = Marshal.load(Marshal.dump(product))
|
94
94
|
clone['model'] = digitals
|
95
|
+
self.merge_additional_properties(clone, field_map)
|
95
96
|
result[:digital] = clone
|
96
97
|
end
|
97
98
|
|
@@ -100,6 +101,7 @@ module BigcommerceProductAgent
|
|
100
101
|
if physicals.length > 0
|
101
102
|
clone = Marshal.load(Marshal.dump(product))
|
102
103
|
clone['model'] = physicals
|
104
|
+
self.merge_additional_properties(clone, field_map)
|
103
105
|
result[:physical] = clone
|
104
106
|
end
|
105
107
|
|
@@ -158,6 +160,17 @@ module BigcommerceProductAgent
|
|
158
160
|
product['model'].select {|m| m['sku'] == sku}.first
|
159
161
|
end
|
160
162
|
|
163
|
+
def self.merge_additional_properties(clone, field_map)
|
164
|
+
defaultVariant = clone['model'].select { |v| v['isDefault'] }.first
|
165
|
+
if defaultVariant['isDefault'] && defaultVariant['additionalProperty']
|
166
|
+
unless field_map.nil? || field_map['additionalProperty'].nil?
|
167
|
+
field_map['additionalProperty'].each do |field, key|
|
168
|
+
prop = defaultVariant['additionalProperty'].select { |prop| prop['propertyID'] == field[key] }.first
|
169
|
+
clone['additionalProperty'].push(prop) unless prop.nil?
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
161
174
|
end
|
162
175
|
end
|
163
176
|
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.3.
|
4
|
+
version: 1.3.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-04-
|
11
|
+
date: 2020-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|