trailer_vote-api 0.8.4 → 0.9.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 +5 -5
- data/.gitignore +13 -13
- data/.rubocop.yml +29 -29
- data/CHANGELOG.md +56 -56
- data/Gemfile +6 -6
- data/Gemfile.lock +10 -11
- data/README.md +188 -188
- data/Rakefile +12 -12
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/lib/trailer_vote/api.rb +43 -43
- data/lib/trailer_vote/api/autoload.rb +24 -22
- data/lib/trailer_vote/api/composable/common.rb +91 -91
- data/lib/trailer_vote/api/composable/get.rb +66 -66
- data/lib/trailer_vote/api/configuration.rb +71 -71
- data/lib/trailer_vote/api/errors.rb +115 -115
- data/lib/trailer_vote/api/fallback_content_types.rb +50 -50
- data/lib/trailer_vote/api/issue.rb +31 -31
- data/lib/trailer_vote/api/issue/create.rb +72 -72
- data/lib/trailer_vote/api/issue/find.rb +42 -42
- data/lib/trailer_vote/api/links.rb +54 -54
- data/lib/trailer_vote/api/place.rb +24 -24
- data/lib/trailer_vote/api/place/children.rb +33 -0
- data/lib/trailer_vote/api/place/children/urls.rb +67 -0
- data/lib/trailer_vote/api/place/create.rb +83 -83
- data/lib/trailer_vote/api/place/find.rb +60 -59
- data/lib/trailer_vote/api/product.rb +33 -33
- data/lib/trailer_vote/api/product/create.rb +63 -63
- data/lib/trailer_vote/api/product/find.rb +55 -55
- data/lib/trailer_vote/api/product/image.rb +38 -38
- data/lib/trailer_vote/api/product/image/create.rb +83 -83
- data/lib/trailer_vote/api/product/image/find.rb +54 -54
- data/lib/trailer_vote/api/product/image/urls.rb +66 -66
- data/lib/trailer_vote/api/product/lookup.rb +97 -97
- data/lib/trailer_vote/api/product/place.rb +40 -40
- data/lib/trailer_vote/api/product/place/link.rb +75 -75
- data/lib/trailer_vote/api/product/update.rb +80 -80
- data/lib/trailer_vote/api/product/video.rb +38 -38
- data/lib/trailer_vote/api/product/video/create.rb +80 -80
- data/lib/trailer_vote/api/product/video/find.rb +56 -56
- data/lib/trailer_vote/api/product/video/urls.rb +66 -66
- data/lib/trailer_vote/api/type_registry.rb +99 -99
- data/lib/trailer_vote/api/version.rb +7 -7
- data/trailer_vote-api.gemspec +45 -45
- metadata +7 -6
@@ -1,31 +1,31 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'trailer_vote/media_types'
|
4
|
-
require 'trailer_vote/api/configuration'
|
5
|
-
|
6
|
-
module TrailerVote
|
7
|
-
module Api
|
8
|
-
class Configuration
|
9
|
-
# @return [TrailerVote::Api::Issue::Find] issues attached to the credentials
|
10
|
-
def issue
|
11
|
-
Issue.new(configuration: self)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class Issue
|
16
|
-
def initialize(configuration:)
|
17
|
-
self.configuration = configuration
|
18
|
-
end
|
19
|
-
|
20
|
-
def back
|
21
|
-
configuration
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
attr_accessor :configuration
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
TrailerVote::MediaTypes::Issue.register
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'trailer_vote/media_types'
|
4
|
+
require 'trailer_vote/api/configuration'
|
5
|
+
|
6
|
+
module TrailerVote
|
7
|
+
module Api
|
8
|
+
class Configuration
|
9
|
+
# @return [TrailerVote::Api::Issue::Find] issues attached to the credentials
|
10
|
+
def issue
|
11
|
+
Issue.new(configuration: self)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Issue
|
16
|
+
def initialize(configuration:)
|
17
|
+
self.configuration = configuration
|
18
|
+
end
|
19
|
+
|
20
|
+
def back
|
21
|
+
configuration
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_accessor :configuration
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
TrailerVote::MediaTypes::Issue.register
|
@@ -1,72 +1,72 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'trailer_vote/api/composable/common'
|
4
|
-
require 'trailer_vote/api/issue'
|
5
|
-
require 'trailer_vote/api/issue/find'
|
6
|
-
|
7
|
-
module TrailerVote
|
8
|
-
module Api
|
9
|
-
class Issue
|
10
|
-
|
11
|
-
def create
|
12
|
-
Create.new(configuration: configuration)
|
13
|
-
end
|
14
|
-
|
15
|
-
class Create
|
16
|
-
include Composable::Common
|
17
|
-
|
18
|
-
CONTENT = MediaTypes::Issue.to_constructable.version(1).view('create')
|
19
|
-
SUCCESS = MediaTypes::Issue.to_constructable.version(1)
|
20
|
-
FAILURE = MediaTypes::Errors.to_constructable.version(1)
|
21
|
-
|
22
|
-
ACCEPT = [SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
|
23
|
-
|
24
|
-
# @private
|
25
|
-
def initialize(configuration:)
|
26
|
-
self.configuration = configuration
|
27
|
-
end
|
28
|
-
|
29
|
-
def back
|
30
|
-
configuration.issue
|
31
|
-
end
|
32
|
-
|
33
|
-
# Create an issue
|
34
|
-
#
|
35
|
-
# @see https://www.rubydoc.info/gems/trailer_vote-media_types/TrailerVote/MediaTypes/Issue TrailerVote::MediaTypes::Issue
|
36
|
-
#
|
37
|
-
# @param [String, Hash] data the data conform to the Issue media type
|
38
|
-
# @param [String] url (#resolve_url result) the url to post to
|
39
|
-
#
|
40
|
-
# @return [TrailerVote::Api::Issue]
|
41
|
-
def call(data:, url: resolve_url)
|
42
|
-
guard_network_errors do
|
43
|
-
body = encode(data)
|
44
|
-
branch(
|
45
|
-
resolve_client.headers(
|
46
|
-
Headers::ACCEPT => ACCEPT,
|
47
|
-
Headers::CONTENT_TYPE => "#{CONTENT}; charset=#{body.encoding.name}"
|
48
|
-
).post(url, body: body),
|
49
|
-
data: data
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
attr_accessor :configuration
|
57
|
-
|
58
|
-
def resolve_url
|
59
|
-
configuration.links.issues
|
60
|
-
end
|
61
|
-
|
62
|
-
def encode(data)
|
63
|
-
TrailerVote::Api.encode(CONTENT, issue: data)
|
64
|
-
end
|
65
|
-
|
66
|
-
def redirect_klazz
|
67
|
-
Find
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'trailer_vote/api/composable/common'
|
4
|
+
require 'trailer_vote/api/issue'
|
5
|
+
require 'trailer_vote/api/issue/find'
|
6
|
+
|
7
|
+
module TrailerVote
|
8
|
+
module Api
|
9
|
+
class Issue
|
10
|
+
|
11
|
+
def create
|
12
|
+
Create.new(configuration: configuration)
|
13
|
+
end
|
14
|
+
|
15
|
+
class Create
|
16
|
+
include Composable::Common
|
17
|
+
|
18
|
+
CONTENT = MediaTypes::Issue.to_constructable.version(1).view('create')
|
19
|
+
SUCCESS = MediaTypes::Issue.to_constructable.version(1)
|
20
|
+
FAILURE = MediaTypes::Errors.to_constructable.version(1)
|
21
|
+
|
22
|
+
ACCEPT = [SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
|
23
|
+
|
24
|
+
# @private
|
25
|
+
def initialize(configuration:)
|
26
|
+
self.configuration = configuration
|
27
|
+
end
|
28
|
+
|
29
|
+
def back
|
30
|
+
configuration.issue
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create an issue
|
34
|
+
#
|
35
|
+
# @see https://www.rubydoc.info/gems/trailer_vote-media_types/TrailerVote/MediaTypes/Issue TrailerVote::MediaTypes::Issue
|
36
|
+
#
|
37
|
+
# @param [String, Hash] data the data conform to the Issue media type
|
38
|
+
# @param [String] url (#resolve_url result) the url to post to
|
39
|
+
#
|
40
|
+
# @return [TrailerVote::Api::Issue]
|
41
|
+
def call(data:, url: resolve_url)
|
42
|
+
guard_network_errors do
|
43
|
+
body = encode(data)
|
44
|
+
branch(
|
45
|
+
resolve_client.headers(
|
46
|
+
Headers::ACCEPT => ACCEPT,
|
47
|
+
Headers::CONTENT_TYPE => "#{CONTENT}; charset=#{body.encoding.name}"
|
48
|
+
).post(url, body: body),
|
49
|
+
data: data
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
attr_accessor :configuration
|
57
|
+
|
58
|
+
def resolve_url
|
59
|
+
configuration.links.issues
|
60
|
+
end
|
61
|
+
|
62
|
+
def encode(data)
|
63
|
+
TrailerVote::Api.encode(CONTENT, issue: data)
|
64
|
+
end
|
65
|
+
|
66
|
+
def redirect_klazz
|
67
|
+
Find
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'trailer_vote/api/composable/get'
|
4
|
-
require 'trailer_vote/api/issue'
|
5
|
-
|
6
|
-
module TrailerVote
|
7
|
-
module Api
|
8
|
-
class Issue
|
9
|
-
class Find
|
10
|
-
include Composable::Get
|
11
|
-
|
12
|
-
SUCCESS = MediaTypes::Issue.to_constructable.version(1)
|
13
|
-
FAILURE = MediaTypes::Errors.to_constructable.version(1)
|
14
|
-
|
15
|
-
ACCEPT = [SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
|
16
|
-
|
17
|
-
def initialize(configuration:, result: nil)
|
18
|
-
self.configuration = configuration
|
19
|
-
self.result = result
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [TrailerVote::Api::Configuration, TrailerVote::Api::Issue::Create]
|
23
|
-
def back
|
24
|
-
backtrack = result
|
25
|
-
backtrack = result.back while backtrack&.is_a?(self.class)
|
26
|
-
backtrack || configuration
|
27
|
-
end
|
28
|
-
|
29
|
-
def call(url: nil)
|
30
|
-
return self if ok? || !url
|
31
|
-
guard_network_errors do
|
32
|
-
branch(resolve_client.headers(Headers::ACCEPT => ACCEPT).get(url))
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def data
|
37
|
-
to_h[:issue]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'trailer_vote/api/composable/get'
|
4
|
+
require 'trailer_vote/api/issue'
|
5
|
+
|
6
|
+
module TrailerVote
|
7
|
+
module Api
|
8
|
+
class Issue
|
9
|
+
class Find
|
10
|
+
include Composable::Get
|
11
|
+
|
12
|
+
SUCCESS = MediaTypes::Issue.to_constructable.version(1)
|
13
|
+
FAILURE = MediaTypes::Errors.to_constructable.version(1)
|
14
|
+
|
15
|
+
ACCEPT = [SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze
|
16
|
+
|
17
|
+
def initialize(configuration:, result: nil)
|
18
|
+
self.configuration = configuration
|
19
|
+
self.result = result
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [TrailerVote::Api::Configuration, TrailerVote::Api::Issue::Create]
|
23
|
+
def back
|
24
|
+
backtrack = result
|
25
|
+
backtrack = result.back while backtrack&.is_a?(self.class)
|
26
|
+
backtrack || configuration
|
27
|
+
end
|
28
|
+
|
29
|
+
def call(url: nil)
|
30
|
+
return self if ok? || !url
|
31
|
+
guard_network_errors do
|
32
|
+
branch(resolve_client.headers(Headers::ACCEPT => ACCEPT).get(url))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def data
|
37
|
+
to_h[:issue]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,54 +1,54 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module TrailerVote
|
4
|
-
module Api
|
5
|
-
class Links
|
6
|
-
def initialize(links)
|
7
|
-
self.links = links
|
8
|
-
end
|
9
|
-
|
10
|
-
def respond_to_missing?(method_name, include_private = false)
|
11
|
-
links.key?(method_name) || super
|
12
|
-
end
|
13
|
-
|
14
|
-
def method_missing(method_name, *arguments)
|
15
|
-
link_name = method_name
|
16
|
-
if links.key?(link_name)
|
17
|
-
return call(link_name, *arguments)
|
18
|
-
end
|
19
|
-
|
20
|
-
if /[a-z_]+/.match? method_name
|
21
|
-
raise ArgumentError, format(
|
22
|
-
'Unknown link %<link>s. Available: %<links>s',
|
23
|
-
link: method_name,
|
24
|
-
links: links.keys
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
super
|
29
|
-
end
|
30
|
-
|
31
|
-
def [](key)
|
32
|
-
links.fetch(key)
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
attr_accessor :links
|
38
|
-
|
39
|
-
def call(link, **arguments)
|
40
|
-
if arguments.length.zero?
|
41
|
-
return self[link][:href]
|
42
|
-
end
|
43
|
-
|
44
|
-
fill_template(self[link][:href], **arguments)
|
45
|
-
end
|
46
|
-
|
47
|
-
def fill_template(templated, **arguments)
|
48
|
-
arguments.each_with_object(templated) do |(variable, value), result|
|
49
|
-
result.gsub!("{#{variable}}", value)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TrailerVote
|
4
|
+
module Api
|
5
|
+
class Links
|
6
|
+
def initialize(links)
|
7
|
+
self.links = links
|
8
|
+
end
|
9
|
+
|
10
|
+
def respond_to_missing?(method_name, include_private = false)
|
11
|
+
links.key?(method_name) || super
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(method_name, *arguments)
|
15
|
+
link_name = method_name
|
16
|
+
if links.key?(link_name)
|
17
|
+
return call(link_name, *arguments)
|
18
|
+
end
|
19
|
+
|
20
|
+
if /[a-z_]+/.match? method_name
|
21
|
+
raise ArgumentError, format(
|
22
|
+
'Unknown link %<link>s. Available: %<links>s',
|
23
|
+
link: method_name,
|
24
|
+
links: links.keys
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](key)
|
32
|
+
links.fetch(key)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
attr_accessor :links
|
38
|
+
|
39
|
+
def call(link, **arguments)
|
40
|
+
if arguments.length.zero?
|
41
|
+
return self[link][:href]
|
42
|
+
end
|
43
|
+
|
44
|
+
fill_template(self[link][:href], **arguments)
|
45
|
+
end
|
46
|
+
|
47
|
+
def fill_template(templated, **arguments)
|
48
|
+
arguments.each_with_object(templated) do |(variable, value), result|
|
49
|
+
result.gsub!("{#{variable}}", value)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'trailer_vote/media_types'
|
4
|
-
require 'trailer_vote/api/configuration'
|
5
|
-
|
6
|
-
module TrailerVote
|
7
|
-
module Api
|
8
|
-
class Place
|
9
|
-
def initialize(configuration:)
|
10
|
-
self.configuration = configuration
|
11
|
-
end
|
12
|
-
|
13
|
-
def back
|
14
|
-
configuration
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_accessor :configuration
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
TrailerVote::MediaTypes::Place.register
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'trailer_vote/media_types'
|
4
|
+
require 'trailer_vote/api/configuration'
|
5
|
+
|
6
|
+
module TrailerVote
|
7
|
+
module Api
|
8
|
+
class Place
|
9
|
+
def initialize(configuration:)
|
10
|
+
self.configuration = configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def back
|
14
|
+
configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_accessor :configuration
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
TrailerVote::MediaTypes::Place.register
|