apimatic_core 0.3.1 → 0.3.2

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: 07647c7b720a3711a7304e41810c5700cd175e6456c8707096a5238e67730810
4
- data.tar.gz: 1156887637f2db594c6442e97599eb0679f515408f4e5fa4743dfb0ad912e909
3
+ metadata.gz: 5bb8b07b1daea4ded5f7f3cd7552c5e9b7f47b5d88466d46ca2c166606f9b73e
4
+ data.tar.gz: 8eeb04841951ded1916d37588aca7a36254079653a1db626787e5ee958ccf338
5
5
  SHA512:
6
- metadata.gz: 6175e53d0f56a3479ff3eb58a016f685e02d8d3076e2be36a76c9ed1f55b7ff221b27dd1de6529b057b63aec018d01520cb8aa12bf909991c6a23763438add47
7
- data.tar.gz: 3f6a35a5beb8768d5331887604c5458c5bba59a6c8e9fc0880ff9e8c99b3ba5f4c824338f7d8cd2b6eadf460d3e671bd6f7bbddcee92b0d4ca32004d4570d4d7
6
+ metadata.gz: 8157cd92fc94067895362179be7d61a594e256a46bc53a6937eaa138d74d673ce2911a3411730b628e01484932363ec2750219556e12cc1f461a78e7e76dc624
7
+ data.tar.gz: b81485a1ef18c8be37c339530ce0ab317212226c89841aa53c94d82256dbac4cf2cef401b3ee28c5be7b9062597776cb5782be8ec5f9fdd57f4bd69f8425ea96
data/README.md CHANGED
@@ -50,11 +50,11 @@ gem 'apimatic_core'
50
50
 
51
51
 
52
52
  ## Exceptions
53
- | Name | Description |
54
- |-------------------------------------------------------------------------------------------|-----------------------------------------------------|
55
- | [`OneOfValidationException`](lib/apimatic-core/exceptions/one_of_validation_exception.rb) | Exception thrown in case of OneOf validation errors |
56
- | [`AnyOfValidationException`](lib/apimatic-core/exceptions/any_of_validation_exception.rb) | Exception thrown in case of AnyOf validation errors |
57
-
53
+ | Name | Description |
54
+ |-------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
55
+ | [`OneOfValidationException`](lib/apimatic-core/exceptions/one_of_validation_exception.rb) | An exception class for the failed validation of oneOf (union-type) cases |
56
+ | [`AnyOfValidationException`](lib/apimatic-core/exceptions/any_of_validation_exception.rb) | An exception class for the failed validation of anyOf (union-type) cases |
57
+ | [`AuthValidationException`](lib/apimatic-core/exceptions/auth_validation_exception.rb) | An exception class for the failed validation of authentication schemes |
58
58
 
59
59
  ## Factories
60
60
  | Name | Description |
@@ -18,11 +18,10 @@ module CoreLibrary
18
18
  # @return [Boolean] True if the associated auth is valid, false otherwise.
19
19
  def valid
20
20
  @mapped_group.each do |participant|
21
- if participant.valid
22
- @is_valid_group = true
23
- else
24
- @error_messages.append(participant.error_message)
25
- end
21
+ @is_valid_group = participant.valid
22
+ return true if @is_valid_group
23
+
24
+ @error_messages.append(participant.error_message)
26
25
  end
27
26
 
28
27
  @is_valid_group
@@ -13,7 +13,7 @@ module CoreLibrary
13
13
  @auth_participant = auth_participant
14
14
  @mapped_auth = nil
15
15
  @error_message = nil
16
- @is_valid = true
16
+ @is_valid = false
17
17
  end
18
18
 
19
19
  # Extracts out the auth from the given auth managers.
@@ -31,11 +31,8 @@ module CoreLibrary
31
31
  def valid
32
32
  raise ArgumentError, 'The auth manager entry must not have a nil value.' if @mapped_auth.nil?
33
33
 
34
- unless @mapped_auth.valid
35
- @error_message = @mapped_auth.error_message
36
- @is_valid = false
37
- end
38
-
34
+ @is_valid = @mapped_auth.valid
35
+ @error_message = @mapped_auth.error_message unless @is_valid
39
36
  @is_valid
40
37
  end
41
38
 
@@ -1,5 +1,5 @@
1
1
  module CoreLibrary
2
2
  # Class for exceptions when there is an invalid state while applying the auth credentials.
3
- class InvalidAuthCredential < StandardError
3
+ class AuthValidationException < StandardError
4
4
  end
5
5
  end
@@ -207,8 +207,8 @@ module CoreLibrary
207
207
  # @param [String] url The URL of the endpoint.
208
208
  # @return [String] The URL with resolved query parameters if any.
209
209
  def get_updated_url_with_query_params(url)
210
- _has_additional_query_params = (!@additional_query_params.nil? and @additional_query_params.any?)
211
- _has_query_params = (!@query_params.nil? and @query_params.any?)
210
+ _has_additional_query_params = !@additional_query_params.nil? and @additional_query_params.any?
211
+ _has_query_params = !@query_params.nil? and @query_params.any?
212
212
  _query_params = @query_params
213
213
  _query_params.merge!(@additional_query_params) if _has_additional_query_params
214
214
 
@@ -229,9 +229,9 @@ module CoreLibrary
229
229
  _global_headers = global_configuration.get_global_headers
230
230
  _additional_headers = global_configuration.get_additional_headers
231
231
 
232
- _has_global_headers = (!_global_headers.nil? && _global_headers.any?)
233
- _has_additional_headers = (!_additional_headers.nil? && _additional_headers.any?)
234
- _has_local_headers = (!@header_params.nil? and @header_params.any?)
232
+ _has_global_headers = !_global_headers.nil? && _global_headers.any?
233
+ _has_additional_headers = !_additional_headers.nil? && _additional_headers.any?
234
+ _has_local_headers = !@header_params.nil? and @header_params.any?
235
235
 
236
236
  if _has_global_headers || _has_additional_headers || _has_local_headers
237
237
  @endpoint_logger.info("Preparing headers for #{@endpoint_name_for_logging}.")
@@ -251,9 +251,9 @@ module CoreLibrary
251
251
  # Processes the body parameter of the request (including form param, json body or xml body).
252
252
  # @return [Object] The body param to be sent in the request.
253
253
  def process_body
254
- _has_form_params = (!@form_params.nil? && @form_params.any?)
255
- _has_additional_form_params = (!@additional_form_params.nil? && @additional_form_params.any?)
256
- _has_multipart_param = (!@multipart_params.nil? && @multipart_params.any?)
254
+ _has_form_params = !@form_params.nil? && @form_params.any?
255
+ _has_additional_form_params = !@additional_form_params.nil? && @additional_form_params.any?
256
+ _has_multipart_param = !@multipart_params.nil? && @multipart_params.any?
257
257
  _has_body_param = !@body_param.nil?
258
258
  _has_body_serializer = !@body_serializer.nil?
259
259
  _has_xml_attributes = !@xml_attributes.nil?
@@ -329,7 +329,7 @@ module CoreLibrary
329
329
  def apply_auth(auth_managers, http_request)
330
330
  is_valid_auth = @auth.with_auth_managers(auth_managers).valid unless @auth.nil?
331
331
  @auth.apply(http_request) if is_valid_auth
332
- raise InvalidAuthCredential, @auth.error_message if !@auth.nil? && !is_valid_auth
332
+ raise AuthValidationException, @auth.error_message if !@auth.nil? && !is_valid_auth
333
333
  end
334
334
  end
335
335
  end
@@ -61,7 +61,7 @@ module CoreLibrary
61
61
  def validate_dict_case(dict_value)
62
62
  return false unless dict_value.instance_of?(Hash)
63
63
 
64
- dict_value.each do |_key, value|
64
+ dict_value.each_value do |value|
65
65
  is_valid = validate_simple_case(value)
66
66
  return false unless is_valid
67
67
  end
@@ -72,7 +72,7 @@ module CoreLibrary
72
72
  def validate_dict_of_array_case(dict_value)
73
73
  return false unless dict_value.instance_of?(Hash)
74
74
 
75
- dict_value.each do |_key, value|
75
+ dict_value.each_value do |value|
76
76
  is_valid = validate_array_case(value)
77
77
  return false unless is_valid
78
78
  end
data/lib/apimatic_core.rb CHANGED
@@ -13,7 +13,7 @@ require_relative 'apimatic-core/factories/http_response_factory'
13
13
 
14
14
  require_relative 'apimatic-core/configurations/global_configuration'
15
15
 
16
- require_relative 'apimatic-core/exceptions/invalid_auth_credential'
16
+ require_relative 'apimatic-core/exceptions/auth_validation_exception'
17
17
  require_relative 'apimatic-core/exceptions/any_of_validation_exception'
18
18
  require_relative 'apimatic-core/exceptions/one_of_validation_exception'
19
19
 
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - APIMatic Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-21 00:00:00.000000000 Z
11
+ date: 2023-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apimatic_core_interfaces
@@ -180,7 +180,7 @@ files:
180
180
  - lib/apimatic-core/authentication/query_auth.rb
181
181
  - lib/apimatic-core/configurations/global_configuration.rb
182
182
  - lib/apimatic-core/exceptions/any_of_validation_exception.rb
183
- - lib/apimatic-core/exceptions/invalid_auth_credential.rb
183
+ - lib/apimatic-core/exceptions/auth_validation_exception.rb
184
184
  - lib/apimatic-core/exceptions/one_of_validation_exception.rb
185
185
  - lib/apimatic-core/factories/http_response_factory.rb
186
186
  - lib/apimatic-core/http/configurations/http_client_configuration.rb