apimatic_core_interfaces 0.1.2 → 0.2.1

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: 90e066016582514a809448dcd2268022b4a9876641ef77dfd5ae88915bd605a0
4
- data.tar.gz: fc00d445cfd4e983cf3fecd034834bbac9ec649c10e18d7f245501959baa6446
3
+ metadata.gz: 01a4e34ebafdba39e2611a2b683cd55dfc9e28d1ba990680b247e82e0258eebb
4
+ data.tar.gz: 100242792ff4890d5a68fd9ec72dea9027583630b42db0791156cb26cc88dcb6
5
5
  SHA512:
6
- metadata.gz: a1d9b6e320aa1b921f1018a5017595476574977fdb34233db073c64f1a6e8107b9ea8b3a8b961cfbc89b5223e419e7b0645d14d8ec1e57367d26dd0e1bd5480b
7
- data.tar.gz: ae062e11518bc9a72b0374f52556af263e3b5e32419cd0a6ab18519ee1a2fc5aa81a1de8bcbad308ffaf6e4ab53b4571f7872407cd123bbc4deb9bc67a2e575e
6
+ metadata.gz: 416839b0980056003f53c6a9329edd837ffb7c4ce0e01cd8a5580a9e19fcb142c76a14dd77b082fbc6741167fe92a62f166902d77fae1b46710c2089d93871fc
7
+ data.tar.gz: 9b056e3bde0d308e524b526b597d32e0289c3ad3594f5f070479b80ad782d7905f31eac1b25a6833c1a9079f892eedf761dda0d0ad3cef8b3d4a07b6fca34337
data/README.md CHANGED
@@ -24,12 +24,14 @@ gem 'apimatic_core_interfaces'
24
24
  ```
25
25
 
26
26
  ## Interfaces
27
- | Name | Description |
28
- |--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
29
- | [`HttpClient`](lib/apimatic-core-interfaces/client/http_client.rb) | To save both Request and Response after the completion of response |
30
- | [`ResponseFactory`](lib/apimatic-core-interfaces/factories/response_factory.rb) | To convert the client-adapter response into a custom HTTP response |
31
- | [`Authentication`](lib/apimatic-core-interfaces/types/authentication.rb) | To setup methods for the validation and application of the required authentication scheme |
32
- | [`ClientConfiguration`](lib/apimatic-core-interfaces/client/client_configuration.rb) | To setup the http client configurations including retries, timeouts and connections etc. |
27
+ | Name | Description |
28
+ |--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
29
+ | [`HttpClient`](lib/apimatic-core-interfaces/client/http_client.rb) | To save both Request and Response after the completion of response |
30
+ | [`ResponseFactory`](lib/apimatic-core-interfaces/factories/response_factory.rb) | To convert the client-adapter response into a custom HTTP response |
31
+ | [`Authentication`](lib/apimatic-core-interfaces/types/authentication.rb) | To setup methods for the validation and application of the required authentication scheme |
32
+ | [`UnionType`](lib/apimatic-core-interfaces/types/union_type.rb) | To setup methods for the validation, serialization and deserialization of OneOf/AnyOf union types |
33
+ | [`ApiLogger`](lib/apimatic-core-interfaces/logger/api_logger.rb) | An interface for logging API requests and responses. |
34
+ | [`Logger`](lib/apimatic-core-interfaces/logger/logger.rb) | An interface for the generic logger facade |
33
35
 
34
36
 
35
37
  ## Enumerations
@@ -0,0 +1,18 @@
1
+ module CoreLibrary
2
+ # An interface for logging API requests and responses.
3
+ # This class should not be instantiated but should be used as a base class
4
+ # for API logger class.
5
+ class ApiLogger
6
+ # Logs the details of an HTTP request.
7
+ # @param request [HttpRequest] The HTTP request to log.
8
+ def log_request(request)
9
+ raise NotImplementedError, 'This method needs to be implemented in a child class.'
10
+ end
11
+
12
+ # Logs the details of an HTTP response.
13
+ # @param response [HttpResponse] The HTTP response to log.
14
+ def log_response(response)
15
+ raise NotImplementedError, 'This method needs to be implemented in a child class.'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module CoreLibrary
2
+ # An interface for the generic logger facade.
3
+ # This class should not be instantiated but should be used as a base class
4
+ # for Logger class.
5
+ class Logger
6
+ # Logs a message with a specified log level and additional parameters.
7
+ # @param level [Symbol] The log level of the message.
8
+ # @param message [String] The message to log.
9
+ # @param params [Hash] Additional parameters to include in the log message.
10
+ def log(level, message, params)
11
+ raise NotImplementedError, 'This method needs to be implemented in a child class.'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,55 @@
1
+ module CoreLibrary
2
+ # Represents a union type that can validate, serialize and deserialize values based on a set of allowed types.
3
+ class UnionType
4
+ # NATIVE_TYPES represents the list of native types in Ruby.
5
+ # These types are commonly used and built-in to the Ruby language.
6
+ # The constant contains the following types:
7
+ # - Integer: Represents whole numbers without a decimal point.
8
+ # - String: Represents a sequence of characters.
9
+ # - Float: Represents floating-point numbers with a decimal point.
10
+ # - TrueClass: Represents the boolean value `true`.
11
+ # - FalseClass: Represents the boolean value `false`.
12
+ # This constant is used within the UnionType class to define the allowed native types.
13
+ NATIVE_TYPES = [Integer, String, Float, TrueClass, FalseClass].freeze
14
+
15
+ attr_accessor :is_valid, :error_messages, :union_type_context, :union_types
16
+
17
+ # Initializes a new instance of UnionType.
18
+ # @param union_types [Array<Class>] An array of allowed types for the union.
19
+ # @param union_type_context [Object] The context of the union type.
20
+ def initialize(union_types, union_type_context)
21
+ @union_types = union_types
22
+ @union_type_context = union_type_context
23
+ @is_valid = false
24
+ @error_messages = Set.new
25
+ end
26
+
27
+ # Validates a value against the union type.
28
+ # This method should be implemented by subclasses.
29
+ # @param value [Object] The value to validate.
30
+ # @raise [NotImplementedError] If the method is not implemented in a subclass.
31
+ def validate(value)
32
+ raise NotImplementedError, 'This method needs
33
+ to be implemented in a child class.'
34
+ end
35
+
36
+ # Serializes a given value.
37
+ # @param value [Object] The value to be serialized.
38
+ # @raise [NotImplementedError] If the method is not implemented in the child class.
39
+ # @return [String] The serialized representation of the value.
40
+ def serialize(value)
41
+ raise NotImplementedError, 'This method needs
42
+ to be implemented in a child class.'
43
+ end
44
+
45
+ # Deserializes a value based on the union type.
46
+ # This method should be implemented by subclasses.
47
+ # @param value [Object] The value to deserialize.
48
+ # @param should_symbolize [Boolean] Indicates whether the deserialized value should be symbolized.
49
+ # @raise [NotImplementedError] If the method is not implemented in a subclass.
50
+ def deserialize(value, should_symbolize: false)
51
+ raise NotImplementedError, 'This method needs
52
+ to be implemented in a child class.'
53
+ end
54
+ end
55
+ end
@@ -3,7 +3,11 @@ require_relative 'apimatic-core-interfaces/client/client_configuration'
3
3
 
4
4
  require_relative 'apimatic-core-interfaces/factories/response_factory'
5
5
 
6
+ require_relative 'apimatic-core-interfaces/logger/logger'
7
+ require_relative 'apimatic-core-interfaces/logger/api_logger'
8
+
6
9
  require_relative 'apimatic-core-interfaces/types/authentication'
10
+ require_relative 'apimatic-core-interfaces/types/union_type'
7
11
  require_relative 'apimatic-core-interfaces/types/http_callback'
8
12
  require_relative 'apimatic-core-interfaces/types/http_method'
9
13
  require_relative 'apimatic-core-interfaces/types/array_serialization_format'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apimatic_core_interfaces
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
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-04-04 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This project contains the abstract layer for APIMatic's core library.
14
14
  The purpose of creating interfaces is to separate out the functionalities needed
@@ -25,11 +25,14 @@ files:
25
25
  - lib/apimatic-core-interfaces/client/client_configuration.rb
26
26
  - lib/apimatic-core-interfaces/client/http_client.rb
27
27
  - lib/apimatic-core-interfaces/factories/response_factory.rb
28
+ - lib/apimatic-core-interfaces/logger/api_logger.rb
29
+ - lib/apimatic-core-interfaces/logger/logger.rb
28
30
  - lib/apimatic-core-interfaces/types/array_serialization_format.rb
29
31
  - lib/apimatic-core-interfaces/types/authentication.rb
30
32
  - lib/apimatic-core-interfaces/types/datetime_format.rb
31
33
  - lib/apimatic-core-interfaces/types/http_callback.rb
32
34
  - lib/apimatic-core-interfaces/types/http_method.rb
35
+ - lib/apimatic-core-interfaces/types/union_type.rb
33
36
  - lib/apimatic_core_interfaces.rb
34
37
  homepage: https://apimatic.io
35
38
  licenses:
@@ -50,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
53
  - !ruby/object:Gem::Version
51
54
  version: '0'
52
55
  requirements: []
53
- rubygems_version: 3.4.10
56
+ rubygems_version: 3.4.19
54
57
  signing_key:
55
58
  specification_version: 4
56
59
  summary: An abstract layer of the functionalities provided by apimatic-core, faraday-client-adapter