huginn_bigcommerce_product_agent 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mapper/product_mapper.rb +34 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35c321f72aa2a5961ef5b305d1222e910a8d4432f8b758051300169c01fd5882
|
4
|
+
data.tar.gz: 9653eab8c17015e8bf9c9d1604ac86416f9497fcbe9698de7d3dfce213dd58c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40ddd8f7fda0c0d1cb792d4ad4a8c30c957c0e5e3b74c05b72d152b9c3a346cc8f1ba90def9fa9e95ad8eb9ca52d33f47b0d9b562ccd0e78e4155a9a8bf28e67
|
7
|
+
data.tar.gz: 4fa44c38eec2c696bacd090d33fc761b689d9839cae34596b61cb5ec1242d2bdd65b3ab36f8a8e0b970ade13c3b3539894701440a861fc948e2f26f9ee807876
|
@@ -19,6 +19,9 @@ module BigcommerceProductAgent
|
|
19
19
|
"width" => default_variant['width'],
|
20
20
|
"depth" => default_variant['depth'],
|
21
21
|
"height" => default_variant['height'],
|
22
|
+
"releaseDate" => default_variant['releaseDate'],
|
23
|
+
"datePublished" => default_variant['datePublished'],
|
24
|
+
"availability" => self.get_availability_offer(product, default_variant),
|
22
25
|
}.merge(product)
|
23
26
|
end
|
24
27
|
end
|
@@ -31,7 +34,7 @@ module BigcommerceProductAgent
|
|
31
34
|
description: product['description'] || '',
|
32
35
|
price: product['offers'] && product['offers'][0] ? product['offers'][0]['price'] : '0',
|
33
36
|
categories: self.get_categories(product),
|
34
|
-
|
37
|
+
availability: self.get_availability(product),
|
35
38
|
weight: product['weight'] ? product['weight']['value'] : '0',
|
36
39
|
width: product['width'] ? product['width']['value'] : '0',
|
37
40
|
depth: product['depth'] ? product['depth']['value'] : '0',
|
@@ -40,6 +43,9 @@ module BigcommerceProductAgent
|
|
40
43
|
meta_description: self.meta_description(product) || '',
|
41
44
|
search_keywords: self.get_search_keywords(additional_data.delete(:additional_search_terms), product),
|
42
45
|
is_visible: variant ? false : true,
|
46
|
+
preorder_release_date: product['releaseDate'] && product['releaseDate'].to_datetime ? product['releaseDate'].to_datetime.strftime("%FT%T%:z") : nil,
|
47
|
+
preorder_message: self.get_availability(product) == 'preorder' ? product['availability'] : '',
|
48
|
+
is_preorder_only: self.get_availability(product) == 'preorder' ? true : false,
|
43
49
|
}
|
44
50
|
result[:upc] = product['gtin12'] if product['gtin12']
|
45
51
|
|
@@ -187,6 +193,33 @@ module BigcommerceProductAgent
|
|
187
193
|
def self.get_search_keywords(additional_search_terms, product)
|
188
194
|
return (self.meta_keywords(product) + additional_search_terms.split(",")).join(",")
|
189
195
|
end
|
196
|
+
|
197
|
+
def self.get_availability(product)
|
198
|
+
if product['datePublished'] && product['datePublished'].to_datetime && product['datePublished'].to_datetime < DateTime.now
|
199
|
+
return 'available'
|
200
|
+
else
|
201
|
+
if product['releaseDate'] && product['releaseDate'].to_datetime
|
202
|
+
if product['releaseDate'].to_datetime > DateTime.now
|
203
|
+
return 'preorder'
|
204
|
+
else
|
205
|
+
return 'available'
|
206
|
+
end
|
207
|
+
else
|
208
|
+
return 'disabled'
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def self.get_availability_offer(product, variant)
|
214
|
+
if product['offers'] && product['offers'][0]
|
215
|
+
return product['offers'][0]['availability']
|
216
|
+
else
|
217
|
+
if variant['offers'] && variant['offers'][0]
|
218
|
+
return variant['offers'][0]['availability']
|
219
|
+
end
|
220
|
+
end
|
221
|
+
return ''
|
222
|
+
end
|
190
223
|
end
|
191
224
|
end
|
192
225
|
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.6.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-06-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|