hamadhassan3 / outseta-client

A Java SDK for easily accessing the Outseta API. It can be installed using Maven or Gradle on Java and Kotlin frameworks like Spring Boot and Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

outseta-client

A Java SDK for easily accessing the Outseta API.

GitHub CI GitHub release (latest by date) Maven Central codecov License GitHub issues GitHub pull requests GitHub last commit

Code Coverage Graphs

The Code is thoroughly tested to ensure reliable execution of the API endpoints. The architecture, endpoints and models are thoroughly unit tested. Furthermore, integration tests are added for the endpoints to ensure that the API endpoints are working as expected.

codecov gridcodecov sunburst

About

This library is a Java SDK for easily accessing the Outseta API. It uses Jackson to parse the requests and responses and Apache's HttpClient to make the requests. The models in this library provide a convenient mapping to the Json of the APIs. The library is built using Java 8 and is compatible with Android.

You can also refer to the unit tests in order to see how to use the library.

Requirements

  • Java 8 or higher

Installation

Install the library using Maven or Gradle. The library is available on Maven Central.

Maven

<dependency>
    <groupId>io.github.hamadhassan3</groupId>
    <artifactId>outseta-client</artifactId>
    <version>3.0.0</version>
</dependency>

Gradle

implementation group: 'io.github.hamadhassan3', name: 'outseta-client', version: '3.0.0'

The library provides following API Clients

CRM

Billing

Authentication

The library provides two ways to authenticate with the Outseta API. The first way is to use the AuthenticationClient to get an auth token and then use that token to make requests to the other APIs. This provides access to user specific APIs like profile endpoints. The second way is to use the API key directly in the other API clients. This provides access to most APIs. Please note that either the API key or the Access Key needs to be specified when creating a Client object. Otherwise, client creation fails. PeopleClient can only be created using an Access Key and AuthenticationClient can be built without any keys.

Usage:

Creating a Client (e.g. AuthenticationClient)

AuthenticationClient client = AuthenticationClient.builder(outsetaUrl)
    .apiKey(outsetaKey)
    .defaultParser()
    .defaultRequestMaker()
    .build();

Using Builder to Create a Request Model

GetAuthTokenRequest request = GetAuthTokenRequest.builder()
    .username(username)
    .password(password)
    .build();

Calling the required method to execute corresponding API

AuthToken token = client.getAuthToken(request);

Pagination (Using People Client)

PeopleClient client = PeopleClient.builder(outsetaUrl)
    .apiKey(outsetaKey)
    .defaultParser()
    .defaultRequestMaker()
    .build();
PageRequest request = PageRequest.builder()
    .page(page)
    .pageSize(pageSize)
    .build();
int total = 0;
ItemPage<Person> personPage = null;
do {
    // Keep making requests as long as there are more pages
    personPage = peopleClient.getPersonPage(request);
    total = personPage.getMetadata().getTotal();

    // The current page's items are aggregated
    allPeople.addAll(personPage.getItems());
    request = request.nextPageRequest();
}
while (allPeople.size() < total);

Pagination Custom Arguments

In addition to the regular pagination request, you can pass custom arguments for filtering, sort, etc. For example, to filter the people by email, you can pass the following custom arguments:

Map<String, Object> customParams = new HashMap<>();
customParams.put("Email", "asd@dummy.com");

PageRequest request = PageRequest.builder()
    .page(page)
    .pageSize(pageSize)
    .customParams(customParams)
    .build();

Customized Pagination Request

In addition to the regular Pagination request, the following customized requests are available for common use cases:

Please refer to the javadoc for each client to see the available methods.

Dependencies

Javadoc

The code is thoroughly documented. You can access the javadoc to understand the code and its usage. You can view the javadoc inside the docs folder in root directory.

The Builder Pattern

The builder pattern is used to create the request and response models. This makes it easy to create the models and also makes the code more readable. This allows the user to create the models in a single line of code without worrying over case sensitivity, spellings, etc. The builder pattern is also used to create the API clients.

Linting

The code uses Checkstyle to ensure proper formatting of the code. Furthermore, the Sun coding conventions are used in the checkstyle script. This is the recommended coding convention for Java.

License

This project is licensed under the MIT License - see the LICENSE for details

Reference

The Outseta API: https://documenter.getpostman.com/view/3613332/outseta-rest-api-v1/7TNfr6k

About

A Java SDK for easily accessing the Outseta API. It can be installed using Maven or Gradle on Java and Kotlin frameworks like Spring Boot and Android.

License:MIT License


Languages

Language:Java 100.0%