huginn_acumen_product_agent 1.4.0 → 1.6.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: 158ba4f844cb9b68a1e554d322c1cdde320fe46bb3740b22f97c490ef7a4f35f
|
4
|
+
data.tar.gz: c567ef95d19590b6df91f6b961f8f68fa8efc28151c3e446245165b084b273aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4d0b0dd3eb5bc6e7490922d37bb7760f9590c0e6737ec377f84b9ff1e743ac388c3676ab15b7ff4e5a1a4898f5c20451b7ab346bbcc5202afecb0f40b576244
|
7
|
+
data.tar.gz: a2422b4b261212d2ae098c71da5ec0adb823704798bb852157019d293fc8ecf656437777ba17b8a4fb9bc5b89f4bbf138ee01c9d126768e5cb9e9faf0a96a03e
|
@@ -93,6 +93,9 @@ class AcumenClient
|
|
93
93
|
<column_name>Inv_Product.Info_Alpha_1</column_name>
|
94
94
|
<column_name>Inv_Product.Info_Boolean_1</column_name>>
|
95
95
|
<column_name>Inv_Product.Category</column_name>
|
96
|
+
<column_name>Inv_Product.Next_Release</column_name>
|
97
|
+
<column_name>Inv_Product.BO_Reason</column_name>
|
98
|
+
<column_name>Inv_Product.Not_On_Website</column_name>
|
96
99
|
</requested_output>
|
97
100
|
</acusoapRequest>
|
98
101
|
XML
|
@@ -54,6 +54,12 @@ module Agents
|
|
54
54
|
unless options['contributor_types_map'].is_a?(Hash)
|
55
55
|
errors.add(:base, "if provided, contributor_types_map must be a hash")
|
56
56
|
end
|
57
|
+
|
58
|
+
if options['ignore_skus']
|
59
|
+
unless options['ignore_skus'].is_a?(Array)
|
60
|
+
errors.add(:base, "if provided, ignore_skus must be an array")
|
61
|
+
end
|
62
|
+
end
|
57
63
|
end
|
58
64
|
|
59
65
|
def working?
|
@@ -78,6 +84,7 @@ module Agents
|
|
78
84
|
password = interpolated['password']
|
79
85
|
physical_formats = interpolated['physical_formats']
|
80
86
|
digital_formats = interpolated['digital_formats']
|
87
|
+
ignore_skus = interpolated['ignore_skus'] ? interpolated['ignore_skus'] : []
|
81
88
|
|
82
89
|
auth = {
|
83
90
|
'site_code' => site_code,
|
@@ -104,7 +111,9 @@ module Agents
|
|
104
111
|
end
|
105
112
|
|
106
113
|
products.each do |product|
|
107
|
-
|
114
|
+
unless ignore_skus.include?(product['sku'])
|
115
|
+
create_event payload: product
|
116
|
+
end
|
108
117
|
end
|
109
118
|
end
|
110
119
|
|
@@ -10,7 +10,12 @@ module AcumenProductQueryConcern
|
|
10
10
|
|
11
11
|
def get_products_by_ids(acumen_client, ids)
|
12
12
|
response = acumen_client.get_products(ids)
|
13
|
-
products =
|
13
|
+
products = []
|
14
|
+
|
15
|
+
# Filter out Not_On_Website === '1'
|
16
|
+
unless response[0]['Inv_Product.Not_On_Website']['__content__'] === '1'
|
17
|
+
products = parse_product_request(response)
|
18
|
+
end
|
14
19
|
|
15
20
|
response = acumen_client.get_products_marketing(ids)
|
16
21
|
marketing = parse_product_marketing_request(response)
|
@@ -20,7 +25,16 @@ module AcumenProductQueryConcern
|
|
20
25
|
|
21
26
|
def get_variants_for_ids(acumen_client, ids)
|
22
27
|
result = get_linked_products_by_ids(acumen_client, ids)
|
23
|
-
|
28
|
+
|
29
|
+
# Filtering out duplicate links getting sent from acumen
|
30
|
+
filter = []
|
31
|
+
result.each do |link|
|
32
|
+
if (link['alt_format'].to_s != 0.to_s && !link.in?(filter))
|
33
|
+
filter.push(link)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
return filter
|
24
38
|
end
|
25
39
|
|
26
40
|
def get_linked_products_by_ids(acumen_client, ids)
|
@@ -77,20 +91,24 @@ module AcumenProductQueryConcern
|
|
77
91
|
|
78
92
|
def get_product_categories(acumen_client, products)
|
79
93
|
# fetch categories
|
80
|
-
|
94
|
+
|
95
|
+
skus = products.map { |product| product['model'].map { |m| m['sku'] } }[0]
|
81
96
|
response = acumen_client.get_product_categories(skus)
|
82
97
|
categories = process_product_categories_query(response)
|
83
98
|
|
84
99
|
# map categories to products
|
85
100
|
products.each do |product|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
101
|
+
product['model'].each do |variant|
|
102
|
+
variant['categories'] = []
|
103
|
+
sku = variant['sku']
|
104
|
+
if categories[sku]
|
105
|
+
active = categories[sku].select { |c| c['inactive'] == '0' }
|
106
|
+
active.map do |category|
|
107
|
+
variant['categories'].push({
|
108
|
+
'@type' => 'Thing',
|
109
|
+
'identifier' => category['category_id']
|
110
|
+
})
|
111
|
+
end
|
94
112
|
end
|
95
113
|
end
|
96
114
|
end
|
@@ -106,6 +124,7 @@ module AcumenProductQueryConcern
|
|
106
124
|
'Inv_Product.SubTitle' => 'disambiguatingDescription',
|
107
125
|
'Inv_Product.ISBN_UPC' => 'isbn',
|
108
126
|
'Inv_Product.Pub_Date' => 'datePublished',
|
127
|
+
'Inv_Product.Next_Release' => 'releaseDate',
|
109
128
|
})
|
110
129
|
variant['@type'] = 'ProductModel'
|
111
130
|
variant['isDefault'] = false
|
@@ -117,11 +136,13 @@ module AcumenProductQueryConcern
|
|
117
136
|
variant['offers'] = [{
|
118
137
|
'@type' => 'Offer',
|
119
138
|
'price' => field_value(p, 'Inv_Product.Price_1'),
|
139
|
+
'availability' => field_value(p, 'Inv_Product.BO_Reason')
|
120
140
|
}]
|
121
141
|
if field_value(p, 'Inv_Product.Price_2')
|
122
142
|
variant['offers'].push({
|
123
143
|
'@type' => 'Offer',
|
124
144
|
'price' => field_value(p, 'Inv_Product.Price_2'),
|
145
|
+
'availability' => field_value(p, 'Inv_Product.BO_Reason')
|
125
146
|
})
|
126
147
|
end
|
127
148
|
|
@@ -372,9 +393,11 @@ module AcumenProductQueryConcern
|
|
372
393
|
links.each do |link|
|
373
394
|
from_id = link['from_id']
|
374
395
|
to_id = link['to_id']
|
375
|
-
|
376
|
-
|
377
|
-
|
396
|
+
if variants_map.key?(to_id)
|
397
|
+
variant = variants_map[to_id]
|
398
|
+
variant['isDefault'] = false
|
399
|
+
products_map[from_id]['model'].push(*variant['model'])
|
400
|
+
end
|
378
401
|
end
|
379
402
|
|
380
403
|
result = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_acumen_product_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.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-
|
11
|
+
date: 2020-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|