Skip to content

Commit 574b75d

Browse files
committed
cleaning rubocop offenses, adding examples, bumping version
1 parent 27f42e2 commit 574b75d

File tree

8 files changed

+64
-12
lines changed

8 files changed

+64
-12
lines changed

changelog.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## 1.0.4
2+
3+
* New Calls:
4+
5+
* Epages::REST::Shop#`update_product`
6+
* Epages::REST::Shop#`product_add_slideshow_image`
7+
* Epages::REST::Shop#`product_delete_slideshow_image`
8+
* Epages::REST::Shop#`product_slideshow_sequence`
9+
* Epages::REST::Shop#`product_update_slideshow_sequence`
10+
* Epages::REST::Shop#`sales`
11+
* Epages::REST::Shop#`parallel_calls`
12+
13+
* Other changes
14+
15+
* new attributes `shipping_data` and `payment_data` to orders
16+
* replaced attribute `comment` with `ustomer_comment` and `internal_note`
17+
* added range filters `crated_before` and `created_after` to orders
18+
* dates and are interpreted as Datetime, before was String
19+

examples/miscellaneous.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,23 @@ Returns suggestions for a product search query. Returns an Array of Epages::Prod
2929
```
3030
jackets = shop.product_suggestions_for("Jacket")
3131
top = shop.product_suggestions_for("Jacket", limit: 5)
32+
```
33+
34+
## Parallel calls
35+
36+
Run the calls in different threads and return the responses in the same order as it was called.
37+
The keys must be the same that the name of the method to call. If you want to call multiple times tha same call with different parameters put every collection as an array element
38+
39+
```
40+
requests = {
41+
products: {},
42+
categories: {locale: 'en_GB'},
43+
create_cart: {currency: 'USD', locale: 'en_US'},
44+
}
45+
product_requests = {
46+
products: [{sort: 'name', results_per_page: 2}, {results_per_page: 1, page: 3}],
47+
}
48+
49+
response = shop.parallel_calls(requests) # => { products: products_response, categories: categories_response, create_cart: create_cart_response }
50+
product_response = shop.parallel_calls(requests) # => { products: [products_response_1, products_response_2] }
3251
```

examples/sales.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# [Sales Examples](https://developer.epages.com/apps/api-reference/resource-sales.html)
2+
3+
This example assumes you have configured the `shop` correctly.
4+
5+
# [Sales Call](https://developer.epages.com/apps/api-reference/get-shops-shopid-sales.html)
6+
7+
Returns the summary of sales for a specified product or for the shop grouped by currencies.
8+
9+
```
10+
general_sales = shop.sales
11+
product_sales = shop.sales(product_id: product)
12+
today_sales = shop.sales(created_after: Date.today)
13+
sales_since = shop.sales(created_after: '24-01-2016')
14+
```

lib/epages/rest/products.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def product_add_slideshow_image(product, image)
7171
# @param image [String]
7272
def product_delete_slideshow_image(product, image)
7373
id = epages_id(product)
74-
perform_delete_request("/products/#{id}/slideshow/#{image.to_s}")
74+
perform_delete_request("/products/#{id}/slideshow/#{image}")
7575
end
7676

7777
# call the API to get the slideshow sequence of a product

lib/epages/rest/request.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initialize(object, request_method, path, options = {})
1818
def set_request_options(method, options)
1919
@request_method = method
2020
@headers = request_headers
21-
@options = set_options(options)
21+
@options = format_options(options)
2222
end
2323

2424
def auth_token
@@ -40,7 +40,7 @@ def request_headers
4040
end
4141

4242
def options_passed_by
43-
return :form if @request_method == :post && @options.has_key?(:image)
43+
return :form if @request_method == :post && @options.key?(:image)
4444
case @request_method
4545
when :get then :params
4646
when :patch then :body
@@ -52,7 +52,7 @@ def content_type_options
5252
@request_method == :patch ? 'application/json-patch+json' : 'application/json'
5353
end
5454

55-
def set_options(options)
55+
def format_options(options)
5656
case @request_method
5757
when :multipart_post then options_to_multipart_request(options)
5858
when :patch then options_to_patch_request(options).to_json
@@ -62,10 +62,10 @@ def set_options(options)
6262

6363
def mime_type(basename)
6464
case basename
65-
when %r{.gif} then 'image/gif'
66-
when %r{.jpe?g} then 'image/jpeg'
67-
when %r{.png} then 'image/png'
68-
else 'application/octet-stream'
65+
when /.gif/ then 'image/gif'
66+
when /.jpe?g/ then 'image/jpeg'
67+
when /.png/ then 'image/png'
68+
else 'application/octet-stream'
6969
end
7070
end
7171

lib/epages/rest/utils.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def perform_post_with_objects(path, options, klass)
7070
# @param options [Hash]
7171
# @param klass [Class]
7272
def perform_multipart_post_with_objects(path, image, klass)
73-
response = perform_request(:multipart_post, path, {file: image})
74-
response.has_key?('items') ? response[:items].collect { |data| klass.new(data) } : klass.new(response)
73+
response = perform_request(:multipart_post, path, file: image)
74+
response.key?('items') ? response[:items].collect { |data| klass.new(data) } : klass.new(response)
7575
end
7676

7777
# @param request_method [Symbol]

lib/epages/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Epages
2-
VERSION = '1.0.3'
2+
VERSION = '1.0.4'
33
end

spec/epages/rest/products_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
end
6060

6161
it 'assigns attributes' do
62-
api_product = shop.update_product(product, 'name' => name, 'short_description' => short_description, "price_info/price/amount" => price)
62+
api_product = shop.update_product(product, 'name' => name, 'short_description' => short_description, 'price_info/price/amount' => price)
6363
expect(api_product.name).to eq name
6464
expect(api_product.short_description).to eq short_description
6565
expect(api_product.price_info.price.amount).to eq price

0 commit comments

Comments
 (0)