Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
eab5ff5
feat(logging): remove extra logging commands
hamzamahmood Apr 8, 2024
1d7eaf4
add scoped logging to apilogger interface
mrafnadeem-apimatic Apr 9, 2024
6ed6fa6
fix(logging): remove unused methods & add reqesut error logging
hamzamahmood Apr 9, 2024
9261022
simplify interface
mrafnadeem-apimatic Apr 9, 2024
0044966
fix(apiLogger): add support for mdc in async methods
hamzamahmood Apr 9, 2024
d5a55bb
remove scopes from interface
mrafnadeem-apimatic Apr 15, 2024
9bf7055
fix(apiLogger): clean up apiLogging interface
hamzamahmood Apr 16, 2024
4d9a946
fix(logging): fix request interface and add logging options
hamzamahmood Apr 16, 2024
c463676
bump package major version
hamzamahmood Apr 17, 2024
2351010
fix javadocs
mrafnadeem-apimatic Apr 17, 2024
5856329
add Loggable interface for logging and add docs
hamzamahmood Apr 17, 2024
06d63b2
rename Logger and overload for getUrl with ArraySerializationFormat a…
hamzamahmood Apr 17, 2024
60e0b09
remove logging level enum and use sl4j logging level
hamzamahmood Apr 17, 2024
ea6ff48
replace sl4j logger with internal logger in ReadonlyLogging
hamzamahmood Apr 17, 2024
013b744
remove array serialization format from endpoint configuration
hamzamahmood Apr 18, 2024
200f749
renamed ReadonlyLogging to ReadonlyLoggingConfiguration
sufyankhanrao Apr 18, 2024
73fafdb
Merge branch 'poc-logging' of https://github.com/apimatic/core-interf…
sufyankhanrao Apr 18, 2024
e22f8ed
fixed linting issues
sufyankhanrao Apr 18, 2024
3285a22
fixed liniting issues - 2nd iteration
sufyankhanrao Apr 18, 2024
a67c987
fixed liniting issues - 3rd iteration
sufyankhanrao Apr 18, 2024
af785b2
renamed the ReadOnlyRequestLogging to ReadonlyRequestLogOptions and R…
sufyankhanrao Apr 18, 2024
3370878
update readme
hamzamahmood Apr 18, 2024
d46a45d
modify logger interface & fix formatting
hamzamahmood Apr 18, 2024
f48a79f
update readme and arguments name in Logger interface
hamzamahmood Apr 18, 2024
70bf2dc
fixed linting issues
sufyankhanrao Apr 18, 2024
ccd8061
add support for whiteList headers in LogOptions
hamzamahmood Apr 19, 2024
abec8ed
fix code lint issues
hamzamahmood Apr 19, 2024
eaf0e7f
rename whiteList headers to unmask headers
hamzamahmood Apr 19, 2024
a763bbc
renamed classes
sufyankhanrao Apr 19, 2024
036c783
add getLogger method in Logger interface &
hamzamahmood Apr 19, 2024
dfd704c
fixed lint issue
sufyankhanrao Apr 19, 2024
2c4a45b
fixed linitng issue
sufyankhanrao Apr 19, 2024
d44fc4c
reverted library version as this will be auto-updated at the release …
sufyankhanrao Apr 19, 2024
7e35a68
rename LoggingOptions to LoggingCOnfiguration
hamzamahmood Apr 22, 2024
1e1fb79
remove logging enums and reformat README.md
hamzamahmood Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 55 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,83 @@
# APIMatic JAVA Core Library Interfaces

[![Maven Central][maven-badge]][maven-url]
[![Tests][test-badge]][test-url]
[![Lint Code][lint-badge]][lint-url]
[![Maintainability][maintainability-url]][code-climate-url]
[![Licence][license-badge]][license-url]

## Introduction
This project contains the abstract layer for APIMatic's core library and Apimatic's JAVA SDK.

This project contains the abstract layer for APIMatic's core library and Apimatic's JAVA SDK.

## Prerequisites

* The JRE flavor requires `JDK 1.8`.

## Install the maven package

Core Interfaces's Maven group ID is `io.apimatic`, and its artifact ID is `core-interfaces`.

## Interfaces
| Name | Description |
|-------------------------------------------------------------------------|--------------------------------------------------------------------|
| [`Context`](./src/main/java/io/apimatic/coreinterfaces/http/Context.java) | To save both Request and Response after the completion of response |
| [`Callback`](./src/main/java/io/apimatic/coreinterfaces/http/Callback.java) | To perform action before Request and after the completion of response |
| [`HttpClient`](./src/main/java/io/apimatic/coreinterfaces/http/HttpClient.java) | To provide abstraction to execute API call in HttpClient |
| [`HttpHeaders`](./src/main/java/io/apimatic/coreinterfaces/http/HttpHeaders.java) | To save additional information about the request and response |
| [`ClientConfiguration`](./src/main/java/io/apimatic/coreinterfaces/http/ClientConfiguration.java) | To hold the default configurations for HttpClient |
| [`Authentication`](./src/main/java/io/apimatic/coreinterfaces/authentication/Authentication.java) | To Provide abstraction for all Authentications |
| [`Request`](./src/main/java/io/apimatic/coreinterfaces/http/request/Request.java) | To create and manage HTTP Requests |
| [`Multipart`](./src/main/java/io/apimatic/coreinterfaces/http/request/Multipart.java) | To wrap byteArray and headers to be sent as part of a multipart request |
| [`MultipartFile`](./src/main/java/io/apimatic/coreinterfaces/http/request/MultipartFile.java) | To wrap file and headers to be sent as part of a multipart request |
| [`CoreEndpointConfiguration`](./src/main/java/io/apimatic/coreinterfaces/http/request/configuration/CoreEndpointConfiguration.java) | To Provide endpoint level configuration |
| [`Response`](./src/main/java/io/apimatic/coreinterfaces/http/response/Response.java) | To get the properties from the instance of Response |
| [`DynamicType`](./src/main/java/io/apimatic/coreinterfaces/http/response/DynamicType.java) | To get the properties from the instance of Dynamic Response Type |
| [`ApiResponseType`](./src/main/java/io/apimatic/coreinterfaces/http/response/ApiResponseType.java) | To get the properties from the instance of ApiResponseType |
| [`CompatibilityFactory`](./src/main/java/io/apimatic/coreinterfaces/compatibility\CompatibilityFactory.java) | Holds required converter methods to create SDK classes |
| [`CoreFileWrapper`](./src/main/java/io/apimatic/coreinterfaces/type/CoreFileWrapper.java) | To wrap file and contentType to be sent as part of a HTTP request. |
| [`HttpApiException`](./src/main/java/io/apimatic/coreinterfaces/type/HttpApiException.java) | Default interface for all the exception models in SDK |
| [`ApiLogger`](./src/main/java/io/apimatic/coreinterfaces/logger/ApiLogger.java) | To log the useful information or errors |
| [`ReadonlyLogging`](./src/main/java/io/apimatic/coreinterfaces/logger/ReadonlyLogging.java) | To hold logging configuration |
| [`Deserializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/Deserializer.java) | Functional interface to apply the deserialization function |
| [`ExceptionCreator`](./src/main/java/io/apimatic/coreinterfaces/type/functional/ExceptionCreator.java) | Functional interface to create the SDK exception |
| [`Serializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/Serializer.java) | Functional interface to apply the serialization function |
| [`ContextInitializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/ContextInitializer.java) | Functional Interface to apply the context initialization function for the response models |

| Name | Description |
|-------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| [`Context`](./src/main/java/io/apimatic/coreinterfaces/http/Context.java) | To save both Request and Response after the completion of response |
| [`Callback`](./src/main/java/io/apimatic/coreinterfaces/http/Callback.java) | To perform action before Request and after the completion of response |
| [`HttpClient`](./src/main/java/io/apimatic/coreinterfaces/http/HttpClient.java) | To provide abstraction to execute API call in HttpClient |
| [`HttpHeaders`](./src/main/java/io/apimatic/coreinterfaces/http/HttpHeaders.java) | To save additional information about the request and response |
| [`ClientConfiguration`](./src/main/java/io/apimatic/coreinterfaces/http/ClientConfiguration.java) | To hold the default configurations for HttpClient |
| [`Authentication`](./src/main/java/io/apimatic/coreinterfaces/authentication/Authentication.java) | To Provide abstraction for all Authentications |
| [`Request`](./src/main/java/io/apimatic/coreinterfaces/http/request/Request.java) | To create and manage HTTP Requests |
| [`Multipart`](./src/main/java/io/apimatic/coreinterfaces/http/request/Multipart.java) | To wrap byteArray and headers to be sent as part of a multipart request |
| [`MultipartFile`](./src/main/java/io/apimatic/coreinterfaces/http/request/MultipartFile.java) | To wrap file and headers to be sent as part of a multipart request |
| [`CoreEndpointConfiguration`](./src/main/java/io/apimatic/coreinterfaces/http/request/configuration/CoreEndpointConfiguration.java) | To Provide endpoint level configuration |
| [`Response`](./src/main/java/io/apimatic/coreinterfaces/http/response/Response.java) | To get the properties from the instance of Response |
| [`DynamicType`](./src/main/java/io/apimatic/coreinterfaces/http/response/DynamicType.java) | To get the properties from the instance of Dynamic Response Type |
| [`ApiResponseType`](./src/main/java/io/apimatic/coreinterfaces/http/response/ApiResponseType.java) | To get the properties from the instance of ApiResponseType |
| [`CompatibilityFactory`](./src/main/java/io/apimatic/coreinterfaces/compatibility/CompatibilityFactory.java) | Holds required converter methods to create SDK classes |
| [`CoreFileWrapper`](./src/main/java/io/apimatic/coreinterfaces/type/CoreFileWrapper.java) | To wrap file and contentType to be sent as part of a HTTP request. |
| [`HttpApiException`](./src/main/java/io/apimatic/coreinterfaces/type/HttpApiException.java) | Default interface for all the exception models in SDK |
| [`ApiLogger`](./src/main/java/io/apimatic/coreinterfaces/logger/ApiLogger.java) | Interface for Loggin Api Calls. |
| [`Logger`](./src/main/java/io/apimatic/coreinterfaces/logger/Logger.java) | Interface for logging at different levels. |
| [`LoggingConfiguration`](./src/main/java/io/apimatic/coreinterfaces/logger/configuration/LoggingConfiguration.java) | To hold logging configuration |
| [`HttpLoggingConfiguration`](./src/main/java/io/apimatic/coreinterfaces/logger/configuration/HttpLoggingConfiguration.java) | To hold configuration for http logging |
| [`RequestLoggingConfiguration`](./src/main/java/io/apimatic/coreinterfaces/logger/configuration/RequestLoggingConfiguration.java) | To hold Request configuration for logging |
| [`ResponseLoggingConfiguration`](./src/main/java/io/apimatic/coreinterfaces/logger/configuration/ResponseLoggingConfiguration.java) | To hold Response configuration for logging |
| [`Deserializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/Deserializer.java) | Functional interface to apply the deserialization function |
| [`ExceptionCreator`](./src/main/java/io/apimatic/coreinterfaces/type/functional/ExceptionCreator.java) | Functional interface to create the SDK exception |
| [`Serializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/Serializer.java) | Functional interface to apply the serialization function |
| [`ContextInitializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/ContextInitializer.java) | Functional Interface to apply the context initialization function for the response models |

## Enumerations
| Name | Description |
|-------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [`Method`](./src/main/java/io/apimatic/coreinterfaces/http/Method.java) | Enumeration for all possible types of requests |
| [`HttpMethodType`](./src/main/java/io/apimatic/coreinterfaces/http/HttpMethodType.java) | HTTP methods enumeration. |
| [`RetryOption`](./src/main/java/io/apimatic/coreinterfaces/http/request/configuration/RetryOption.java) | Enumeration for RetryingOption of each API call |
| [`ArraySerializationFormat`](./src/main/java/io/apimatic/coreinterfaces/http/request/ArraySerializationFormat.java) | Enumeration for all ArraySerialization formats |
| [`MutliPartRequestType`](./src/main/java/io/apimatic/coreinterfaces/http/request/MutliPartRequestType.java) | Enumeration for multipart request |
| [`ResponseClassType`](./src/main/java/io/apimatic/coreinterfaces/http/request/ResponseClassType.java) | Enumeration for Response class type |
| [`HeaderLoggingPolicyLevel`](./src/main/java/io/apimatic/coreinterfaces/http/HeaderLoggingPolicyLevel.java) | Enumeration of Header Logging ploicy |
| [`LoggingLevel`](./src/main/java/io/apimatic/coreinterfaces/http/LoggingLevel.java) | Enumeration of all the possible Logging Level |
| [`LoggingLevelType`](./src/main/java/io/apimatic/coreinterfaces/http/LoggingLevelType.java) | Enumeration of Logging Level |

| Name | Description |
|---------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [`Method`](./src/main/java/io/apimatic/coreinterfaces/http/Method.java) | Enumeration for all possible types of requests |
| [`HttpMethodType`](./src/main/java/io/apimatic/coreinterfaces/http/HttpMethodType.java) | HTTP methods enumeration. |
| [`RetryOption`](./src/main/java/io/apimatic/coreinterfaces/http/request/configuration/RetryOption.java) | Enumeration for RetryingOption of each API call |
| [`ArraySerializationFormat`](./src/main/java/io/apimatic/coreinterfaces/http/request/ArraySerializationFormat.java) | Enumeration for all ArraySerialization formats |
| [`MutliPartRequestType`](./src/main/java/io/apimatic/coreinterfaces/http/request/MutliPartRequestType.java) | Enumeration for multipart request |
| [`ResponseClassType`](./src/main/java/io/apimatic/coreinterfaces/http/request/ResponseClassType.java) | Enumeration for Response class type |
| [`HeaderLoggingPolicyLevel`](./src/main/java/io/apimatic/coreinterfaces/http/HeaderLoggingPolicyLevel.java) | Enumeration of Header Logging ploicy |

[license-badge]: https://img.shields.io/badge/licence-MIT-blue

[license-url]: LICENSE

[maven-badge]: https://img.shields.io/maven-central/v/io.apimatic/core-interfaces?color=green

[maven-url]: https://central.sonatype.dev/artifact/io.apimatic/core-interfaces/0.1.1

[test-badge]: https://github.com/apimatic/core-interfaces-java/actions/workflows/build-and-test.yml/badge.svg

[test-url]: https://github.com/apimatic/core-interfaces-java/actions/workflows/build-and-test.yml

[code-climate-url]: https://codeclimate.com/github/apimatic/core-interfaces-java

[maintainability-url]: https://api.codeclimate.com/v1/badges/71332f9af318d309c3dc/maintainability

[lint-badge]: https://github.com/apimatic/core-interfaces-java/actions/workflows/linter.yml/badge.svg

[lint-url]: https://github.com/apimatic/core-interfaces-java/actions/workflows/linter.yml

5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.10</version>
</dependency>
</dependencies>

<build>
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/io/apimatic/coreinterfaces/http/LoggingLevel.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public interface Request {
*/
String getUrl(ArraySerializationFormat arraySerializationFormat);

/**
* Get the request URL without query parameters
* @return String Url
*/
String getUrl();

/**
* Parameters for the http request.
* @return List of simple entries for form parameters
Expand All @@ -60,5 +66,4 @@ public interface Request {
* @return Object body
*/
Object getBody();

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.apimatic.coreinterfaces.http.request.configuration;

import io.apimatic.coreinterfaces.http.request.ArraySerializationFormat;

/**
* The configuration for an endpoint.
*/
Expand All @@ -18,10 +16,4 @@ public interface CoreEndpointConfiguration {
* @return the boolean which tells endpoint has binary response or not
*/
boolean hasBinaryResponse();

/**
* Enumeration for all ArraySerialization formats
* @return the array serialization format
*/
ArraySerializationFormat getArraySerializationFormat();
}
30 changes: 2 additions & 28 deletions src/main/java/io/apimatic/coreinterfaces/logger/ApiLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,12 @@ public interface ApiLogger {
/**
* Log requests.
* @param request HttpRequest to be logged.
* @param url String request URL.
*/
void logRequest(Request request, String url);

/**
* Log requests.
* @param request HttpRequest to be logged.
* @param url String request URL.
* @param additionalMessage Any additional message to be logged.
*/
void logRequest(Request request, String url, String additionalMessage);

/**
* Set error for failed requests.
* @param request HttpRequest that failed.
* @param error Throwable occurred.
*/
void setError(Request request, Throwable error);
void logRequest(Request request);

/**
* Log Responses.
* @param request HttpRequest that completed.
* @param response HttpResponse to be logged.
*/
void logResponse(Request request, Response response);

/**
* Log Responses.
* @param request HttpRequest that completed.
* @param response HttpResponse to be logged.
* @param additionalMessage Any additional message to be logged.
*/
void logResponse(Request request, Response response, String additionalMessage);

void logResponse(Response response);
}
27 changes: 27 additions & 0 deletions src/main/java/io/apimatic/coreinterfaces/logger/Logger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.apimatic.coreinterfaces.logger;

import java.util.Map;

import org.slf4j.event.Level;

/**
* Interface representing an object capable of logging messages at different
* levels.
*/
public interface Logger {

/**
* Return instance of the provided slf4j logger instance.
* @return wrapped instance of SLF4J Logger.
*/
org.slf4j.Logger getLogger();

/**
* Logs a message with the specified logging level, format, and arguments.
*
* @param level the logging level of the message
* @param format a format string for the message
* @param arguments arguments referenced by the format string
*/
void log(Level level, String format, Map<String, Object> arguments);
}
Loading