Skip to content

apideck-libraries/sdk-java

Repository files navigation

openapi

Developer-friendly & type-safe Java SDK specifically catered to leverage openapi API.

Summary

Apideck: The Apideck OpenAPI Spec: SDK Optimized

For more information about the API: Apideck Developer Docs

Table of Contents

SDK Installation

Getting started

JDK 11 or later is required.

The samples below show how a published SDK artifact is used:

Gradle:

implementation 'com.apideck:unify:0.2.1'

Maven:

<dependency>
    <groupId>com.apideck</groupId>
    <artifactId>unify</artifactId>
    <version>0.2.1</version>
</dependency>

How to build

After cloning the git repository to your file system you can build the SDK artifact from source to the build directory by running ./gradlew build on *nix systems or gradlew.bat on Windows systems.

If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):

On *nix:

./gradlew publishToMavenLocal -Pskip.signing

On Windows:

gradlew.bat publishToMavenLocal -Pskip.signing

SDK Example Usage

Example

package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.TaxRatesFilter;
import com.apideck.unify.models.errors.BadRequestResponse;
import com.apideck.unify.models.errors.NotFoundResponse;
import com.apideck.unify.models.errors.PaymentRequiredResponse;
import com.apideck.unify.models.errors.UnauthorizedResponse;
import com.apideck.unify.models.errors.UnprocessableResponse;
import com.apideck.unify.models.operations.AccountingTaxRatesAllRequest;
import com.apideck.unify.models.operations.AccountingTaxRatesAllResponse;
import java.lang.Exception;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .apiKey("<YOUR_BEARER_TOKEN_HERE>")
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
            .build();

        AccountingTaxRatesAllRequest req = AccountingTaxRatesAllRequest.builder()
                .serviceId("salesforce")
                .filter(TaxRatesFilter.builder()
                    .assets(true)
                    .equity(true)
                    .expenses(true)
                    .liabilities(true)
                    .revenue(true)
                    .build())
                .passThrough(Map.ofEntries(
                    Map.entry("search", "San Francisco")))
                .fields("id,updated_at")
                .build();

        AccountingTaxRatesAllResponse res = sdk.accounting().taxRates().list()
                .request(req)
                .call();

        if (res.getTaxRatesResponse().isPresent()) {
            // handle response
        }
    }
}

Available Resources and Operations

Available methods
  • get - Get BalanceSheet
  • list - List Bill Payments
  • create - Create Bill Payment
  • get - Get Bill Payment
  • update - Update Bill Payment
  • delete - Delete Bill Payment
  • get - Get company info
  • list - List Credit Notes
  • create - Create Credit Note
  • get - Get Credit Note
  • update - Update Credit Note
  • delete - Delete Credit Note
  • list - List Departments
  • create - Create Department
  • get - Get Department
  • update - Update Department
  • delete - Delete Department
  • list - List Invoice Items
  • create - Create Invoice Item
  • get - Get Invoice Item
  • update - Update Invoice Item
  • delete - Delete Invoice Item
  • list - List Journal Entries
  • create - Create Journal Entry
  • get - Get Journal Entry
  • update - Update Journal Entry
  • delete - Delete Journal Entry
  • list - List Ledger Accounts
  • create - Create Ledger Account
  • get - Get Ledger Account
  • update - Update Ledger Account
  • delete - Delete Ledger Account
  • get - Get Profit and Loss
  • list - List Purchase Orders
  • create - Create Purchase Order
  • get - Get Purchase Order
  • update - Update Purchase Order
  • delete - Delete Purchase Order
  • list - List Subsidiaries
  • create - Create Subsidiary
  • get - Get Subsidiary
  • update - Update Subsidiary
  • delete - Delete Subsidiary
  • list - List Tracking Categories
  • create - Create Tracking Category
  • get - Get Tracking Category
  • update - Update Tracking Category
  • delete - Delete Tracking Category
  • list - List Applications
  • create - Create Application
  • get - Get Application
  • update - Update Application
  • delete - Delete Application
  • get - Get API Resource Coverage
  • get - Get API Resource
  • get - Get Connector Doc content
  • get - Get Connector Resource
  • list - List Connectors
  • get - Get Connector
  • list - List opportunities
  • create - Create opportunity
  • get - Get opportunity
  • update - Update opportunity
  • delete - Delete opportunity
  • list - List Customers
  • get - Get Customer
  • list - List Orders
  • get - Get Order
  • list - List Products
  • get - Get Product
  • get - Get Store
  • list - List DriveGroups
  • create - Create DriveGroup
  • get - Get DriveGroup
  • update - Update DriveGroup
  • delete - Delete DriveGroup
  • list - List SharedLinks
  • create - Create Shared Link
  • get - Get Shared Link
  • update - Update Shared Link
  • delete - Delete Shared Link
  • create - Start Upload Session
  • get - Get Upload Session
  • delete - Abort Upload Session
  • finish - Finish Upload Session
  • list - List Departments
  • create - Create Department
  • get - Get Department
  • update - Update Department
  • delete - Delete Department
  • list - List Employee Payrolls
  • get - Get Employee Payroll
  • list - List Employee Schedules
  • list - List Payroll
  • get - Get Payroll
  • list - List Time Off Requests
  • create - Create Time Off Request
  • get - Get Time Off Request
  • update - Update Time Off Request
  • delete - Delete Time Off Request
  • list - List Collections
  • get - Get Collection
  • list - List connection custom mappings
  • list - Get all connections
  • get - Get connection
  • update - Update connection
  • delete - Deletes a connection
  • imports - Import connection
  • token - Authorize Access Token
  • list - Get resource settings
  • update - Update settings
  • list - Consumer request counts
  • state - Create Callback State
  • list - Get resource custom fields
  • list - List custom mappings
  • list - Get all consumer request logs
  • state - Validate Connection State
  • list - List webhook subscriptions
  • create - Create webhook subscription
  • get - Get webhook subscription
  • update - Update webhook subscription
  • delete - Delete webhook subscription

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, you can provide a RetryConfig object through the retryConfig builder method:

package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.TaxRatesFilter;
import com.apideck.unify.models.errors.BadRequestResponse;
import com.apideck.unify.models.errors.NotFoundResponse;
import com.apideck.unify.models.errors.PaymentRequiredResponse;
import com.apideck.unify.models.errors.UnauthorizedResponse;
import com.apideck.unify.models.errors.UnprocessableResponse;
import com.apideck.unify.models.operations.AccountingTaxRatesAllRequest;
import com.apideck.unify.models.operations.AccountingTaxRatesAllResponse;
import com.apideck.unify.utils.BackoffStrategy;
import com.apideck.unify.utils.RetryConfig;
import java.lang.Exception;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .apiKey("<YOUR_BEARER_TOKEN_HERE>")
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
            .build();

        AccountingTaxRatesAllRequest req = AccountingTaxRatesAllRequest.builder()
                .serviceId("salesforce")
                .filter(TaxRatesFilter.builder()
                    .assets(true)
                    .equity(true)
                    .expenses(true)
                    .liabilities(true)
                    .revenue(true)
                    .build())
                .passThrough(Map.ofEntries(
                    Map.entry("search", "San Francisco")))
                .fields("id,updated_at")
                .build();

        AccountingTaxRatesAllResponse res = sdk.accounting().taxRates().list()
                .request(req)
                .retryConfig(RetryConfig.builder()
                    .backoff(BackoffStrategy.builder()
                        .initialInterval(1L, TimeUnit.MILLISECONDS)
                        .maxInterval(50L, TimeUnit.MILLISECONDS)
                        .maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
                        .baseFactor(1.1)
                        .jitterFactor(0.15)
                        .retryConnectError(false)
                        .build())
                    .build())
                .call();

        if (res.getTaxRatesResponse().isPresent()) {
            // handle response
        }
    }
}

If you'd like to override the default retry strategy for all operations that support retries, you can provide a configuration at SDK initialization:

package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.TaxRatesFilter;
import com.apideck.unify.models.errors.BadRequestResponse;
import com.apideck.unify.models.errors.NotFoundResponse;
import com.apideck.unify.models.errors.PaymentRequiredResponse;
import com.apideck.unify.models.errors.UnauthorizedResponse;
import com.apideck.unify.models.errors.UnprocessableResponse;
import com.apideck.unify.models.operations.AccountingTaxRatesAllRequest;
import com.apideck.unify.models.operations.AccountingTaxRatesAllResponse;
import com.apideck.unify.utils.BackoffStrategy;
import com.apideck.unify.utils.RetryConfig;
import java.lang.Exception;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .retryConfig(RetryConfig.builder()
                    .backoff(BackoffStrategy.builder()
                        .initialInterval(1L, TimeUnit.MILLISECONDS)
                        .maxInterval(50L, TimeUnit.MILLISECONDS)
                        .maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
                        .baseFactor(1.1)
                        .jitterFactor(0.15)
                        .retryConnectError(false)
                        .build())
                    .build())
                .apiKey("<YOUR_BEARER_TOKEN_HERE>")
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
            .build();

        AccountingTaxRatesAllRequest req = AccountingTaxRatesAllRequest.builder()
                .serviceId("salesforce")
                .filter(TaxRatesFilter.builder()
                    .assets(true)
                    .equity(true)
                    .expenses(true)
                    .liabilities(true)
                    .revenue(true)
                    .build())
                .passThrough(Map.ofEntries(
                    Map.entry("search", "San Francisco")))
                .fields("id,updated_at")
                .build();

        AccountingTaxRatesAllResponse res = sdk.accounting().taxRates().list()
                .request(req)
                .call();

        if (res.getTaxRatesResponse().isPresent()) {
            // handle response
        }
    }
}

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.

By default, an API error will throw a models/errors/APIException exception. When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the list method throws the following exceptions:

Error Type Status Code Content Type
models/errors/BadRequestResponse 400 application/json
models/errors/UnauthorizedResponse 401 application/json
models/errors/PaymentRequiredResponse 402 application/json
models/errors/NotFoundResponse 404 application/json
models/errors/UnprocessableResponse 422 application/json
models/errors/APIException 4XX, 5XX */*

Example

package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.TaxRatesFilter;
import com.apideck.unify.models.errors.BadRequestResponse;
import com.apideck.unify.models.errors.NotFoundResponse;
import com.apideck.unify.models.errors.PaymentRequiredResponse;
import com.apideck.unify.models.errors.UnauthorizedResponse;
import com.apideck.unify.models.errors.UnprocessableResponse;
import com.apideck.unify.models.operations.AccountingTaxRatesAllRequest;
import com.apideck.unify.models.operations.AccountingTaxRatesAllResponse;
import java.lang.Exception;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .apiKey("<YOUR_BEARER_TOKEN_HERE>")
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
            .build();

        AccountingTaxRatesAllRequest req = AccountingTaxRatesAllRequest.builder()
                .serviceId("salesforce")
                .filter(TaxRatesFilter.builder()
                    .assets(true)
                    .equity(true)
                    .expenses(true)
                    .liabilities(true)
                    .revenue(true)
                    .build())
                .passThrough(Map.ofEntries(
                    Map.entry("search", "San Francisco")))
                .fields("id,updated_at")
                .build();

        AccountingTaxRatesAllResponse res = sdk.accounting().taxRates().list()
                .request(req)
                .call();

        if (res.getTaxRatesResponse().isPresent()) {
            // handle response
        }
    }
}

Server Selection

Override Server URL Per-Client

The default server can also be overridden globally using the .serverURL(String serverUrl) builder method when initializing the SDK client instance. For example:

package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.TaxRatesFilter;
import com.apideck.unify.models.errors.BadRequestResponse;
import com.apideck.unify.models.errors.NotFoundResponse;
import com.apideck.unify.models.errors.PaymentRequiredResponse;
import com.apideck.unify.models.errors.UnauthorizedResponse;
import com.apideck.unify.models.errors.UnprocessableResponse;
import com.apideck.unify.models.operations.AccountingTaxRatesAllRequest;
import com.apideck.unify.models.operations.AccountingTaxRatesAllResponse;
import java.lang.Exception;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .serverURL("https://unify.apideck.com")
                .apiKey("<YOUR_BEARER_TOKEN_HERE>")
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
            .build();

        AccountingTaxRatesAllRequest req = AccountingTaxRatesAllRequest.builder()
                .serviceId("salesforce")
                .filter(TaxRatesFilter.builder()
                    .assets(true)
                    .equity(true)
                    .expenses(true)
                    .liabilities(true)
                    .revenue(true)
                    .build())
                .passThrough(Map.ofEntries(
                    Map.entry("search", "San Francisco")))
                .fields("id,updated_at")
                .build();

        AccountingTaxRatesAllResponse res = sdk.accounting().taxRates().list()
                .request(req)
                .call();

        if (res.getTaxRatesResponse().isPresent()) {
            // handle response
        }
    }
}

Override Server URL Per-Operation

The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:

package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.CreateUploadSessionRequest;
import com.apideck.unify.models.components.ExtendPaths;
import com.apideck.unify.models.components.PassThroughBody;
import com.apideck.unify.models.errors.BadRequestResponse;
import com.apideck.unify.models.errors.NotFoundResponse;
import com.apideck.unify.models.errors.PaymentRequiredResponse;
import com.apideck.unify.models.errors.UnauthorizedResponse;
import com.apideck.unify.models.errors.UnprocessableResponse;
import com.apideck.unify.models.operations.FileStorageUploadSessionsAddRequest;
import com.apideck.unify.models.operations.FileStorageUploadSessionsAddResponse;
import java.lang.Exception;
import java.util.List;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .apiKey("<YOUR_BEARER_TOKEN_HERE>")
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
            .build();

        FileStorageUploadSessionsAddRequest req = FileStorageUploadSessionsAddRequest.builder()
                .createUploadSessionRequest(CreateUploadSessionRequest.builder()
                    .name("Documents")
                    .parentFolderId("1234")
                    .size(1810673L)
                    .driveId("1234")
                    .passThrough(List.of(
                        PassThroughBody.builder()
                            .serviceId("<id>")
                            .extendPaths(List.of(
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(\n    Map.entry("TaxClassificationRef", Map.ofEntries(\n    Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build(),
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(\n    Map.entry("TaxClassificationRef", Map.ofEntries(\n    Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build()))
                            .build()))
                    .build())
                .serviceId("salesforce")
                .build();

        FileStorageUploadSessionsAddResponse res = sdk.fileStorage().uploadSessions().create()
                .request(req)
                .serverURL("https://upload.apideck.com")
                .call();

        if (res.createUploadSessionResponse().isPresent()) {
            // handle response
        }
    }
}

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
apiKey http HTTP Bearer

To authenticate with the API the apiKey parameter must be set when initializing the SDK client instance. For example:

package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.TaxRatesFilter;
import com.apideck.unify.models.errors.BadRequestResponse;
import com.apideck.unify.models.errors.NotFoundResponse;
import com.apideck.unify.models.errors.PaymentRequiredResponse;
import com.apideck.unify.models.errors.UnauthorizedResponse;
import com.apideck.unify.models.errors.UnprocessableResponse;
import com.apideck.unify.models.operations.AccountingTaxRatesAllRequest;
import com.apideck.unify.models.operations.AccountingTaxRatesAllResponse;
import java.lang.Exception;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .apiKey("<YOUR_BEARER_TOKEN_HERE>")
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
            .build();

        AccountingTaxRatesAllRequest req = AccountingTaxRatesAllRequest.builder()
                .serviceId("salesforce")
                .filter(TaxRatesFilter.builder()
                    .assets(true)
                    .equity(true)
                    .expenses(true)
                    .liabilities(true)
                    .revenue(true)
                    .build())
                .passThrough(Map.ofEntries(
                    Map.entry("search", "San Francisco")))
                .fields("id,updated_at")
                .build();

        AccountingTaxRatesAllResponse res = sdk.accounting().taxRates().list()
                .request(req)
                .call();

        if (res.getTaxRatesResponse().isPresent()) {
            // handle response
        }
    }
}

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy