apimatic_faraday_client_adapter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +26 -0
- data/README.md +53 -0
- data/lib/apimatic-faraday-client-adapter/faraday_client.rb +76 -0
- data/lib/apimatic_faraday_client_adapter.rb +4 -0
- metadata +235 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 368a4751f2a43b497174044144d8be6790b1355c19d7a837f647d874a4b78f70
|
4
|
+
data.tar.gz: 0b241473039956ab55f12bd8405453d68eda6ca18697929b9486c0a87221c1f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dbb775134ff1563f7ad9230a6fb5104469e51f9526f3c7f1b19004ea9bac5b1b9dff631263fd0da7b625de5d239b6157038240c6b29f1d323fe86a1534e76d21
|
7
|
+
data.tar.gz: 30be7348957c1c0a551d1ee66c5ab0a4802748eae4126af30b438dd3f0420d535df4d7bd51d43e73ab4905c76fad04ad2d306250900779e70af8a95491a3aef2
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
APIMATIC REFERENCE SOURCE LICENSE
|
2
|
+
|
3
|
+
This license governs the use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
|
4
|
+
|
5
|
+
1. Definitions
|
6
|
+
The terms "reproduce," "reproduction" and "distribution" have the same meaning here as under U.S. copyright law.
|
7
|
+
|
8
|
+
"You" means the licensee of the software.
|
9
|
+
|
10
|
+
"Your company" means the company you worked for when you downloaded the software.
|
11
|
+
|
12
|
+
"Reference use" means the use of the software within your company as a reference, in read-only form, for the sole purposes of debugging your products, maintaining your products, or enhancing the interoperability of your products with the software, and specifically excludes the right to distribute the software outside of your company.
|
13
|
+
|
14
|
+
"Licensed patents" means any Licensor patent claims which read directly on the software as distributed by the Licensor under this license.
|
15
|
+
|
16
|
+
2. Grant of Rights
|
17
|
+
(A) Copyright Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free copyright license to reproduce the software for reference use.
|
18
|
+
|
19
|
+
(B) Patent Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free patent license under licensed patents for reference use.
|
20
|
+
|
21
|
+
3. Limitations
|
22
|
+
(A) No Trademark License- This license does not grant you any rights to use the Licensor's name, logo, or trademarks.
|
23
|
+
|
24
|
+
(B) If you begin patent litigation against the Licensor over patents that you think may apply to the software (including a cross-claim or counterclaim in a lawsuit), your license to the software ends automatically.
|
25
|
+
|
26
|
+
(C) The software is licensed "as-is." You bear the risk of using it. The Licensor gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the Licensor excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# apimatic-faraday-client-adapter
|
2
|
+
|
3
|
+
[![Tests][test-badge]][test-url]
|
4
|
+
[![Linting][lint-badge]][lint-url]
|
5
|
+
[![Maintainability][maintainability-url]][code-climate-url]
|
6
|
+
[![Test Coverage][test-coverage-url]][code-climate-url]
|
7
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
|
8
|
+
[![Licence][license-badge]][license-url]
|
9
|
+
|
10
|
+
## Introduction
|
11
|
+
This repository contains the client implementation that uses the faraday client library for the ruby SDKs provided by APIMatic.
|
12
|
+
|
13
|
+
## Version supported
|
14
|
+
Currently APIMatic supports `2.6 <= Ruby version < 3.1` hence faraday-client-adapter will need the same versions to be supported.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
Installation is quite simple, just execute the following command:
|
18
|
+
```
|
19
|
+
gem install apimatic_faraday_client_adapter
|
20
|
+
```
|
21
|
+
|
22
|
+
If you'd rather install apimatic_faraday_client_adapter using bundler, add a line for it in your Gemfile:
|
23
|
+
```
|
24
|
+
gem 'apimatic_faraday_client_adapter'
|
25
|
+
```
|
26
|
+
|
27
|
+
## Classes
|
28
|
+
| Class | Description |
|
29
|
+
|--------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
|
30
|
+
| [`FaradayClient`](lib/apimatic-faraday-client-adapter/faraday_client.rb) | Executes an HttpRequest and converts the HTTP Response from the client to an HttpResponse object. |
|
31
|
+
|
32
|
+
|
33
|
+
## Methods
|
34
|
+
| Method | Description |
|
35
|
+
|--------------------------------------------------------------------------------|-----------------------------------------------|
|
36
|
+
| [`create_connection`](lib/apimatic-faraday-client-adapter/faraday_client.rb) | Initiates a new connection for executing the HTTP calls |
|
37
|
+
| [`execute`](lib/apimatic-faraday-client-adapter/faraday_client.rb) | Executes request with the properties set |
|
38
|
+
| [`convert_response`](lib/apimatic-faraday-client-adapter/faraday_client.rb) | Converts the Response from the HTTP client into HttpResponse object|
|
39
|
+
|
40
|
+
## Links
|
41
|
+
|
42
|
+
[//]: # (* [apimatic-core-interfaces](https://pypi.org/project/apimatic-core-interfaces/))
|
43
|
+
* [Faraday](https://rubygems.org/gems/faraday)
|
44
|
+
|
45
|
+
[test-badge]: https://github.com/apimatic/faraday-client-adapter/actions/workflows/test-runner.yml/badge.svg
|
46
|
+
[test-url]: https://github.com/apimatic/faraday-client-adapter/actions/workflows/test-runner.yml
|
47
|
+
[lint-badge]: https://github.com/apimatic/faraday-client-adapter/actions/workflows/lint-runner.yml/badge.svg
|
48
|
+
[lint-url]: https://github.com/apimatic/faraday-client-adapter/actions/workflows/lint-runner.yml
|
49
|
+
[code-climate-url]: https://codeclimate.com/github/apimatic/faraday-client-adapter
|
50
|
+
[maintainability-url]: https://api.codeclimate.com/v1/badges/59badaadebeb3478eb48/maintainability
|
51
|
+
[test-coverage-url]: https://api.codeclimate.com/v1/badges/59badaadebeb3478eb48/test_coverage
|
52
|
+
[license-badge]: https://img.shields.io/badge/licence-APIMATIC-blue
|
53
|
+
[license-url]: LICENSE
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'faraday/http_cache'
|
2
|
+
require 'faraday/retry'
|
3
|
+
require 'faraday/multipart'
|
4
|
+
require 'faraday/follow_redirects'
|
5
|
+
require 'faraday/gzip'
|
6
|
+
require 'faraday/net_http_persistent'
|
7
|
+
|
8
|
+
module CoreLibrary
|
9
|
+
# An implementation of HttpClient.
|
10
|
+
class FaradayClient < CoreLibrary::HttpClient
|
11
|
+
# The attribute readers for properties.
|
12
|
+
attr_reader :connection, :response_factory
|
13
|
+
|
14
|
+
# The constructor.
|
15
|
+
# @param [ClientConfiguration] client_configuration The configurations for the Faraday client.
|
16
|
+
def initialize(client_configuration)
|
17
|
+
@response_factory = client_configuration.response_factory
|
18
|
+
@connection = if client_configuration.connection.nil?
|
19
|
+
create_connection(client_configuration)
|
20
|
+
else
|
21
|
+
client_configuration.connection
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Method to initialize connection.
|
26
|
+
# @param [ClientConfiguration] client_configuration The configurations for the Faraday client.
|
27
|
+
def create_connection(client_configuration)
|
28
|
+
Faraday.new do |faraday|
|
29
|
+
faraday.use Faraday::HttpCache, serializer: Marshal if client_configuration.cache
|
30
|
+
faraday.use Faraday::FollowRedirects::Middleware
|
31
|
+
faraday.request :gzip
|
32
|
+
faraday.request :multipart
|
33
|
+
faraday.request :url_encoded
|
34
|
+
faraday.ssl[:ca_file] = Certifi.where
|
35
|
+
faraday.ssl[:verify] = client_configuration.verify
|
36
|
+
faraday.request :retry,
|
37
|
+
max: client_configuration.max_retries,
|
38
|
+
interval: client_configuration.retry_interval,
|
39
|
+
backoff_factor: client_configuration.backoff_factor,
|
40
|
+
retry_statuses: client_configuration.retry_statuses,
|
41
|
+
methods: client_configuration.retry_methods,
|
42
|
+
retry_if: proc { |env, _exc|
|
43
|
+
env.request.context['forced_retry'] ||= false
|
44
|
+
}
|
45
|
+
faraday.adapter client_configuration.adapter
|
46
|
+
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
47
|
+
faraday.options[:timeout] = client_configuration.timeout if client_configuration.timeout.positive?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Method overridden from HttpClient.
|
52
|
+
# @param [HttpRequest] http_request The HttpRequest to be executed.
|
53
|
+
def execute(http_request)
|
54
|
+
response = @connection.send(
|
55
|
+
http_request.http_method.downcase,
|
56
|
+
http_request.query_url
|
57
|
+
) do |request|
|
58
|
+
request.headers = http_request.headers.map { |k, v| [k.to_s, v.to_s] }
|
59
|
+
request.options.context ||= {}
|
60
|
+
request.options.context.merge!(http_request.context)
|
61
|
+
unless http_request.http_method == HttpMethod::GET && http_request.parameters.empty?
|
62
|
+
request.body = http_request.parameters
|
63
|
+
end
|
64
|
+
end
|
65
|
+
convert_response(response, http_request)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Method overridden from HttpClient.
|
69
|
+
# @param [Dynamic] response The response object received from the client.
|
70
|
+
# @param [HttpRequest] http_request The HttpRequest which was executed.
|
71
|
+
def convert_response(response, http_request)
|
72
|
+
@response_factory.create(response.status, response.reason_phrase,
|
73
|
+
response.headers, response.body, http_request)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,235 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apimatic_faraday_client_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- APIMatic Ltd.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: apimatic_core_interfaces
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.0.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: faraday-follow_redirects
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.2'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: faraday-multipart
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: faraday-gzip
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.1'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0.1'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: faraday-retry
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: faraday-net_http_persistent
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: certifi
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2018.1'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 2018.01.18
|
127
|
+
type: :runtime
|
128
|
+
prerelease: false
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '2018.1'
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 2018.01.18
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: faraday-http-cache
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '2.2'
|
144
|
+
type: :runtime
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '2.2'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: minitest
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '5.14'
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 5.14.1
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '5.14'
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 5.14.1
|
171
|
+
- !ruby/object:Gem::Dependency
|
172
|
+
name: minitest-proveit
|
173
|
+
requirement: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '1.0'
|
178
|
+
type: :development
|
179
|
+
prerelease: false
|
180
|
+
version_requirements: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - "~>"
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '1.0'
|
185
|
+
- !ruby/object:Gem::Dependency
|
186
|
+
name: simplecov
|
187
|
+
requirement: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - "~>"
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: 0.21.2
|
192
|
+
type: :development
|
193
|
+
prerelease: false
|
194
|
+
version_requirements: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - "~>"
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: 0.21.2
|
199
|
+
description: Faraday is a simple, yet elegant, HTTP library. This repository contains
|
200
|
+
the client implementation that uses the requests library for python SDK provided
|
201
|
+
by APIMatic.
|
202
|
+
email: support@apimatic.io
|
203
|
+
executables: []
|
204
|
+
extensions: []
|
205
|
+
extra_rdoc_files: []
|
206
|
+
files:
|
207
|
+
- LICENSE
|
208
|
+
- README.md
|
209
|
+
- lib/apimatic-faraday-client-adapter/faraday_client.rb
|
210
|
+
- lib/apimatic_faraday_client_adapter.rb
|
211
|
+
homepage: https://apimatic.io
|
212
|
+
licenses:
|
213
|
+
- APIMATIC REFERENCE SOURCE LICENSE
|
214
|
+
metadata: {}
|
215
|
+
post_install_message:
|
216
|
+
rdoc_options: []
|
217
|
+
require_paths:
|
218
|
+
- lib
|
219
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '2.6'
|
224
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '0'
|
229
|
+
requirements: []
|
230
|
+
rubygems_version: 3.4.1
|
231
|
+
signing_key:
|
232
|
+
specification_version: 4
|
233
|
+
summary: An adapter for faraday client library consumed by the SDKs generated with
|
234
|
+
APIMatic.
|
235
|
+
test_files: []
|