trailer_vote-api 3.0.3 → 3.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 671a01b7b669d2495c6a3fc31441a367de6e789ea06e9fd49aebf5477da12010
4
- data.tar.gz: a3965c94b0ff1564257448ff025263926c9be645f751cd345ecc16f4dcff1947
3
+ metadata.gz: ffccb405ec69e5cb2f85fdc6bec5b629667d9ad4d4cb14030db0952fafc13a23
4
+ data.tar.gz: 5659979cd40ebb822a2b7eb01975490b05af87f4403e4cc69a90333a655f3ab0
5
5
  SHA512:
6
- metadata.gz: 86a0c3522ab245a902478168f43b9d882be92ae8a02ab603c55586e30262abb64b632ad05a3b860c7201812ffcb5e9f43f142a41be9ee32be4f228f3bf914f7c
7
- data.tar.gz: 7f1a11dc470339dd3aab217f6680813a5dc4d50a930eeac10dad70736e6c0d6e87e60fb35f163990d83584b0804040032164fce88f0448851cf470c7559e8a70
6
+ metadata.gz: bc09c0745b73c5497dc6ca98521d359a95de307f2e38a1826930b1cc931eddfadbb43c750ff1d6aaf83d03ed1a794259caaa7a27cda34bf5cf5b361bb60ea412
7
+ data.tar.gz: cecc15619cbd422d7713036a8b743229970fe76481a777cf90df7c05ddbf5f8a10702548cf2920892b49adffc3d2dec6e34c1d6d1541d168ea859edf232fbec4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trailer_vote-api (3.0.3)
4
+ trailer_vote-api (3.1.0)
5
5
  http (>= 3.3.0, <= 4.1.1)
6
6
  oj (>= 3.6, < 4.x)
7
7
  trailer_vote-media_types (~> 3.0)
@@ -29,7 +29,7 @@ GEM
29
29
  domain_name (~> 0.5)
30
30
  http-form_data (2.3.0)
31
31
  http_parser.rb (0.6.0)
32
- media_types (2.0.0)
32
+ media_types (2.0.1)
33
33
  minitest (5.14.0)
34
34
  minitest-ci (3.4.0)
35
35
  minitest (>= 5.0.6)
@@ -38,7 +38,7 @@ GEM
38
38
  builder
39
39
  minitest (>= 5.0)
40
40
  ruby-progressbar
41
- oj (3.10.6)
41
+ oj (3.10.7)
42
42
  public_suffix (4.0.3)
43
43
  rake (13.0.1)
44
44
  ruby-progressbar (1.10.1)
@@ -47,7 +47,7 @@ GEM
47
47
  docile (~> 1.1)
48
48
  simplecov-html (~> 0.11)
49
49
  simplecov-html (0.12.2)
50
- trailer_vote-media_types (3.0.1)
50
+ trailer_vote-media_types (3.0.4)
51
51
  media_types (>= 2.0.0, < 3)
52
52
  unf (0.1.4)
53
53
  unf_ext
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'trailer_vote/api'
5
+ require 'trailer_vote/api/autoload'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -3,6 +3,7 @@
3
3
  # require 'httpx'
4
4
  # HTTP_KLAZZ = HTTPX.plugin(:compression, :basic_authentication)
5
5
  require 'http'
6
+ require 'json'
6
7
  HTTP_KLAZZ = HTTP.use(:auto_inflate)
7
8
 
8
9
  require 'trailer_vote/api/version'
@@ -17,9 +18,12 @@ module TrailerVote
17
18
 
18
19
  def decode(result)
19
20
  begin
20
- Oj.load(result, mode: :strict, symbol_keys: true)
21
+ #Oj.load(result, mode: :strict, symbol_keys: true)
22
+ JSON.parse(result, {symbolize_names: true})
21
23
  rescue Oj::Error => err
22
24
  raise DecodeError.new(media_type: media_type, source: err)
25
+ rescue JSON::JSONError => err
26
+ raise DecodeError.new(media_type: media_type, source: err)
23
27
  end
24
28
  end
25
29
 
@@ -10,6 +10,7 @@ require 'trailer_vote/api/place/children'
10
10
  require 'trailer_vote/api/place/children/urls'
11
11
  require 'trailer_vote/api/place/create'
12
12
  require 'trailer_vote/api/place/find'
13
+ require 'trailer_vote/api/place/lookup'
13
14
  require 'trailer_vote/api/product'
14
15
  require 'trailer_vote/api/product/create'
15
16
  require 'trailer_vote/api/product/find'
@@ -16,7 +16,7 @@ module TrailerVote
16
16
  class Configuration
17
17
  include Composable::Get
18
18
 
19
- SUCCESS = MediaTypes::Configuration.to_constructable.version(2)
19
+ SUCCESS = MediaTypes::Configuration.to_constructable.version(5)
20
20
  FAILURE = MediaTypes::Errors.to_constructable.version(1)
21
21
 
22
22
  ACCEPT = [SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'trailer_vote/api/composable/common'
4
+
5
+ require 'trailer_vote/api/place'
6
+ require 'trailer_vote/api/place/find'
7
+
8
+ module TrailerVote
9
+ module Api
10
+
11
+ class Configuration
12
+ # @return [TrailerVote::Api::Place::Lookup] api to deal with looking up a place
13
+ def place_lookup
14
+ Place::Lookup.new(configuration: self)
15
+ end
16
+ end
17
+
18
+ class Place
19
+
20
+ # @return [TrailerVote::Api::Place::Lookup] api to deal with looking up a place
21
+ def lookup
22
+ Lookup.new(configuration: configuration)
23
+ end
24
+
25
+ ##
26
+ # Looks up a place by a concatenated authority and identifier string
27
+ #
28
+ # @example lookup a place by vista authority
29
+ #
30
+ # result = TrailerVote::Api.configure(...).place.lookup.call(url: '')
31
+ # result.place
32
+ # # => { "title": "" }
33
+ #
34
+ class Lookup
35
+ include Composable::Common
36
+
37
+ SUCCESS = MediaTypes::Place.to_constructable.version(2)
38
+ FAILURE = MediaTypes::Errors.to_constructable.version(1)
39
+
40
+ ACCEPT = [SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
41
+
42
+ def initialize(configuration:)
43
+ self.configuration = configuration
44
+ end
45
+
46
+ # @return [TrailerVote::Api::Place] api to deal with places
47
+ def back
48
+ configuration.place
49
+ end
50
+
51
+ def call(authority:, identifier:)
52
+ url = resolve_url(authority: authority, identifier: identifier)
53
+ guard_network_errors do
54
+ branch(
55
+ resolve_client.headers(Headers::ACCEPT => ACCEPT).get(url, body: nil)
56
+ )
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ def resolve_url(authority:, identifier:)
63
+ configuration.links.lookup(authority: authority, identifier: identifier)
64
+ end
65
+
66
+ def redirect_klazz
67
+ Find
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TrailerVote
4
4
  module Api
5
- VERSION = '3.0.3'
5
+ VERSION = '3.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailer_vote-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derk-Jan Karrenbeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-10 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -208,6 +208,7 @@ files:
208
208
  - lib/trailer_vote/api/place/children/urls.rb
209
209
  - lib/trailer_vote/api/place/create.rb
210
210
  - lib/trailer_vote/api/place/find.rb
211
+ - lib/trailer_vote/api/place/lookup.rb
211
212
  - lib/trailer_vote/api/product.rb
212
213
  - lib/trailer_vote/api/product/create.rb
213
214
  - lib/trailer_vote/api/product/find.rb
@@ -253,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
254
  - !ruby/object:Gem::Version
254
255
  version: '0'
255
256
  requirements: []
256
- rubygems_version: 3.0.3
257
+ rubygems_version: 3.1.2
257
258
  signing_key:
258
259
  specification_version: 4
259
260
  summary: Provides a client to interact with the TrailerVote API