beyond_api 0.3.0.pre → 0.4.0.pre

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: 39f26590cd69a079e050654b3594df5730ad90b989135d2ec98f0ab81bdc8c29
4
- data.tar.gz: bdf1d4aead411a78eeaddf0fefa04a9ff016ec512248002a83aa83b99ff09651
3
+ metadata.gz: e3795859a890e583f269eb293d62e8e05eb37b03d64c6a0c3b50015c519ae3ef
4
+ data.tar.gz: 7e20846e047c5f9cdce44bfe8960ee58c712690f6ac08ffcc13a15165ce4e6d3
5
5
  SHA512:
6
- metadata.gz: 844e88bcc3c6a4bc455ff939479429bb109ea11627bf745ad91ea8eea11bbd7ef3ffbdfbdcb767e96b8ded26c6e17d2e6e05dfe33e51c8901af9ab2e492222b0
7
- data.tar.gz: 3c2ff7a924237f01b048c6de04b692b004039410023f0ef62e75b7a070a27145b2ba1526b08f5629389eb0a66fae6c7a1b85cd40d1a2a3fab6645ddd6842ffbe
6
+ metadata.gz: fd8ad25f6dc6e0026172bd64ba6e952cfb44183aea2547c5bd5ba94a3a1b23b1c358d9f551f1d35ca49fdffdd9e921f3cc13e9fa3189b1fe79e8fa7a3da1a7a3
7
+ data.tar.gz: 5ee088be3e778a21cc2db512e7d85b93585cc9b5463731aa29e6a2feca0fc82421cbcd136377c06cfb482d012f136485883c5e38490a1ab74d63d671bf72ce0f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,37 @@
1
- ### 0.1.0.pre
1
+ ### v0.4.0.pre
2
+
3
+ * bug-fixes
4
+ * Fix product attribute definition `create` method
5
+ * Fix product attribute definition `delete` method
6
+ * Fix product custom attribute module name
7
+ * Include `BeyondApi::ProductCustomAttributes` module into `BeyondApi::Products` class
8
+ * Include `BeyondApi::ProductImages` module into `BeyondApi::Products` class
9
+
10
+ * enhancements
11
+ * Allow to get all product attribute definitions on a single call
12
+
13
+ ### v0.3.0.pre
14
+
15
+ * bug-fixes
16
+ * Fix logger
17
+
18
+ * features
19
+ * Add a configurable option to raise on error requests
20
+
21
+ ### v0.2.1.pre
22
+
23
+ * features
24
+ * Add logger option
25
+
26
+ ### v0.2.0.pre
27
+
28
+ * bug-fixes
29
+ * Fix the signers delete endpoint
30
+
31
+ * enhancements
32
+ * Add better documentation
33
+
34
+ ### v0.1.0.pre
2
35
 
3
36
  * features
4
37
  * All endpoints offered by the Beyond API
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beyond_api (0.3.0.pre)
4
+ beyond_api (0.4.0.pre)
5
5
  faraday (~> 0.15)
6
6
 
7
7
  GEM
@@ -14,6 +14,7 @@ module BeyondApi
14
14
  #
15
15
  # @beyond_api.scopes +prad:r+
16
16
  #
17
+ # @option param [Boolean] :paginated
17
18
  # @option param [Integer] :size the page size
18
19
  # @option param [Integer] :page the page number
19
20
  #
@@ -23,9 +24,18 @@ module BeyondApi
23
24
  # @product_attribute_definitions = session.product_attribute_definitions.all(size: 100, page: 0)
24
25
  #
25
26
  def all(params = {})
26
- response, status = BeyondApi::Request.get(@session, "/product-attribute-definitions", params)
27
+ if params[:paginated] == false
28
+ result = all_paginated(page: 0, size: 1000)
27
29
 
28
- handle_response(response, status)
30
+ (1..result[:page][:total_pages] - 1).each do |page|
31
+ result[:embedded][:product_attribute_definition].concat(all_paginated(page: page, size: 1000)[:embedded][:product_attribute_definitions])
32
+ end
33
+
34
+ result.is_a?(Hash) ? result.delete(:page) : result.delete_field(:page)
35
+ result
36
+ else
37
+ all_paginated(params)
38
+ end
29
39
  end
30
40
 
31
41
  #
@@ -56,8 +66,8 @@ module BeyondApi
56
66
  # }
57
67
  # @product_attribute_definition = session.product_attribute_definitions.create(body)
58
68
  #
59
- def create(product_attribute_name)
60
- response, status = BeyondApi::Request.post(@session, "/product-attribute-definitions")
69
+ def create(body)
70
+ response, status = BeyondApi::Request.post(@session, "/product-attribute-definitions", body)
61
71
 
62
72
  handle_response(response, status)
63
73
  end
@@ -80,7 +90,7 @@ module BeyondApi
80
90
  # session.product_attribute_definitions.delete("filling_capacity")
81
91
  #
82
92
  def delete(product_attribute_name)
83
- response, status = BeyondApi::Request.get(@session, "/product-attribute-definitions/#{product_attribute_name}")
93
+ response, status = BeyondApi::Request.delete(@session, "/product-attribute-definitions/#{product_attribute_name}")
84
94
 
85
95
  handle_response(response, status, respond_with_true: true)
86
96
  end
@@ -105,5 +115,12 @@ module BeyondApi
105
115
 
106
116
  handle_response(response, status)
107
117
  end
118
+
119
+ private
120
+
121
+ def all_paginated(params = {})
122
+ response, status = BeyondApi::Request.get(@session, "/product-attribute-definitions", params)
123
+ handle_response(response, status)
124
+ end
108
125
  end
109
126
  end
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "beyond_api/utils"
4
+ require "beyond_api/resources/products/custom_attributes"
5
+ require "beyond_api/resources/products/images"
4
6
 
5
7
  module BeyondApi
6
8
  class Products < Base
9
+ include BeyondApi::ProductCustomAttributes
10
+ include BeyondApi::ProductImages
7
11
  include BeyondApi::Utils
8
12
 
9
13
  #
@@ -3,7 +3,7 @@
3
3
  require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
- module ProductCustomAttribute
6
+ module ProductCustomAttributes
7
7
 
8
8
  #
9
9
  # A +POST+ request is used to create a product attribute, which defines the value of a certain {product attribute definition}[http://docs.beyondshop.cloud/#resources-product-attribute-definitions] for a specific {product}[http://docs.beyondshop.cloud/#resources-products].
@@ -1,3 +1,3 @@
1
1
  module BeyondApi
2
- VERSION = "0.3.0.pre".freeze
2
+ VERSION = "0.4.0.pre".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre
4
+ version: 0.4.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unai Abrisketa
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-10-22 00:00:00.000000000 Z
13
+ date: 2019-11-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler