apimatic_core 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c05d9bcfc3de9b4a1b64bef3e97ddc26be097d03a46c921526a7a0a0ab4ad083
4
- data.tar.gz: aa0f7ae505663bc00d919cf4c8a9a661ce0ba2703cfa0aa1a82697aea5913472
3
+ metadata.gz: 5bb8b07b1daea4ded5f7f3cd7552c5e9b7f47b5d88466d46ca2c166606f9b73e
4
+ data.tar.gz: 8eeb04841951ded1916d37588aca7a36254079653a1db626787e5ee958ccf338
5
5
  SHA512:
6
- metadata.gz: fcfbdbab3adcf1d8c5463a2402e2cfa3253554a72ff4ddfe5625ababf23ff980ac4efb175d6959176bec6bf181f8554ae539181b7c8060c088ceff94c17ec1c7
7
- data.tar.gz: 3a22ad6f9424b9a227020fc03f00a0b3d6537a7d3d11d2823d025fc0a4de8eb1b056c9e68af9b312f5809ff4ef6b7997d9921763befada28135962422e2a53f1
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?
@@ -271,7 +271,6 @@ module CoreLibrary
271
271
  _form_params.merge!(@form_params) if _has_form_params
272
272
  _form_params.merge!(@multipart_params) if _has_multipart_param
273
273
  _form_params.merge!(@additional_form_params) if _has_additional_form_params
274
- # TODO: add Array serialization format support while writing the POC
275
274
  return ApiHelper.form_encode_parameters(_form_params, @array_serialization_format)
276
275
  elsif _has_body_param && _has_body_serializer
277
276
  return @body_serializer.call(resolve_body_param)
@@ -279,7 +278,7 @@ module CoreLibrary
279
278
  return resolve_body_param
280
279
  end
281
280
 
282
- {}
281
+ nil
283
282
  end
284
283
 
285
284
  # Processes the part of a multipart request and assign appropriate part value and its content-type.
@@ -330,7 +329,7 @@ module CoreLibrary
330
329
  def apply_auth(auth_managers, http_request)
331
330
  is_valid_auth = @auth.with_auth_managers(auth_managers).valid unless @auth.nil?
332
331
  @auth.apply(http_request) if is_valid_auth
333
- raise InvalidAuthCredential, @auth.error_message if !@auth.nil? && !is_valid_auth
332
+ raise AuthValidationException, @auth.error_message if !@auth.nil? && !is_valid_auth
334
333
  end
335
334
  end
336
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.0
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-07-04 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