akeneo 1.5.0 → 1.6.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: e23e9957d939ac3ec1b78110e9c1488e9b7603661a635bb2c0ea6ec7ea6de067
4
- data.tar.gz: 03c61f430ae6e7df2ea18d687b6a0a4fbe969d983bcfca02fe8c72e27d213a4f
3
+ metadata.gz: f303ceb4a14dd7ab8dbc34262a322e34202c6eb4370139aa3ef0b3472db7b356
4
+ data.tar.gz: f9ef743047f2579fa8b76d63ae1594e039dd693c2ac2efc6021a7fbc389f719d
5
5
  SHA512:
6
- metadata.gz: 24adead0b454a21ba3f9d5e01c08f8bfc03284451b29deedafa6ff1b971d030839d0f66fd3a0e5264e7c92accf24e3aee2f7a0c837e320eced2b469f1acaffaf
7
- data.tar.gz: 1b73fae84742e1e1a94066f96db9186e5795a31d28d0a6c9db5b41cbe1ad18ca1b3cec0697b115634d00d54b406114d29d5a96fcf5f4b0ce0e20c12e70cf4c97
6
+ metadata.gz: ce6e025a9e0cd24b4fe174c0d7fbcc4a409f609e76c9da60f61b7eddd324b4631c94f5eea0466559f87f2599958c574e66e61b95c81153c29c883883e2a8f284
7
+ data.tar.gz: 5b57fe99232ffaa7b8d1e5f7c47099bf46afb5d8f09a58a540f4605f99d538da7efbd220192d5e3623065029afbb342bc071bae016bd1530df21382a522eea44
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- akeneo (1.5.0)
4
+ akeneo (1.6.0)
5
5
  httparty
6
6
  mime-types
7
7
  redis
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'akeneo'
8
- spec.version = '1.5.0'
8
+ spec.version = '1.6.0'
9
9
  spec.authors = ['AWN Dev Team']
10
10
  spec.email = ['edv@awn.de']
11
11
 
@@ -12,12 +12,7 @@ module Akeneo
12
12
 
13
13
  def initialize(url:, client_id:, secret:, username:, password:)
14
14
  @url = url
15
- authorization_service.authorize!(
16
- client_id: client_id,
17
- secret: secret,
18
- username: username,
19
- password: password
20
- )
15
+ authorization_service.authorize!(client_id: client_id, secret: secret, username: username, password: password)
21
16
  end
22
17
 
23
18
  def fresh_access_token
@@ -28,8 +23,12 @@ module Akeneo
28
23
  product_service.find(sku)
29
24
  end
30
25
 
31
- def products(with_family: nil)
32
- product_service.all(with_family: with_family)
26
+ def products(with_family: nil, with_completeness: nil, updated_after: nil)
27
+ product_service.all(
28
+ with_family: with_family,
29
+ with_completeness: with_completeness,
30
+ updated_after: updated_after
31
+ )
33
32
  end
34
33
 
35
34
  def published_products(updated_after: nil)
@@ -27,10 +27,9 @@ module Akeneo
27
27
  load_products(akeneo_product, akeneo_product['family'], parents)
28
28
  end
29
29
 
30
- def all(with_family: nil)
30
+ def all(with_family: nil, with_completeness: nil, updated_after: nil)
31
31
  Enumerator.new do |products|
32
- path = "/products?#{pagination_param}&#{limit_param}"
33
- path += search_with_family_param(with_family) if with_family
32
+ path = build_path(with_family, with_completeness, updated_after)
34
33
 
35
34
  loop do
36
35
  response = get_request(path)
@@ -47,8 +46,13 @@ module Akeneo
47
46
 
48
47
  private
49
48
 
50
- def search_with_family_param(family)
51
- "&search={\"family\":[{\"operator\":\"IN\",\"value\":[\"#{family}\"]}]}"
49
+ def build_path(family, completeness, updated_after)
50
+ path = "/products?#{pagination_param}&#{limit_param}"
51
+ path + search_params(
52
+ family: family,
53
+ completeness: completeness,
54
+ updated_after: updated_after
55
+ )
52
56
  end
53
57
 
54
58
  def load_akeneo_parent(code)
@@ -12,7 +12,7 @@ module Akeneo
12
12
  def published_products(updated_after: nil)
13
13
  Enumerator.new do |products|
14
14
  path = "/published-products?#{pagination_param}"
15
- path += "&#{search_param(updated_after)}" if updated_after
15
+ path += search_params(updated_after: updated_after)
16
16
 
17
17
  loop do
18
18
  response = get_request(path)
@@ -19,6 +19,20 @@ module Akeneo
19
19
 
20
20
  private
21
21
 
22
+ def search_params(family: nil, completeness: nil, updated_after: nil)
23
+ return '' if family.nil? && completeness.nil? && updated_after.nil?
24
+
25
+ "&search=#{search_params_hash(family, completeness, updated_after).to_json}"
26
+ end
27
+
28
+ def search_params_hash(family, completeness, updated_after)
29
+ {}.tap do |hash|
30
+ hash[:family] = [{ operator: 'IN', value: [family] }] if family
31
+ hash[:completeness] = [completeness] if completeness
32
+ hash[:updated] = [{ operator: '>', value: updated_after.strftime('%F %T') }] if updated_after
33
+ end
34
+ end
35
+
22
36
  def json_headers
23
37
  { 'Content-Type' => 'application/json' }
24
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akeneo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AWN Dev Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-11 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -179,7 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.0.2
182
+ rubyforge_project:
183
+ rubygems_version: 2.7.6
183
184
  signing_key:
184
185
  specification_version: 4
185
186
  summary: API client for accessing Akeneo