trailer_vote-api 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 +7 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +29 -0
- data/CHANGELOG.md +56 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +77 -0
- data/README.md +188 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/trailer_vote/api.rb +67 -0
- data/lib/trailer_vote/api/autoload.rb +28 -0
- data/lib/trailer_vote/api/composable/common.rb +91 -0
- data/lib/trailer_vote/api/composable/get.rb +66 -0
- data/lib/trailer_vote/api/configuration.rb +69 -0
- data/lib/trailer_vote/api/errors.rb +113 -0
- data/lib/trailer_vote/api/fallback_content_types.rb +50 -0
- data/lib/trailer_vote/api/issue.rb +29 -0
- data/lib/trailer_vote/api/issue/create.rb +72 -0
- data/lib/trailer_vote/api/issue/find.rb +42 -0
- data/lib/trailer_vote/api/links.rb +54 -0
- data/lib/trailer_vote/api/place.rb +22 -0
- 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 -0
- data/lib/trailer_vote/api/place/find.rb +60 -0
- data/lib/trailer_vote/api/place/lookup.rb +72 -0
- data/lib/trailer_vote/api/product.rb +31 -0
- data/lib/trailer_vote/api/product/create.rb +63 -0
- data/lib/trailer_vote/api/product/find.rb +55 -0
- data/lib/trailer_vote/api/product/image.rb +36 -0
- data/lib/trailer_vote/api/product/image/create.rb +83 -0
- data/lib/trailer_vote/api/product/image/find.rb +54 -0
- data/lib/trailer_vote/api/product/image/urls.rb +66 -0
- data/lib/trailer_vote/api/product/lookup.rb +95 -0
- data/lib/trailer_vote/api/product/place.rb +38 -0
- data/lib/trailer_vote/api/product/place/link.rb +75 -0
- data/lib/trailer_vote/api/product/update.rb +80 -0
- data/lib/trailer_vote/api/product/video.rb +36 -0
- data/lib/trailer_vote/api/product/video/create.rb +80 -0
- data/lib/trailer_vote/api/product/video/find.rb +56 -0
- data/lib/trailer_vote/api/product/video/urls.rb +66 -0
- data/lib/trailer_vote/api/push_recipe_android.rb +37 -0
- data/lib/trailer_vote/api/push_recipe_ios.rb +37 -0
- data/lib/trailer_vote/api/type_registry.rb +95 -0
- data/lib/trailer_vote/api/version.rb +7 -0
- data/lib/trailer_vote/api/vista_config.rb +37 -0
- data/trailer_vote-api.gemspec +45 -0
- metadata +261 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ffccb405ec69e5cb2f85fdc6bec5b629667d9ad4d4cb14030db0952fafc13a23
|
4
|
+
data.tar.gz: 5659979cd40ebb822a2b7eb01975490b05af87f4403e4cc69a90333a655f3ab0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc09c0745b73c5497dc6ca98521d359a95de307f2e38a1826930b1cc931eddfadbb43c750ff1d6aaf83d03ed1a794259caaa7a27cda34bf5cf5b361bb60ea412
|
7
|
+
data.tar.gz: cecc15619cbd422d7713036a8b743229970fe76481a777cf90df7c05ddbf5f8a10702548cf2920892b49adffc3d2dec6e34c1d6d1541d168ea859edf232fbec4
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- '**/Rakefile'
|
4
|
+
- 'lib/**/*.rb'
|
5
|
+
Exclude:
|
6
|
+
- 'Gemfile'
|
7
|
+
- 'bin/**/*'
|
8
|
+
TargetRubyVersion: 2.4
|
9
|
+
|
10
|
+
Layout/EmptyLinesAroundClassBody:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Layout/EndOfLine:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/LineLength:
|
17
|
+
Max: 120
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Max: 15
|
21
|
+
|
22
|
+
Style/Documentation:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/EmptyMethod:
|
26
|
+
EnforcedStyle: expanded
|
27
|
+
|
28
|
+
Style/IfUnlessModifier:
|
29
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# 0.8.4
|
2
|
+
|
3
|
+
- Add `#inspect` and `#to_s` to response errors
|
4
|
+
- Add `#status` and `#to_i` to response errors
|
5
|
+
- Add `UnprocessibleEntity` as defined response error (`ClientError`)
|
6
|
+
|
7
|
+
# 0.8.3
|
8
|
+
|
9
|
+
- Add `Issue` media create API
|
10
|
+
|
11
|
+
# 0.8.2
|
12
|
+
|
13
|
+
- Add a fallback if the `errors` is decoded correctly, but not the correct format.
|
14
|
+
|
15
|
+
# 0.8.1
|
16
|
+
|
17
|
+
- Add a fallback if the `errors` key does not exist for error messages
|
18
|
+
- Fix decoding error messages (use symbol instead of string)
|
19
|
+
|
20
|
+
# 0.8.0
|
21
|
+
|
22
|
+
- Symbolize all keys to ensure interopt. with TrailerVote ingestion, and Ruby hash defaults
|
23
|
+
- Add warning to STDERR when decoding yields a validation error (server response does not match media type)
|
24
|
+
|
25
|
+
# 0.7.0
|
26
|
+
|
27
|
+
- Guards network errors during all API calls
|
28
|
+
- Add `NetworkError` and the subclasses `TimeoutError`, `ConnectionError`
|
29
|
+
- Add `back` links to most API calls
|
30
|
+
- Add `MediaTypeUnknown` error for decoding (and encoding) unknown media types
|
31
|
+
- Add `application/json` fallback support for hostile server responses
|
32
|
+
- Add `text/html` fallback support
|
33
|
+
- Fix a bug with a missing `product` attribute
|
34
|
+
- Fix an unsupported media type causing `ErrorsResponse` to break
|
35
|
+
|
36
|
+
# 0.6.1
|
37
|
+
|
38
|
+
- Always coerce body into string first because `Oj` might choke on chunked body.
|
39
|
+
|
40
|
+
# 0.6.0
|
41
|
+
|
42
|
+
- Add error classes for common errors
|
43
|
+
- Add error message decoding from server (and pass onto error message)
|
44
|
+
|
45
|
+
# 0.5.2
|
46
|
+
|
47
|
+
- Fix a bug with the `media_types` integration
|
48
|
+
|
49
|
+
# 0.5.1
|
50
|
+
|
51
|
+
- Loosen Gem dependency versions to allow any minor update, except for dogfooded gems, which are allowed major updates, until they hit 1.0.0
|
52
|
+
- Add metadata urls for gemspec
|
53
|
+
|
54
|
+
# 0.5.0
|
55
|
+
|
56
|
+
:baby: Initial public release
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
trailer_vote-api (3.1.0)
|
5
|
+
http (>= 3.3.0, <= 4.1.1)
|
6
|
+
oj (>= 3.6, < 4.x)
|
7
|
+
trailer_vote-media_types (~> 3.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.7.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
14
|
+
ansi (1.5.0)
|
15
|
+
awesome_print (1.8.0)
|
16
|
+
builder (3.2.4)
|
17
|
+
crack (0.4.3)
|
18
|
+
safe_yaml (~> 1.0.0)
|
19
|
+
docile (1.3.2)
|
20
|
+
domain_name (0.5.20190701)
|
21
|
+
unf (>= 0.0.5, < 1.0.0)
|
22
|
+
hashdiff (1.0.1)
|
23
|
+
http (4.1.1)
|
24
|
+
addressable (~> 2.3)
|
25
|
+
http-cookie (~> 1.0)
|
26
|
+
http-form_data (~> 2.0)
|
27
|
+
http_parser.rb (~> 0.6.0)
|
28
|
+
http-cookie (1.0.3)
|
29
|
+
domain_name (~> 0.5)
|
30
|
+
http-form_data (2.3.0)
|
31
|
+
http_parser.rb (0.6.0)
|
32
|
+
media_types (2.0.1)
|
33
|
+
minitest (5.14.0)
|
34
|
+
minitest-ci (3.4.0)
|
35
|
+
minitest (>= 5.0.6)
|
36
|
+
minitest-reporters (1.4.2)
|
37
|
+
ansi
|
38
|
+
builder
|
39
|
+
minitest (>= 5.0)
|
40
|
+
ruby-progressbar
|
41
|
+
oj (3.10.7)
|
42
|
+
public_suffix (4.0.3)
|
43
|
+
rake (13.0.1)
|
44
|
+
ruby-progressbar (1.10.1)
|
45
|
+
safe_yaml (1.0.5)
|
46
|
+
simplecov (0.18.5)
|
47
|
+
docile (~> 1.1)
|
48
|
+
simplecov-html (~> 0.11)
|
49
|
+
simplecov-html (0.12.2)
|
50
|
+
trailer_vote-media_types (3.0.4)
|
51
|
+
media_types (>= 2.0.0, < 3)
|
52
|
+
unf (0.1.4)
|
53
|
+
unf_ext
|
54
|
+
unf_ext (0.0.7.7)
|
55
|
+
unf_ext (0.0.7.7-x64-mingw32)
|
56
|
+
webmock (3.8.3)
|
57
|
+
addressable (>= 2.3.6)
|
58
|
+
crack (>= 0.3.2)
|
59
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
x64-mingw32
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
awesome_print (~> 1.8)
|
67
|
+
bundler (~> 1.16)
|
68
|
+
minitest (~> 5.11)
|
69
|
+
minitest-ci (~> 3.4)
|
70
|
+
minitest-reporters (~> 1.3)
|
71
|
+
rake (~> 13.0)
|
72
|
+
simplecov (~> 0.16)
|
73
|
+
trailer_vote-api!
|
74
|
+
webmock (~> 3.4)
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
1.17.3
|
data/README.md
ADDED
@@ -0,0 +1,188 @@
|
|
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)
|
5
|
+
[](https://depfu.com/github/TrailerVote/trailervote-api-clients?project_id=5890)
|
6
|
+
|
7
|
+
The TrailerVote Api gem is the official interface to communicate with the TrailerVote product service. It allows you to
|
8
|
+
keep your code simple and not deal with the HTTP suite.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'trailer_vote-api'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install trailer_vote-api
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
By default only the configuration api calls are available and you need to require which ever calls you want to make. A call always loads it dependencies. If you want to load everything you can `require 'trailer_vote/api/autoload'`.
|
29
|
+
|
30
|
+
In order to call any of the APIs, you need to configure the api first:
|
31
|
+
```Ruby
|
32
|
+
key = '<TrailerVote API Client key>'
|
33
|
+
secret = '<TrailerVote API Client secret>'
|
34
|
+
url = '<TrailerVote API environment url>'
|
35
|
+
|
36
|
+
configuration = TrailerVote::Api.configure(url: url, key: key, secret: secret)
|
37
|
+
# => TrailerVote::Api::Configuration
|
38
|
+
```
|
39
|
+
|
40
|
+
The TrailerVote API Client for Ruby uses a lazy chainable API and does **NOT** make any requests until it's absolutely necessary.
|
41
|
+
It is recommended that you re-use the configuration instance, as well as other results, in order to reduce network requests.
|
42
|
+
|
43
|
+
The common interface is:
|
44
|
+
- `#call(*args)`: Make the call and return an object that has results
|
45
|
+
- `#data`: Return the inner data (`#to_h`) without the wrapping key
|
46
|
+
- `#to_i`: Return the HTTP status code
|
47
|
+
- `#to_h`: Return the response (`#call`), parsed (if parsable, like JSON) and validated (according to the media type)
|
48
|
+
- `#etag`: Return the HTTP ETag header value, if any
|
49
|
+
- `#links`: Return the HTTP Link header / inner `_links` as `Links` object
|
50
|
+
|
51
|
+
Unless data is being posted, `#call` is not necessary:
|
52
|
+
|
53
|
+
```Ruby
|
54
|
+
configuration = TrailerVote::Api.configure(url: url, key: key, secret: secret)
|
55
|
+
configuration.links
|
56
|
+
# => TrailerVote::Api::Links # Makes the HTTP call if necessary
|
57
|
+
```
|
58
|
+
|
59
|
+
In case of an error, a `TrailerVote::Api::Error` is raised, with subclasses defining what went wrong. If the API gives back an error (HTTP status `(400..599)`), the error is parsed and turned into a `ErrorsResponse < Error` error.
|
60
|
+
|
61
|
+
## Interface
|
62
|
+
|
63
|
+
Only the call available to the current link in the chain, if `required` are available on each object.
|
64
|
+
|
65
|
+
### `configuration`
|
66
|
+
You don't need to require this, it's always loaded.
|
67
|
+
|
68
|
+
```Ruby
|
69
|
+
require 'trailer_vote/api/configuration'
|
70
|
+
|
71
|
+
configuration = TrailerVote::Api.configure(key: '', secret: '', url: '')
|
72
|
+
# => TrailerVote::Api::Configuration
|
73
|
+
```
|
74
|
+
|
75
|
+
### `configuration.product.lookup`
|
76
|
+
Used to lookup products by authority:identifier pairs. If found, returns the actual `Product::Find`.
|
77
|
+
|
78
|
+
The `data` argument is wrapped in `{ product_identifiers: data }` and then needs to match `application/vnd.trailervote.product.lookup.v1+json`
|
79
|
+
|
80
|
+
```Ruby
|
81
|
+
require 'trailer_vote/api/product/lookup'
|
82
|
+
|
83
|
+
lookup = configuration.product.lookup
|
84
|
+
# => TrailerVote::Api::Product::Lookup
|
85
|
+
|
86
|
+
lookup.call(data: [{ authority: 'imdb', identifier: 'tt01010101' }, { authority: 'tmdb', identifier: '12345678' }])
|
87
|
+
# => TrailerVote::Api::Product::Find
|
88
|
+
```
|
89
|
+
|
90
|
+
### `configuration.product.update`
|
91
|
+
Used to update a product. Is only available on `Product::Find`, because we require updates to be non-stale, that is you need to ensure that you are the last one updating the product, so merging data can be done correctly.
|
92
|
+
|
93
|
+
The `data` argument is wrapped in `{ product: data }` and then needs to match `application/vnd.trailervote.product.v2+json`
|
94
|
+
|
95
|
+
```Ruby
|
96
|
+
require 'trailer_vote/api/product/lookup'
|
97
|
+
require 'trailer_vote/api/product/update'
|
98
|
+
|
99
|
+
lookup = configuration.product.lookup
|
100
|
+
product = lookup.call(data: [{ authority: 'imdb', identifier: 'tt01010101' }])
|
101
|
+
# => TrailerVote::Api::Product::Find
|
102
|
+
|
103
|
+
current_product_data = product.data
|
104
|
+
next_product_data = make_changes_to_product_data(current_product_data)
|
105
|
+
product.update.call(data: next_product_data)
|
106
|
+
# => TrailerVote::Api::Product::Find
|
107
|
+
```
|
108
|
+
|
109
|
+
If the update call fails with a `409 Conflict` or `412 Precondition Failed`, it means the product was updated in the meanwhile. You want to fetch the product again by doing another lookup and then running your strategy again.
|
110
|
+
|
111
|
+
### `configuration.product.create`
|
112
|
+
Creating a product is similar to looking up a product. If successful, returns an actual `Product::Find`.
|
113
|
+
|
114
|
+
The `data` argument is wrapped in `{ product: data }` and then needs to match `application/vnd.trailervote.product.v2.create+json`
|
115
|
+
|
116
|
+
```Ruby
|
117
|
+
require 'trailer_vote/api/product/create'
|
118
|
+
|
119
|
+
configuration.product.create(data: { title: 'My product', ... })
|
120
|
+
# => TrailerVote::Api::Product::Find
|
121
|
+
```
|
122
|
+
|
123
|
+
### `configuration.product.<>.video.create`
|
124
|
+
To attach an video to a product, you first need to find the product. This can be done by:
|
125
|
+
- `configuration.product.create`: creating a new product
|
126
|
+
- `configuration.product.lookup`: looking up an existing product
|
127
|
+
|
128
|
+
Once you have it, the video operations are available on the result.
|
129
|
+
|
130
|
+
The `data` argument is wrapped in `{ product_video: data }` and then needs to match `application/vnd.trailervote.product.video.v1.create+json`
|
131
|
+
|
132
|
+
```Ruby
|
133
|
+
require 'trailer_vote/api/product/lookup'
|
134
|
+
require 'trailer_vote/api/product/video/create'
|
135
|
+
|
136
|
+
product = configuration.product.lookup.call(data: [{ authority: 'imdb', identifier: 'tt01010101' }])
|
137
|
+
# => TrailerVote::Api::Product::Find
|
138
|
+
|
139
|
+
product.video.create(data: { source_url: '', ... })
|
140
|
+
# => TrailerVote::Api::Product::Video::Find
|
141
|
+
```
|
142
|
+
|
143
|
+
You can see in this example the `product` result is cached in a variable, so that if you want to create *many* videos, the product isn't looked up each call.
|
144
|
+
|
145
|
+
### `configuration.product.<>.image.urls`
|
146
|
+
Gets all the image urls for a product
|
147
|
+
|
148
|
+
### `configuration.product.<>.video.create`
|
149
|
+
To attach an video to a product, you first need to find the product. This can be done by:
|
150
|
+
- `configuration.product.create`: creating a new product
|
151
|
+
- `configuration.product.lookup`: looking up an existing product
|
152
|
+
|
153
|
+
Once you have it, the video operations are available on the result.
|
154
|
+
|
155
|
+
The `data` argument is wrapped in `{ product_video: data }` and then needs to match `application/vnd.trailervote.product.video.v1.create+json`
|
156
|
+
|
157
|
+
```Ruby
|
158
|
+
require 'trailer_vote/api/product/lookup'
|
159
|
+
require 'trailer_vote/api/product/video/create'
|
160
|
+
|
161
|
+
product = configuration.product.lookup.call(data: [{ authority: 'imdb', identifier: 'tt01010101' }])
|
162
|
+
# => TrailerVote::Api::Product::Find
|
163
|
+
|
164
|
+
product.video.create(data: { source_url: '', ... })
|
165
|
+
# => TrailerVote::Api::Product::Video::Find
|
166
|
+
```
|
167
|
+
|
168
|
+
You can see in this example the `product` result is cached in a variable, so that if you want to create *many* videos, the product isn't looked up each call.
|
169
|
+
|
170
|
+
### `configuration.product.<>.video.urls`
|
171
|
+
Gets all the image urls for a product
|
172
|
+
|
173
|
+
### `configuration.product.<>.place.link`
|
174
|
+
Links a place to a product
|
175
|
+
|
176
|
+
## Development
|
177
|
+
|
178
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
|
179
|
+
also run `bin/console` for an interactive prompt that will allow you to experiment.
|
180
|
+
|
181
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
182
|
+
version number in `version.rb`, and then run `bundle update trailer_vote-api` in any repository that depends on
|
183
|
+
this gem. If you have push rights, you may call `bundle exec rake release` to create a new git tag, push
|
184
|
+
git commits and tags, and push the `.gem` file to the rubygems gem server.
|
185
|
+
|
186
|
+
## Contributing
|
187
|
+
|
188
|
+
Bug reports and pull requests are welcome on GitHub at [TrailerVote/trailervote-api-clients](https://github.com/trailervote/trailervote-api-clients)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'trailer_vote/api/autoload'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# require 'httpx'
|
4
|
+
# HTTP_KLAZZ = HTTPX.plugin(:compression, :basic_authentication)
|
5
|
+
require 'http'
|
6
|
+
require 'json'
|
7
|
+
HTTP_KLAZZ = HTTP.use(:auto_inflate)
|
8
|
+
|
9
|
+
require 'trailer_vote/api/version'
|
10
|
+
require 'trailer_vote/api/type_registry'
|
11
|
+
require 'trailer_vote/api/fallback_content_types'
|
12
|
+
require 'trailer_vote/api/errors'
|
13
|
+
require 'trailer_vote/api/configuration'
|
14
|
+
|
15
|
+
module TrailerVote
|
16
|
+
module Api
|
17
|
+
module_function
|
18
|
+
|
19
|
+
def decode(result)
|
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
|
28
|
+
end
|
29
|
+
|
30
|
+
def encode(media_type, data)
|
31
|
+
Oj.dump(data, mode: :compat)
|
32
|
+
end
|
33
|
+
|
34
|
+
def default_unauthenticated_client
|
35
|
+
HTTP_KLAZZ.headers(
|
36
|
+
Headers::ACCEPT_ENCODING => 'gzip, deflate; q=0.5, identity; q=0.1',
|
37
|
+
Headers::USER_AGENT => format('TrailerVote/httpx.rb (client %<version>s)', version: VERSION)
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def default_client(username, password)
|
42
|
+
default_unauthenticated_client.basic_auth(user: username, pass: password)
|
43
|
+
end
|
44
|
+
|
45
|
+
module Headers
|
46
|
+
ACCEPT = 'Accept'
|
47
|
+
ACCEPT_ENCODING = 'Accept-Encoding'
|
48
|
+
CONTENT_TYPE = 'Content-Type'
|
49
|
+
ETAG = 'ETag'
|
50
|
+
IF_MATCH = 'If-Match'
|
51
|
+
USER_AGENT = 'User-Agent'
|
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)
|
66
|
+
end
|
67
|
+
end
|