Creating Service Clients

To make requests to the Impossible FX Service, you first create a service client object. The preferred way to do this is to use the service client builder. Each FX service has a service interface that has methods for each action in the service API. For example, the service interface for the Asset Management API is named FXAssetManagementClient. Each service interface has a corresponding client builder you can use to construct an implementation of the service interface. The client builder class for FXAssetManagementClient is named FXAssetManagementClientBuilder.

To obtain an instance of the client builder, use the static factory method builder(), as shown in the following example.
FXAssetManagementClient client = FXAssetManagementClient.builder()
                        .withRegion("us-west-2")
                        .withCredentials(new EnvironmentCredentialsProvider())
                        .build();

The fluent withXXX methods return the builder object so that you can chain the method calls for convenience and more readable code. After you configure all the properties you want, you can call the build method to create the client. Once a client is created, it is immutable and any calls to setRegion or setEndpoint will fail.

A builder can create multiple clients with the same configuration. When you're writing your application, be aware that the builder is mutable and not thread-safe.

Terms of Use | © 2017, Impossible Software, or its affiliates. All rights reserved.