apimatic_core 0.3.17 → 0.3.19
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8036d7d4e85c7d9a51ba0cb35b55512f7f5ee7b9be1ae82539968818cb071647
|
4
|
+
data.tar.gz: a7c919a5d44e501c1dcb24c348a8a2d86397a7544cf909f9437a70b4e362cc13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 740e2f24d1386d43da34543a506044593a9e15dd879f894e83a2abb5f68d0497c4edc0c741dfcc73c5147f691eeab8abef8c2b9d005f0f2493ff3136f28dca20
|
7
|
+
data.tar.gz: a691fb1f4ebf03184ad11ad9d1662da02563d5f6208d71224ff6782474eb017c09e970053919816782684af64ec188de94ad0507f61c7ca2c72c75db24f0c144
|
data/README.md
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
[](https://badge.fury.io/rb/apimatic_core)
|
4
4
|
[![Tests][test-badge]][test-url]
|
5
5
|
[![Linting][lint-badge]][lint-url]
|
6
|
-
[![Test Coverage][
|
6
|
+
[![Test Coverage][coverage-badge]][coverage-url]
|
7
|
+
[![Maintainability Rating][maintainability-badge]][maintainability-url]
|
8
|
+
[![Vulnerabilities][vulnerabilities-badge]][vulnerabilities-url]
|
7
9
|
[](https://github.com/rubocop/rubocop)
|
8
10
|
[![Licence][license-badge]][license-url]
|
9
11
|
|
@@ -43,7 +45,7 @@ gem 'apimatic_core'
|
|
43
45
|
| [`Single`](lib/apimatic-core/authentication/multiple/single_auth.rb) | Helper class to support single authentication |
|
44
46
|
|
45
47
|
|
46
|
-
##
|
48
|
+
## Global Configuration
|
47
49
|
| Name | Description |
|
48
50
|
|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
|
49
51
|
| [`GlobalConfiguration`](lib/apimatic-core/configurations/global_configuration.rb ) | Class holding the global configuration properties to make a successful API Call |
|
@@ -61,10 +63,15 @@ gem 'apimatic_core'
|
|
61
63
|
|-------------------------------------------------------------------------------|------------------------------------------|
|
62
64
|
| [`HttpResponseFactory`](lib/apimatic-core/factories/http_response_factory.rb) | Factory class to create an HTTP Response |
|
63
65
|
|
66
|
+
## HTTP Configuration
|
67
|
+
| Name | Description |
|
68
|
+
|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
|
69
|
+
| [`HttpClientConfiguration`](lib/apimatic-core/http/configurations/http_client_configuration.rb) | Class used for configuring SDK by a user |
|
70
|
+
| [`ProxySettings`](lib/apimatic-core/http/configurations/proxy_settings.rb) | ProxySettings encapsulates HTTP proxy configuration for Faraday, e.g. address, port and optional basic authentication |
|
71
|
+
|
64
72
|
## HTTP
|
65
73
|
| Name | Description |
|
66
74
|
|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
67
|
-
| [`HttpClientConfiguration`](lib/apimatic-core/http/configurations/http_client_configuration.rb) | Class used for configuring SDK by a user |
|
68
75
|
| [`HttpRequest`](lib/apimatic-core/http/request/http_request.rb) | Class which contains information about the HTTP Request |
|
69
76
|
| [`ApiResponse`](lib/apimatic-core/http/response/api_response.rb) | Wrapper class for Api Response |
|
70
77
|
| [`HttpResponse`](lib/apimatic-core/http/response/http_response.rb) | Class which contains information about the HTTP Response |
|
@@ -125,8 +132,11 @@ gem 'apimatic_core'
|
|
125
132
|
[test-url]: https://github.com/apimatic/core-lib-ruby/actions/workflows/test-runner.yml
|
126
133
|
[lint-badge]: https://github.com/apimatic/core-lib-ruby/actions/workflows/lint-runner.yml/badge.svg
|
127
134
|
[lint-url]: https://github.com/apimatic/core-lib-ruby/actions/workflows/lint-runner.yml
|
128
|
-
[
|
129
|
-
[
|
130
|
-
[
|
135
|
+
[coverage-badge]: https://sonarcloud.io/api/project_badges/measure?project=apimatic_core-lib-ruby&metric=coverage
|
136
|
+
[coverage-url]: https://sonarcloud.io/summary/new_code?id=apimatic_core-lib-ruby
|
137
|
+
[maintainability-badge]: https://sonarcloud.io/api/project_badges/measure?project=apimatic_core-lib-ruby&metric=sqale_rating
|
138
|
+
[maintainability-url]: https://sonarcloud.io/summary/new_code?id=apimatic_core-lib-ruby
|
139
|
+
[vulnerabilities-badge]: https://sonarcloud.io/api/project_badges/measure?project=apimatic_core-lib-ruby&metric=vulnerabilities
|
140
|
+
[vulnerabilities-url]: https://sonarcloud.io/summary/new_code?id=apimatic_core-lib-ruby
|
131
141
|
[license-badge]: https://img.shields.io/badge/licence-MIT-blue
|
132
142
|
[license-url]: LICENSE
|
@@ -16,12 +16,13 @@ module CoreLibrary
|
|
16
16
|
# @param [Boolean] verify Should verification be enabled.
|
17
17
|
# @param http_callback A method to be used as http callback
|
18
18
|
# @param [HttpClient] http_client An instance of HttpClient
|
19
|
+
# @param [ProxySettings] proxy_settings The configurable settings for proxy
|
19
20
|
def initialize(
|
20
21
|
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
21
22
|
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
22
23
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
23
24
|
retry_methods: %i[get put], cache: false, verify: true, http_callback: nil, http_client: nil,
|
24
|
-
logging_configuration: nil
|
25
|
+
logging_configuration: nil, proxy_settings: nil
|
25
26
|
)
|
26
27
|
@response_factory = HttpResponseFactory.new
|
27
28
|
@connection = connection
|
@@ -37,6 +38,7 @@ module CoreLibrary
|
|
37
38
|
@cache = cache
|
38
39
|
@http_client = http_client
|
39
40
|
@logging_configuration = logging_configuration
|
41
|
+
@proxy_settings = proxy_settings
|
40
42
|
end
|
41
43
|
|
42
44
|
# Setter for http_client.
|
@@ -58,7 +60,8 @@ module CoreLibrary
|
|
58
60
|
verify: @verify,
|
59
61
|
http_callback: http_callback || DeepCloneUtils.deep_copy(@http_callback),
|
60
62
|
http_client: DeepCloneUtils.deep_copy(@http_client),
|
61
|
-
logging_configuration: DeepCloneUtils.deep_copy(@logging_configuration)
|
63
|
+
logging_configuration: DeepCloneUtils.deep_copy(@logging_configuration),
|
64
|
+
proxy_settings: DeepCloneUtils.deep_copy(@proxy_settings)
|
62
65
|
)
|
63
66
|
end
|
64
67
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module CoreLibrary
|
2
|
+
##
|
3
|
+
# ProxySettings encapsulates HTTP proxy configuration for Faraday,
|
4
|
+
# including optional basic authentication.
|
5
|
+
#
|
6
|
+
class ProxySettings
|
7
|
+
attr_accessor :address, :port, :username, :password
|
8
|
+
|
9
|
+
##
|
10
|
+
# @param address [String] The proxy server address (e.g., 'http://localhost').
|
11
|
+
# @param port [Integer, nil] Optional proxy server port (e.g., 8080).
|
12
|
+
# @param username [String, nil] Optional proxy auth username.
|
13
|
+
# @param password [String, nil] Optional proxy auth password.
|
14
|
+
#
|
15
|
+
# @raise [ArgumentError] If address is invalid.
|
16
|
+
#
|
17
|
+
def initialize(address:, port: nil, username: nil, password: nil)
|
18
|
+
raise ArgumentError, 'Proxy address must be a non-empty string' unless address.is_a?(String) && !address.empty?
|
19
|
+
|
20
|
+
@address = address
|
21
|
+
@port = port
|
22
|
+
@username = username
|
23
|
+
@password = password
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Converts the proxy settings into a Faraday-compatible hash.
|
28
|
+
#
|
29
|
+
# @return [Hash] A hash with keys :uri, :user, and :password (as applicable).
|
30
|
+
#
|
31
|
+
def to_h
|
32
|
+
uri_str = port ? "#{address}:#{port}" : address
|
33
|
+
|
34
|
+
{
|
35
|
+
uri: uri_str
|
36
|
+
}.tap do |hash|
|
37
|
+
hash[:user] = username if username
|
38
|
+
hash[:password] = password if password
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -72,8 +72,11 @@ module CoreLibrary
|
|
72
72
|
|
73
73
|
# Deserializer to use when the type of response is not known beforehand.
|
74
74
|
# @param response The response received.
|
75
|
+
# @return [Hash, Array, nil] The deserialized response.
|
75
76
|
def self.dynamic_deserializer(response, should_symbolize)
|
76
|
-
|
77
|
+
return unless deserializable_json?(response)
|
78
|
+
|
79
|
+
json_deserialize(response, should_symbolize)
|
77
80
|
end
|
78
81
|
|
79
82
|
# Deserializes response to a known custom model type.
|
@@ -303,6 +306,20 @@ module CoreLibrary
|
|
303
306
|
end
|
304
307
|
end
|
305
308
|
|
309
|
+
# Checks whether the content is deserializable JSON.
|
310
|
+
# @param [String] json A JSON string.
|
311
|
+
# @return [Boolean] True if the content can be deserialized, false otherwise.
|
312
|
+
def self.deserializable_json?(json)
|
313
|
+
return false if json.nil? || json.to_s.strip.empty?
|
314
|
+
|
315
|
+
begin
|
316
|
+
JSON.parse(json)
|
317
|
+
true
|
318
|
+
rescue JSON::ParserError
|
319
|
+
false
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
306
323
|
# Parses JSON string.
|
307
324
|
# @param [object] obj The object to serialize.
|
308
325
|
def self.json_serialize(obj)
|
data/lib/apimatic_core.rb
CHANGED
@@ -30,6 +30,7 @@ require_relative 'apimatic-core/pagination/strategies/offset_pagination'
|
|
30
30
|
require_relative 'apimatic-core/pagination/strategies/page_pagination'
|
31
31
|
|
32
32
|
require_relative 'apimatic-core/http/configurations/http_client_configuration'
|
33
|
+
require_relative 'apimatic-core/http/configurations/proxy_settings'
|
33
34
|
require_relative 'apimatic-core/http/request/http_request'
|
34
35
|
require_relative 'apimatic-core/http/response/http_response'
|
35
36
|
require_relative 'apimatic-core/http/response/api_response'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apimatic_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- APIMatic Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apimatic_core_interfaces
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- lib/apimatic-core/exceptions/one_of_validation_exception.rb
|
171
171
|
- lib/apimatic-core/factories/http_response_factory.rb
|
172
172
|
- lib/apimatic-core/http/configurations/http_client_configuration.rb
|
173
|
+
- lib/apimatic-core/http/configurations/proxy_settings.rb
|
173
174
|
- lib/apimatic-core/http/http_call_context.rb
|
174
175
|
- lib/apimatic-core/http/request/http_request.rb
|
175
176
|
- lib/apimatic-core/http/response/api_response.rb
|