Skip to content

Commit 2094593

Browse files
author
Unai Abrisketa
committed
Merge remote-tracking branch 'upstream/master'
2 parents c6dd194 + aa364f2 commit 2094593

File tree

15 files changed

+820
-480
lines changed

15 files changed

+820
-480
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
### v0.12.1.pre
2+
3+
* bug-fixes
4+
* Fix camelize function for hashes containing arrays
5+
6+
### v0.12.0.pre
7+
8+
* features
9+
* Add locations methods
10+
* `Locations#all`
11+
* `Locations#create`
12+
* `Locations#delete`
13+
* `Locations#find`
14+
* `Locations#update`
15+
16+
* enhancements
17+
* Use `autoload` instead of `require`
18+
19+
### v0.11.1.pre
20+
21+
* bug-fixes
22+
* Use `BeyondApi::Error` for authentication errors
23+
124
### v0.11.0.pre
225

326
* enhancements

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.11.0.pre)
4+
beyond_api (0.12.1.pre)
55
faraday (~> 0.15)
66

77
GEM

lib/beyond_api/error.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
module BeyondApi
44
class Error < StandardError
5-
attr_reader :error_id, :details, :trace_id, :full_message, :status_code
5+
attr_reader :error_id, :details, :trace_id, :full_message, :status_code, :error, :error_description
66

77
def initialize(data, status_code = nil)
8-
@error_id = data['errorId']
9-
@details = data['details']
10-
@trace_id = data['traceId']
11-
@full_message = data
12-
@status_code = status_code
8+
@error_id = data['errorId']
9+
@details = data['details']
10+
@trace_id = data['traceId']
11+
@error = data['error']
12+
@error_description = data['error_description']
13+
@full_message = data
14+
@status_code = status_code
1315

14-
super(data['message'])
16+
super(data['message'] || data['error_description'])
1517
end
1618
end
1719
end

lib/beyond_api/ext.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ class Hash
44
def deep_transform_keys(&block)
55
result = {}
66
each do |key, value|
7-
result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value
7+
result[yield(key)] = case value
8+
when Hash
9+
value.deep_transform_keys(&block)
10+
when Array
11+
value.camelize_keys
12+
else
13+
value
14+
end
815
end
916
result
1017
end

lib/beyond_api/resources/products.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# frozen_string_literal: true
22

33
require "beyond_api/utils"
4-
require "beyond_api/resources/products/attachments"
5-
require "beyond_api/resources/products/availability"
6-
require "beyond_api/resources/products/cross_sells"
7-
require "beyond_api/resources/products/custom_attributes"
8-
require "beyond_api/resources/products/images"
9-
require "beyond_api/resources/products/searches"
10-
require "beyond_api/resources/products/variation_properties"
11-
require "beyond_api/resources/products/videos"
124

135
module BeyondApi
6+
autoload :ProductAttachments, "beyond_api/resources/products/attachments"
7+
autoload :ProductAvailability, "beyond_api/resources/products/availability"
8+
autoload :ProductCrossSells, "beyond_api/resources/products/cross_sells"
9+
autoload :ProductCustomAttributes, "beyond_api/resources/products/custom_attributes"
10+
autoload :ProductImages, "beyond_api/resources/products/images"
11+
autoload :ProductSearches, "beyond_api/resources/products/searches"
12+
autoload :ProductVariationProperties, "beyond_api/resources/products/variation_properties"
13+
autoload :ProductVideos, "beyond_api/resources/products/videos"
14+
1415
class Products < Base
1516
include BeyondApi::ProductAttachments
1617
include BeyondApi::ProductAvailability

0 commit comments

Comments
 (0)