trailer_vote-api 0.7.0 → 0.8.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/lib/trailer_vote/api/composable/get.rb +1 -1
- data/lib/trailer_vote/api/configuration.rb +1 -1
- data/lib/trailer_vote/api/fallback_content_types.rb +1 -1
- data/lib/trailer_vote/api/links.rb +6 -5
- data/lib/trailer_vote/api/place/find.rb +1 -1
- data/lib/trailer_vote/api/product/find.rb +1 -1
- data/lib/trailer_vote/api/product/image/find.rb +1 -1
- data/lib/trailer_vote/api/product/image/urls.rb +1 -1
- data/lib/trailer_vote/api/product/video/find.rb +1 -1
- data/lib/trailer_vote/api/product/video/urls.rb +1 -1
- data/lib/trailer_vote/api/type_registry.rb +7 -3
- data/lib/trailer_vote/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035d07df472d9ab44ddba2e14502be9afda848d7
|
4
|
+
data.tar.gz: dc7b3e5583f5983bf5c91eed6ef50a85699c67ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 483ea0ce019b10b29b9c8f598d3e5f2822dd0e38efca8e6e16428d4cd2a116442c0f948483c3fbf3ac2762f95715f27112eb5f8df63819b72d30b6dfd043d89d
|
7
|
+
data.tar.gz: 97e6fba14eabe8c3ee27c65cc9bcdcfb6f89e42f97bfd476ecf1cd76461df64664b715cd8e3c5d39aca6610193343f6efc5076c120bc4b6f0748f029867d1b77
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.8.0
|
2
|
+
|
3
|
+
- Symbolize all keys to ensure interopt. with TrailerVote ingestion, and Ruby hash defaults
|
4
|
+
- Add warning to STDERR when decoding yields a validation error (server response does not match media type)
|
5
|
+
|
1
6
|
# 0.7.0
|
2
7
|
|
3
8
|
- Guards network errors during all API calls
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# TrailerVote::Api
|
2
|
+
[](https://travis-ci.com/TrailerVote/trailervote-api-clients)
|
3
|
+
[](https://badge.fury.io/rb/trailer_vote-api)
|
4
|
+
[](https://codeclimate.com/github/TrailerVote/trailervote-api-clients/maintainability)
|
2
5
|
|
3
6
|
The TrailerVote Api gem is the official interface to communicate with the TrailerVote product service. It allows you to
|
4
7
|
keep your code simple and not deal with the HTTP suite.
|
@@ -18,7 +18,7 @@ module TrailerVote
|
|
18
18
|
# @return [Links] the links
|
19
19
|
def links
|
20
20
|
# TODO: or headers
|
21
|
-
@links ||= Links.new(data[
|
21
|
+
@links ||= Links.new(data[:_links])
|
22
22
|
end
|
23
23
|
|
24
24
|
# Decode the result via {TypeRegistry}. This also takes care of MediaTypes validation.
|
@@ -8,12 +8,13 @@ module TrailerVote
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def respond_to_missing?(method_name, include_private = false)
|
11
|
-
links.key?(
|
11
|
+
links.key?(method_name) || super
|
12
12
|
end
|
13
13
|
|
14
14
|
def method_missing(method_name, *arguments)
|
15
|
-
|
16
|
-
|
15
|
+
link_name = method_name
|
16
|
+
if links.key?(link_name)
|
17
|
+
return call(link_name, *arguments)
|
17
18
|
end
|
18
19
|
|
19
20
|
if /[a-z_]+/.match? method_name
|
@@ -37,10 +38,10 @@ module TrailerVote
|
|
37
38
|
|
38
39
|
def call(link, **arguments)
|
39
40
|
if arguments.length.zero?
|
40
|
-
return self[link][
|
41
|
+
return self[link][:href]
|
41
42
|
end
|
42
43
|
|
43
|
-
fill_template(self[link][
|
44
|
+
fill_template(self[link][:href], **arguments)
|
44
45
|
end
|
45
46
|
|
46
47
|
def fill_template(templated, **arguments)
|
@@ -77,10 +77,14 @@ module TrailerVote
|
|
77
77
|
def define_decode(adapter, media_type)
|
78
78
|
adapter.define_singleton_method('decode') do |str|
|
79
79
|
begin
|
80
|
-
Oj.load(str, mode: :strict).tap do |result|
|
81
|
-
|
80
|
+
Oj.load(str, mode: :strict, symbol_keys: true).tap do |result|
|
81
|
+
begin
|
82
|
+
media_type.validate!(result)
|
83
|
+
rescue ::MediaTypes::Scheme::ValidationError => err
|
84
|
+
warn format('Decode error! API might now be in an invalid or incomplete state. %<err>s', err: err)
|
85
|
+
end
|
82
86
|
end
|
83
|
-
rescue Oj::Error
|
87
|
+
rescue Oj::Error => err
|
84
88
|
raise DecodeError.new(media_type: media_type, source: err)
|
85
89
|
end
|
86
90
|
end
|