apimatic_core_interfaces 0.1.1 → 0.2.0

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: c030a041841cf1a3866d1b6b56e872037665bea6588f9d10e94e217ffd0cc2f3
4
- data.tar.gz: f28625784fcf40cacfb68dfbaa3395ce0811716ecc9661bed13da5a0bb6ac7e9
3
+ metadata.gz: aaf47cc9c42b3a20af7fa3b74bdabd33852f43d29e7f2fe426ee17f51fb0ff42
4
+ data.tar.gz: 4d9200846000fa6492e05d04d4dbc51b27ff7a3e077b583f96af5e9d89c8a420
5
5
  SHA512:
6
- metadata.gz: 739f1d954d50f9f9ac162d6054ed1b0f61a90bad5e8ffdc5ae3ff27c2b0cd5edd24bc1b6e946fd77929f4f0d200406592781a08e598583d71730062c98858467
7
- data.tar.gz: 3ff3f294fa29949e0d6277346a8d9ea52670024fb546bef569c49a5398d429f3901875959d816275ace7bd43a71f1a2dec2def78c5ad56239f7a637f08cb022d
6
+ metadata.gz: b9a7ca20453fd54f0342271f1a4173fe3165c0cb53a45e1bbdff5e8379d0c9edd6a7b5135cb960ecb23ec97543d7d4f196290645ca11bafe23bf36c4490099bc
7
+ data.tar.gz: be574e6033423b730fe3e8a4e5f5c3d9b5167e0e4bfa376645cdee46310ea692a15cb297c82d42894bcd790647d2517d735afc0b630b45d601ba23aed08fa1bf
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  This project contains the abstract layer for core library ruby. The purpose of creating interfaces is to separate out the functionalities needed by ruby core library. The goal is to support scalability and feature enhancement of the core library and the SDKs along with avoiding any breaking changes by reducing tight coupling between modules through the introduction of interfaces.
11
11
 
12
12
  ## Version supported
13
- Currently APIMatic supports `2.6 <= Ruby version < 3.1` hence core-interfaces-ruby will need the same versions to be supported.
13
+ Currently APIMatic supports `2.6 <= Ruby version <= 3.2` hence core-interfaces-ruby will need the same versions to be supported.
14
14
 
15
15
  ## Installation
16
16
  Installation is quite simple, just execute the following command:
@@ -24,12 +24,13 @@ 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
+ | [`ClientConfiguration`](lib/apimatic-core-interfaces/client/client_configuration.rb) | To setup the http client configurations including retries, timeouts and connections etc. |
33
34
 
34
35
 
35
36
  ## Enumerations
@@ -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
@@ -4,6 +4,7 @@ require_relative 'apimatic-core-interfaces/client/client_configuration'
4
4
  require_relative 'apimatic-core-interfaces/factories/response_factory'
5
5
 
6
6
  require_relative 'apimatic-core-interfaces/types/authentication'
7
+ require_relative 'apimatic-core-interfaces/types/union_type'
7
8
  require_relative 'apimatic-core-interfaces/types/http_callback'
8
9
  require_relative 'apimatic-core-interfaces/types/http_method'
9
10
  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.1
4
+ version: 0.2.0
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-02-16 00:00:00.000000000 Z
11
+ date: 2023-07-04 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
@@ -30,6 +30,7 @@ files:
30
30
  - lib/apimatic-core-interfaces/types/datetime_format.rb
31
31
  - lib/apimatic-core-interfaces/types/http_callback.rb
32
32
  - lib/apimatic-core-interfaces/types/http_method.rb
33
+ - lib/apimatic-core-interfaces/types/union_type.rb
33
34
  - lib/apimatic_core_interfaces.rb
34
35
  homepage: https://apimatic.io
35
36
  licenses:
@@ -50,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
51
  - !ruby/object:Gem::Version
51
52
  version: '0'
52
53
  requirements: []
53
- rubygems_version: 3.4.6
54
+ rubygems_version: 3.4.10
54
55
  signing_key:
55
56
  specification_version: 4
56
57
  summary: An abstract layer of the functionalities provided by apimatic-core, faraday-client-adapter