trailer_vote-api 2.2.2 → 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 +4 -4
- data/Gemfile.lock +6 -6
- data/bin/console +1 -1
- data/lib/trailer_vote/api.rb +23 -2
- data/lib/trailer_vote/api/autoload.rb +1 -0
- data/lib/trailer_vote/api/configuration.rb +1 -3
- data/lib/trailer_vote/api/errors.rb +0 -2
- data/lib/trailer_vote/api/issue.rb +0 -2
- data/lib/trailer_vote/api/place.rb +0 -2
- data/lib/trailer_vote/api/place/lookup.rb +72 -0
- data/lib/trailer_vote/api/product.rb +0 -2
- data/lib/trailer_vote/api/product/image.rb +0 -2
- data/lib/trailer_vote/api/product/lookup.rb +0 -2
- data/lib/trailer_vote/api/product/place.rb +0 -2
- data/lib/trailer_vote/api/product/video.rb +0 -2
- data/lib/trailer_vote/api/push_recipe_android.rb +0 -2
- data/lib/trailer_vote/api/push_recipe_ios.rb +0 -2
- data/lib/trailer_vote/api/type_registry.rb +4 -8
- data/lib/trailer_vote/api/version.rb +1 -1
- data/lib/trailer_vote/api/vista_config.rb +1 -3
- data/trailer_vote-api.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffccb405ec69e5cb2f85fdc6bec5b629667d9ad4d4cb14030db0952fafc13a23
|
4
|
+
data.tar.gz: 5659979cd40ebb822a2b7eb01975490b05af87f4403e4cc69a90333a655f3ab0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc09c0745b73c5497dc6ca98521d359a95de307f2e38a1826930b1cc931eddfadbb43c750ff1d6aaf83d03ed1a794259caaa7a27cda34bf5cf5b361bb60ea412
|
7
|
+
data.tar.gz: cecc15619cbd422d7713036a8b743229970fe76481a777cf90df7c05ddbf5f8a10702548cf2920892b49adffc3d2dec6e34c1d6d1541d168ea859edf232fbec4
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
trailer_vote-api (
|
4
|
+
trailer_vote-api (3.1.0)
|
5
5
|
http (>= 3.3.0, <= 4.1.1)
|
6
6
|
oj (>= 3.6, < 4.x)
|
7
|
-
trailer_vote-media_types (~>
|
7
|
+
trailer_vote-media_types (~> 3.0)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -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 (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.
|
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,8 +47,8 @@ GEM
|
|
47
47
|
docile (~> 1.1)
|
48
48
|
simplecov-html (~> 0.11)
|
49
49
|
simplecov-html (0.12.2)
|
50
|
-
trailer_vote-media_types (
|
51
|
-
media_types (>= 0.
|
50
|
+
trailer_vote-media_types (3.0.4)
|
51
|
+
media_types (>= 2.0.0, < 3)
|
52
52
|
unf (0.1.4)
|
53
53
|
unf_ext
|
54
54
|
unf_ext (0.0.7.7)
|
data/bin/console
CHANGED
@@ -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.
|
data/lib/trailer_vote/api.rb
CHANGED
@@ -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'
|
@@ -16,11 +17,18 @@ module TrailerVote
|
|
16
17
|
module_function
|
17
18
|
|
18
19
|
def decode(result)
|
19
|
-
|
20
|
+
begin
|
21
|
+
#Oj.load(result, mode: :strict, symbol_keys: true)
|
22
|
+
JSON.parse(result, {symbolize_names: true})
|
23
|
+
rescue Oj::Error => err
|
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)
|
27
|
+
end
|
20
28
|
end
|
21
29
|
|
22
30
|
def encode(media_type, data)
|
23
|
-
|
31
|
+
Oj.dump(data, mode: :compat)
|
24
32
|
end
|
25
33
|
|
26
34
|
def default_unauthenticated_client
|
@@ -42,5 +50,18 @@ module TrailerVote
|
|
42
50
|
IF_MATCH = 'If-Match'
|
43
51
|
USER_AGENT = 'User-Agent'
|
44
52
|
end
|
53
|
+
|
54
|
+
TypeRegistry.register(MediaTypes::Configuration)
|
55
|
+
TypeRegistry.register(MediaTypes::Errors)
|
56
|
+
TypeRegistry.register(MediaTypes::Issue)
|
57
|
+
TypeRegistry.register(MediaTypes::Place)
|
58
|
+
TypeRegistry.register(MediaTypes::Product)
|
59
|
+
TypeRegistry.register(MediaTypes::ProductImage)
|
60
|
+
TypeRegistry.register(MediaTypes::ProductLookup)
|
61
|
+
TypeRegistry.register(MediaTypes::ProductPlaceLink)
|
62
|
+
TypeRegistry.register(MediaTypes::ProductVideo)
|
63
|
+
TypeRegistry.register(MediaTypes::PushRecipeAndroid)
|
64
|
+
TypeRegistry.register(MediaTypes::PushRecipeIos)
|
65
|
+
TypeRegistry.register(MediaTypes::VistaConfig)
|
45
66
|
end
|
46
67
|
end
|
@@ -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(
|
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
|
@@ -67,5 +67,3 @@ module TrailerVote
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
71
|
-
TrailerVote::MediaTypes::Configuration.register
|
@@ -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
|
@@ -34,10 +34,10 @@ module TrailerVote
|
|
34
34
|
def register(registerable)
|
35
35
|
mime_type = registerable.to_s
|
36
36
|
|
37
|
-
self[mime_type] = AdapterFor(registerable
|
38
|
-
shortcut(mime_type, registerable.
|
37
|
+
self[mime_type] = AdapterFor(registerable)
|
38
|
+
shortcut(mime_type, registerable.to_s)
|
39
39
|
|
40
|
-
registerable.
|
40
|
+
registerable.available_validations.each do |alias_mime_type|
|
41
41
|
shortcut(mime_type, alias_mime_type)
|
42
42
|
end
|
43
43
|
end
|
@@ -47,7 +47,7 @@ module TrailerVote
|
|
47
47
|
|
48
48
|
# noinspection RubyClassMethodNamingConvention
|
49
49
|
def AdapterFor(media_type) # rubocop:disable Naming/MethodName
|
50
|
-
adapter_name = generate_adapter_name(media_type)
|
50
|
+
adapter_name = generate_adapter_name(media_type.identifier)
|
51
51
|
|
52
52
|
if const_defined?(adapter_name)
|
53
53
|
return const_get(adapter_name)
|
@@ -93,7 +93,3 @@ module TrailerVote
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
96
|
-
|
97
|
-
module MediaTypes
|
98
|
-
integrate TrailerVote::Api::TypeRegistry
|
99
|
-
end
|
@@ -9,7 +9,7 @@ module TrailerVote
|
|
9
9
|
|
10
10
|
attr_accessor :client
|
11
11
|
|
12
|
-
SUCCESS = MediaTypes::VistaConfig.to_constructable.version(1).view(:
|
12
|
+
SUCCESS = MediaTypes::VistaConfig.to_constructable.version(1).view(:collection)
|
13
13
|
FAILURE = MediaTypes::Errors.to_constructable.version(1)
|
14
14
|
ACCEPT = [SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
|
15
15
|
|
@@ -35,5 +35,3 @@ module TrailerVote
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
|
-
TrailerVote::MediaTypes::VistaConfig.register
|
data/trailer_vote-api.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
# spec.add_runtime_dependency 'httpx'
|
33
33
|
spec.add_runtime_dependency 'http', '>= 3.3.0', '<= 4.1.1'
|
34
34
|
spec.add_runtime_dependency 'oj', '>= 3.6', '< 4.x'
|
35
|
-
spec.add_runtime_dependency 'trailer_vote-media_types', '~>
|
35
|
+
spec.add_runtime_dependency 'trailer_vote-media_types', '~> 3.0'
|
36
36
|
|
37
37
|
spec.add_development_dependency 'awesome_print', '~> 1.8'
|
38
38
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
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:
|
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-
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: '3.0'
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: '3.0'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: awesome_print
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.
|
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
|