Skip to content

Commit c4cd06e

Browse files
authored
Release v0.10.0.pre (#24)
1 parent a442b43 commit c4cd06e

16 files changed

+60
-73
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
### v0.10.0.pre
2+
3+
* features
4+
* Add optional `paginated: false` parameter to `session.categories_view.all(paginated: false)`
5+
* Add optional `paginated: false` parameter to `session.categories.all(paginated: false)`
6+
* Add optional `paginated: false` parameter to `session.customers.all(paginated: false)`
7+
* Add optional `paginated: false` parameter to `session.orders.all(paginated: false)`
8+
* Add optional `paginated: false` parameter to `session.payment_methods.all(paginated: false)`
9+
* Add optional `paginated: false` parameter to `session.products_view.all(paginated: false)`
10+
* Add optional `paginated: false` parameter to `session.script_tags.all(paginated: false)`
11+
* Add optional `paginated: false` parameter to `session.shipping_zones.all(paginated: false)`
12+
* Add optional `paginated: false` parameter to `session.users.all(paginated: false)`
13+
* Add optional `paginated: false` parameter to `session.webhook_subscriptions.all(paginated: false)`
14+
115
### v0.9.0.pre
216

317
* bug-fixes

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
beyond_api (0.9.0.pre)
4+
beyond_api (0.10.0.pre)
55
faraday (~> 0.15)
66

77
GEM

lib/beyond_api/resources/categories.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Categories < Base
1616
#
1717
# @beyond_api.scopes +catg:r+
1818
#
19+
# @option params [Boolean] :paginated
1920
# @option params [Integer] :size the page size
2021
# @option params [Integer] :page the page number
2122
#
@@ -25,9 +26,7 @@ class Categories < Base
2526
# @categories = session.categories.all(size: 100, page: 0)
2627
#
2728
def all(params = {})
28-
response, status = BeyondApi::Request.get(@session, "/categories", params)
29-
30-
handle_response(response, status)
29+
handle_all_request("/categories", :categories, params)
3130
end
3231

3332
#

lib/beyond_api/resources/categories_view.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CategoriesView < Base
1414
# -H 'Accept: application/hal+json'
1515
#
1616
#
17+
# @option params [Boolean] :paginated
1718
# @option params [Integer] :size the page size
1819
# @option params [Integer] :page the page number
1920
#
@@ -23,9 +24,7 @@ class CategoriesView < Base
2324
# @categories = session.categories_view.all(size: 100, page: 0)
2425
#
2526
def all(params = {})
26-
response, status = BeyondApi::Request.get(@session, "/product-view/categories", params)
27-
28-
handle_response(response, status)
27+
handle_all_request("/product-view/categories", :categories, params)
2928
end
3029

3130
#

lib/beyond_api/resources/customers.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Customers < Base
1414
#
1515
# @beyond_api.scopes +cust:r+
1616
#
17+
# @option params [Boolean] :paginated
1718
# @option params [Integer] :size the page size
1819
# @option params [Integer] :page the page number
1920
#
@@ -23,9 +24,7 @@ class Customers < Base
2324
# @customers = session.customers.all(size: 20, page: 0)
2425
#
2526
def all(params = {})
26-
response, status = BeyondApi::Request.get(@session, "/customers", params)
27-
28-
handle_response(response, status)
27+
handle_all_request("/customers", :customers, params)
2928
end
3029

3130
#

lib/beyond_api/resources/orders.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def active_refund_process(order_id)
5757
#
5858
# @beyond_api.scopes +ordr:r+
5959
#
60+
# @option params [Boolean] :paginated
6061
# @option params [Integer] :size the page size
6162
# @option params [Integer] :page the page number
6263
#
@@ -66,9 +67,7 @@ def active_refund_process(order_id)
6667
# @orders = session.orders.all(size: 100, page: 0)
6768
#
6869
def all(params = {})
69-
response, status = BeyondApi::Request.get(@session, "/orders", params)
70-
71-
handle_response(response, status)
70+
handle_all_request("/orders", :orders, params)
7271
end
7372

7473
#

lib/beyond_api/resources/payment_methods.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def activate(payment_method_id)
3838
#
3939
# @beyond_api.scopes +pymt:r+
4040
#
41+
# @option params [Boolean] :paginated
4142
# @option params [Integer] :size the page size
4243
# @option params [Integer] :page the page number
4344
#
@@ -47,9 +48,7 @@ def activate(payment_method_id)
4748
# @payment_methods = session.payment_methods.all(size: 100, page: 0)
4849
#
4950
def all(params = {})
50-
response, status = BeyondApi::Request.get(@session, "/payment-methods", params)
51-
52-
handle_response(response, status)
51+
handle_all_request("/payment-methods", :payment_methods, params)
5352
end
5453

5554
#

lib/beyond_api/resources/product_attribute_definitions.rb

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,7 @@ class ProductAttributeDefinitions < Base
2424
# @product_attribute_definitions = session.product_attribute_definitions.all(size: 100, page: 0)
2525
#
2626
def all(params = {})
27-
if params[:paginated] == false
28-
result = all_paginated(page: 0, size: 1000)
29-
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-
36-
result
37-
else
38-
all_paginated(params)
39-
end
27+
handle_all_request("/product-attribute-definitions", :product_attribute_definitions, params)
4028
end
4129

4230
#
@@ -114,12 +102,5 @@ def find(product_attribute_name)
114102

115103
handle_response(response, status)
116104
end
117-
118-
private
119-
120-
def all_paginated(params = {})
121-
response, status = BeyondApi::Request.get(@session, "/product-attribute-definitions", params)
122-
handle_response(response, status)
123-
end
124105
end
125106
end

lib/beyond_api/resources/products.rb

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,7 @@ class Products < Base
4242
# @products = session.products.all(size: 100, page: 0)
4343
#
4444
def all(params = {})
45-
if params[:paginated] == false
46-
result = all_paginated(page: 0, size: 1000)
47-
48-
(1..result[:page][:total_pages] - 1).each do |page|
49-
result[:embedded][:products].concat(all_paginated(page: page, size: 1000)[:embedded][:products])
50-
end
51-
52-
result.is_a?(Hash) ? result.delete(:page) : result.delete_field(:page)
53-
54-
result
55-
else
56-
all_paginated(params)
57-
end
45+
handle_all_request("/products", :products, params)
5846
end
5947

6048
#
@@ -293,13 +281,5 @@ def assign_variation_images_differentiator(product_id, differentiator)
293281
alias_method :create_variation, :create
294282
alias_method :find_variation, :find
295283
alias_method :update_variation, :update
296-
297-
private
298-
299-
def all_paginated(params = {})
300-
response, status = BeyondApi::Request.get(@session, "/products", params)
301-
302-
handle_response(response, status)
303-
end
304284
end
305285
end

lib/beyond_api/resources/products_view.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class ProductsView < Base
1313
# -H 'Content-Type: application/json' \
1414
# -H 'Accept: application/hal+json'
1515
#
16+
# @option params [Boolean] :paginated
1617
# @option params [Integer] :size the page size
1718
# @option params [Integer] :page the page number
1819
#
@@ -22,9 +23,7 @@ class ProductsView < Base
2223
# @products = session.products_view.all(page: 0, size: 100)
2324
#
2425
def all(params = {})
25-
response, status = BeyondApi::Request.get(@session, "/product-view/products", params)
26-
27-
handle_response(response, status)
26+
handle_all_request("/product-view/products", :products, params)
2827
end
2928

3029
#

0 commit comments

Comments
 (0)