apimatic_core_interfaces 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 79f8cde8fe5c6a5cec765e78448c3e72d82a11d5c1a447ec54210e4d0064264e
4
+ data.tar.gz: 34cd4ac1a8463c474666a735c8d7df65651ba37b0a233d942bc11b02bca5aebf
5
+ SHA512:
6
+ metadata.gz: 39e69b43f329bd3c0bd16e3e47aef0c80062549af0ebd82304df9a3d03ad922235a604d9ee0bab799c782ac7c13be33df60a665ed9417ce792a126e23cb68532
7
+ data.tar.gz: 62e5d85255b6ee92c7cdfda9de3ee1a798903bea0d6edf29a51cd9749e0959b829e36c3dd118c6d78c132e5e163d8019b2916983e03ac8ccf9529f2efa0d8d8d
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ APIMATIC REFERENCE SOURCE LICENSE
2
+
3
+ This license governs the use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
4
+
5
+ 1. Definitions
6
+ The terms "reproduce," "reproduction" and "distribution" have the same meaning here as under U.S. copyright law.
7
+
8
+ "You" means the licensee of the software.
9
+
10
+ "Your company" means the company you worked for when you downloaded the software.
11
+
12
+ "Reference use" means the use of the software within your company as a reference, in read-only form, for the sole purposes of debugging your products, maintaining your products, or enhancing the interoperability of your products with the software, and specifically excludes the right to distribute the software outside of your company.
13
+
14
+ "Licensed patents" means any Licensor patent claims which read directly on the software as distributed by the Licensor under this license.
15
+
16
+ 2. Grant of Rights
17
+ (A) Copyright Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free copyright license to reproduce the software for reference use.
18
+
19
+ (B) Patent Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free patent license under licensed patents for reference use.
20
+
21
+ 3. Limitations
22
+ (A) No Trademark License- This license does not grant you any rights to use the Licensor's name, logo, or trademarks.
23
+
24
+ (B) If you begin patent litigation against the Licensor over patents that you think may apply to the software (including a cross-claim or counterclaim in a lawsuit), your license to the software ends automatically.
25
+
26
+ (C) The software is licensed "as-is." You bear the risk of using it. The Licensor gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the Licensor excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # apimatic-core-interfaces
2
+
3
+ [//]: # ([![PyPI][rubygems-version]](https://pypi.org/project/apimatic-core-interfaces/))
4
+ [![Linting][lint-badge]][lint-url]
5
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
6
+ [![Maintainability][maintainability-url]][code-climate-url]
7
+ [![Licence][license-badge]][license-url]
8
+
9
+ ## Introduction
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
+
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.
14
+
15
+ ## Installation
16
+ Installation is quite simple, just execute the following command:
17
+ ```
18
+ gem install apimatic_core_interfaces
19
+ ```
20
+
21
+ If you'd rather install apimatic_core_interfaces using bundler, add a line for it in your Gemfile:
22
+ ```
23
+ gem 'apimatic_core_interfaces'
24
+ ```
25
+
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. |
33
+
34
+
35
+ ## Enumerations
36
+ | Name | Description |
37
+ |------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
38
+ | [`DateTimeFormat`](lib/apimatic-core-interfaces/types/datetime_format.rb) | Enumeration containing different datetime formats (RFC1123, RFC3339, UNIX_TIMESTAMP) |
39
+ | [`HttpMethod`](lib/apimatic-core-interfaces/types/http_method.rb) | Enumeration containing HTTP Methods (GET, PUT, POST, PATCH, DELETE, HEAD) |
40
+ | [`ArraySerializationFormat`](lib/apimatic-core-interfaces/types/array_serialization_format.rb) | Enumeration containing different array serialization formats (INDEXED, UNINDEXED, PLAIN, CSV, PSV, TSV) |
41
+
42
+ [rubymine-version]: https://img.shields.io/pypi/v/apimatic-core-interfaces
43
+ [lint-badge]: https://github.com/apimatic/core-interfaces-ruby/actions/workflows/lint-runner.yml/badge.svg
44
+ [lint-url]: https://github.com/apimatic/core-interfaces-ruby/actions/workflows/lint-runner.yml
45
+ [code-climate-url]: https://codeclimate.com/github/apimatic/core-interfaces-ruby
46
+ [maintainability-url]: https://api.codeclimate.com/v1/badges/6557a25e71f7e97e4bb5/maintainability
47
+ [license-badge]: https://img.shields.io/badge/licence-APIMATIC-blue
48
+ [license-url]: LICENSE
49
+
@@ -0,0 +1,9 @@
1
+ module CoreLibrary
2
+ # An interface for the methods that an HTTP Client Configuration must implement.
3
+ # This class should not be instantiated but should be used as a base class
4
+ # for HTTP Client Configuration class.
5
+ class ClientConfiguration
6
+ attr_reader :timeout, :max_retries, :retry_interval, :backoff_factor, :retry_statuses,
7
+ :retry_methods, :connection, :adapter, :response_factory, :cache, :verify
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ module CoreLibrary
2
+ # An interface for the methods that an HTTP Client must implement.
3
+ # This class should not be instantiated but should be used as a base class
4
+ # for HTTP Client class.
5
+ class HttpClient
6
+ # Execute an HttpRequest when the response is expected to be binary.
7
+ # @param [HttpRequest] _http_request The HttpRequest to be executed.
8
+ def execute(_http_request)
9
+ raise NotImplementedError, 'This method needs
10
+ to be implemented in a child class.'
11
+ end
12
+
13
+ # Converts the HTTP Response from the client to an HttpResponse object.
14
+ # @param [Dynamic] _response The response object received from the client.
15
+ # @param [HttpRequest] _http_request The HttpRequest which was executed.
16
+ def convert_response(_response, _http_request)
17
+ raise NotImplementedError, 'This method needs
18
+ to be implemented in a child class.'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module CoreLibrary
2
+ # An interface for the creation of SDK HttpResponse.
3
+ # This class should not be instantiated but should be used as a base class
4
+ # for the HttpResponse creation.
5
+ class ResponseFactory
6
+ # The factory method for creating HttpResponse type.
7
+ # @param [Integer] _status_code The status code returned by the server.
8
+ # @param [String] _reason_phrase The reason phrase returned by the server.
9
+ # @param [Hash] _headers headers The headers sent by the server in the response.
10
+ # @param [String] _raw_body The raw body of the response.
11
+ # @param [HttpRequest] _request The request that resulted in this response.
12
+ def create(_status_code, _reason_phrase, _headers, _raw_body, _request)
13
+ raise NotImplementedError, 'This method needs
14
+ to be implemented in a child class.'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module CoreLibrary
2
+ # All Array Serialization Formats.
3
+ class ArraySerializationFormat
4
+ # Members:
5
+ # UN_INDEXED: Used for serializing array elements in the un-indexed format.
6
+ # INDEXED: Used for serializing array elements in the indexed format.
7
+ # PLAIN: Used for serializing array elements in the plain format.
8
+ # CSV: Used for serializing array elements in the comma separated format.
9
+ # TSV: Used for serializing array elements in the tab separated format.
10
+ # PSV: Used for serializing array elements in the pipe separated format.
11
+
12
+ ARRAY_SERIALIZATION_FORMAT = [UN_INDEXED = 'un-indexed'.freeze,
13
+ INDEXED = 'indexed'.freeze,
14
+ PLAIN = 'plain'.freeze,
15
+ CSV = 'csv'.freeze,
16
+ TSV = 'tsv'.freeze,
17
+ PSV = 'psv'.freeze].freeze
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module CoreLibrary
2
+ # An interface for authenticating the HTTP requests.
3
+ # This class should not be instantiated but should be used as a base class
4
+ # for authenticating the request.
5
+ class Authentication
6
+ # Checks whether this authentication scheme is valid or not.
7
+ # @return [Boolean] True if the auth instance is valid to be applied on the request.
8
+ def valid
9
+ raise NotImplementedError, 'This method needs
10
+ to be implemented in a child class.'
11
+ end
12
+
13
+ # Applies the authentication scheme on the given HTTP request.
14
+ # @param [HttpRequest] _http_request The HTTP request to apply the authentication on.
15
+ def apply(_http_request)
16
+ raise NotImplementedError, 'This method needs
17
+ to be implemented in a child class.'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module CoreLibrary
2
+ # Date Time Formats Enumeration.
3
+ class DateTimeFormat
4
+ # Members:
5
+ # HTTP_DATE_TIME: RFC 1123 Date-Time format
6
+ # UNIX_DATE_TIME: Unix Timestamp Format
7
+ # RFC3339_DATE_TIME: RFC 3339 Date-Time format
8
+
9
+ DATE_TIME_FORMAT = [
10
+ HTTP_DATE_TIME = 'HttpDateTime'.freeze,
11
+
12
+ UNIX_DATE_TIME = 'UnixDateTime'.freeze,
13
+
14
+ RFC3339_DATE_TIME = 'RFC3339DateTime'.freeze
15
+ ].freeze
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ module CoreLibrary
2
+ # HttpCallBack allows defining callables for pre and post API calls.
3
+ # This class should not be instantiated but should be used as a base class
4
+ # for capturing the request and response of an API call.
5
+ class HttpCallback
6
+ # A controller will call this method before making an HTTP Request.
7
+ # @param [HttpRequest] _http_request The HttpRequest object which the HttpClient will execute.
8
+ def on_before_request(_http_request)
9
+ raise NotImplementedError, 'This method needs
10
+ to be implemented in a child class.'
11
+ end
12
+
13
+ # A controller will call this method after making an HTTP Request.
14
+ # @param [HttpResponse] _http_response The HttpResponse of the API call.
15
+ def on_after_response(_http_response)
16
+ raise NotImplementedError, 'This method needs
17
+ to be implemented in a child class.'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module CoreLibrary
2
+ # HTTP Methods Enumeration.
3
+ class HttpMethod
4
+ # Members:
5
+ # GET: Used for the GET request.
6
+ # POST: Used for the POST request.
7
+ # PUT: Used for the PUT request.
8
+ # PATCH: Used for the PATCH request.
9
+ # DELETE: Used for the DELETE request.
10
+ # HEAD: Used for the HEAD request.
11
+
12
+ HTTP_METHOD = [GET = 'GET'.freeze,
13
+ POST = 'POST'.freeze,
14
+ PUT = 'PUT'.freeze,
15
+ PATCH = 'PATCH'.freeze,
16
+ DELETE = 'DELETE'.freeze,
17
+ HEAD = 'HEAD'.freeze].freeze
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'apimatic-core-interfaces/client/http_client'
2
+ require_relative 'apimatic-core-interfaces/client/client_configuration'
3
+
4
+ require_relative 'apimatic-core-interfaces/factories/response_factory'
5
+
6
+ require_relative 'apimatic-core-interfaces/types/authentication'
7
+ require_relative 'apimatic-core-interfaces/types/http_callback'
8
+ require_relative 'apimatic-core-interfaces/types/http_method'
9
+ require_relative 'apimatic-core-interfaces/types/array_serialization_format'
10
+ require_relative 'apimatic-core-interfaces/types/datetime_format'
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apimatic_core_interfaces
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - APIMatic Ltd.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This project contains the abstract layer for APIMatic's core library.
14
+ The purpose of creating interfaces is to separate out the functionalities needed
15
+ by APIMatic's core library module. The goal is to support scalability and feature
16
+ enhancement of the core library and the SDKs along with avoiding any breaking changes
17
+ by reducing tight coupling between modules through the introduction of interfaces.
18
+ email: support@apimatic.io
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - LICENSE
24
+ - README.md
25
+ - lib/apimatic-core-interfaces/client/client_configuration.rb
26
+ - lib/apimatic-core-interfaces/client/http_client.rb
27
+ - lib/apimatic-core-interfaces/factories/response_factory.rb
28
+ - lib/apimatic-core-interfaces/types/array_serialization_format.rb
29
+ - lib/apimatic-core-interfaces/types/authentication.rb
30
+ - lib/apimatic-core-interfaces/types/datetime_format.rb
31
+ - lib/apimatic-core-interfaces/types/http_callback.rb
32
+ - lib/apimatic-core-interfaces/types/http_method.rb
33
+ - lib/apimatic_core_interfaces.rb
34
+ homepage: https://apimatic.io
35
+ licenses:
36
+ - APIMATIC REFERENCE SOURCE LICENSE
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '2.6'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.4.1
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: An abstract layer of the functionalities provided by apimatic-core, faraday-client-adapter
57
+ and APIMatic SDKs.
58
+ test_files: []