Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Java
id: setup-jre
Expand All @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Java
id: setup-jre
Expand All @@ -43,7 +43,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Java
id: setup-jre
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ java {

group = 'dev.merge'

version = '1.1.1'
version = '2.0.0'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand All @@ -71,7 +71,7 @@ publishing {
maven(MavenPublication) {
groupId = 'dev.merge'
artifactId = 'merge-java-client'
version = '1.1.1'
version = '2.0.0'
from components.java
pom {
licenses {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""


# Determine the Java command to use to start the JVM.
Expand Down Expand Up @@ -205,15 +205,15 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

# Stop when "xargs" is not available.
Expand Down
4 changes: 2 additions & 2 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/main/java/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

public final class App {
public static void main(String[] args) {
// import com.merge.api.MergeApiClient
// import com.merge.api.AsyncMergeApiClient
}
}
68 changes: 68 additions & 0 deletions src/main/java/com/merge/api/AsyncMergeApiClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.merge.api;

import com.merge.api.core.ClientOptions;
import com.merge.api.core.Suppliers;
import com.merge.api.resources.accounting.AsyncAccountingClient;
import com.merge.api.resources.ats.AsyncAtsClient;
import com.merge.api.resources.crm.AsyncCrmClient;
import com.merge.api.resources.filestorage.AsyncFilestorageClient;
import com.merge.api.resources.hris.AsyncHrisClient;
import com.merge.api.resources.ticketing.AsyncTicketingClient;
import java.util.function.Supplier;

public class AsyncMergeApiClient {
protected final ClientOptions clientOptions;

protected final Supplier<AsyncAtsClient> atsClient;

protected final Supplier<AsyncCrmClient> crmClient;

protected final Supplier<AsyncHrisClient> hrisClient;

protected final Supplier<AsyncTicketingClient> ticketingClient;

protected final Supplier<AsyncFilestorageClient> filestorageClient;

protected final Supplier<AsyncAccountingClient> accountingClient;

public AsyncMergeApiClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.atsClient = Suppliers.memoize(() -> new AsyncAtsClient(clientOptions));
this.crmClient = Suppliers.memoize(() -> new AsyncCrmClient(clientOptions));
this.hrisClient = Suppliers.memoize(() -> new AsyncHrisClient(clientOptions));
this.ticketingClient = Suppliers.memoize(() -> new AsyncTicketingClient(clientOptions));
this.filestorageClient = Suppliers.memoize(() -> new AsyncFilestorageClient(clientOptions));
this.accountingClient = Suppliers.memoize(() -> new AsyncAccountingClient(clientOptions));
}

public AsyncAtsClient ats() {
return this.atsClient.get();
}

public AsyncCrmClient crm() {
return this.crmClient.get();
}

public AsyncHrisClient hris() {
return this.hrisClient.get();
}

public AsyncTicketingClient ticketing() {
return this.ticketingClient.get();
}

public AsyncFilestorageClient filestorage() {
return this.filestorageClient.get();
}

public AsyncAccountingClient accounting() {
return this.accountingClient.get();
}

public static AsyncMergeApiClientBuilder builder() {
return new AsyncMergeApiClientBuilder();
}
}
80 changes: 80 additions & 0 deletions src/main/java/com/merge/api/AsyncMergeApiClientBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.merge.api;

import com.merge.api.core.ClientOptions;
import com.merge.api.core.Environment;
import okhttp3.OkHttpClient;

public final class AsyncMergeApiClientBuilder {
private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder();

private String apiKey = null;

private String accountToken = null;

private Environment environment = Environment.PRODUCTION;

/**
* Sets apiKey
*/
public AsyncMergeApiClientBuilder apiKey(String apiKey) {
this.apiKey = apiKey;
return this;
}

/**
* Sets accountToken
*/
public AsyncMergeApiClientBuilder accountToken(String accountToken) {
this.accountToken = accountToken;
return this;
}

public AsyncMergeApiClientBuilder environment(Environment environment) {
this.environment = environment;
return this;
}

public AsyncMergeApiClientBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}

/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
public AsyncMergeApiClientBuilder timeout(int timeout) {
this.clientOptionsBuilder.timeout(timeout);
return this;
}

/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
public AsyncMergeApiClientBuilder maxRetries(int maxRetries) {
this.clientOptionsBuilder.maxRetries(maxRetries);
return this;
}

/**
* Sets the underlying OkHttp client
*/
public AsyncMergeApiClientBuilder httpClient(OkHttpClient httpClient) {
this.clientOptionsBuilder.httpClient(httpClient);
return this;
}

public AsyncMergeApiClient build() {
if (apiKey == null) {
throw new RuntimeException("Please provide apiKey");
}
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.apiKey);
if (accountToken != null) {
this.clientOptionsBuilder.addHeader("X-Account-Token", this.accountToken);
}
clientOptionsBuilder.environment(this.environment);
return new AsyncMergeApiClient(clientOptionsBuilder.build());
}
}
16 changes: 8 additions & 8 deletions src/main/java/com/merge/api/MergeApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public class MergeApiClient {

protected final Supplier<CrmClient> crmClient;

protected final Supplier<FilestorageClient> filestorageClient;
protected final Supplier<HrisClient> hrisClient;

protected final Supplier<TicketingClient> ticketingClient;

protected final Supplier<HrisClient> hrisClient;
protected final Supplier<FilestorageClient> filestorageClient;

protected final Supplier<AccountingClient> accountingClient;

public MergeApiClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.atsClient = Suppliers.memoize(() -> new AtsClient(clientOptions));
this.crmClient = Suppliers.memoize(() -> new CrmClient(clientOptions));
this.filestorageClient = Suppliers.memoize(() -> new FilestorageClient(clientOptions));
this.ticketingClient = Suppliers.memoize(() -> new TicketingClient(clientOptions));
this.hrisClient = Suppliers.memoize(() -> new HrisClient(clientOptions));
this.ticketingClient = Suppliers.memoize(() -> new TicketingClient(clientOptions));
this.filestorageClient = Suppliers.memoize(() -> new FilestorageClient(clientOptions));
this.accountingClient = Suppliers.memoize(() -> new AccountingClient(clientOptions));
}

Expand All @@ -46,16 +46,16 @@ public CrmClient crm() {
return this.crmClient.get();
}

public FilestorageClient filestorage() {
return this.filestorageClient.get();
public HrisClient hris() {
return this.hrisClient.get();
}

public TicketingClient ticketing() {
return this.ticketingClient.get();
}

public HrisClient hris() {
return this.hrisClient.get();
public FilestorageClient filestorage() {
return this.filestorageClient.get();
}

public AccountingClient accounting() {
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/com/merge/api/MergeApiClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.merge.api.core.ClientOptions;
import com.merge.api.core.Environment;
import okhttp3.OkHttpClient;

public final class MergeApiClientBuilder {
private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder();
Expand Down Expand Up @@ -42,13 +43,29 @@ public MergeApiClientBuilder url(String url) {
}

/**
* Sets the timeout (in seconds) for the client
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
public MergeApiClientBuilder timeout(int timeout) {
this.clientOptionsBuilder.timeout(timeout);
return this;
}

/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
public MergeApiClientBuilder maxRetries(int maxRetries) {
this.clientOptionsBuilder.maxRetries(maxRetries);
return this;
}

/**
* Sets the underlying OkHttp client
*/
public MergeApiClientBuilder httpClient(OkHttpClient httpClient) {
this.clientOptionsBuilder.httpClient(httpClient);
return this;
}

public MergeApiClient build() {
if (apiKey == null) {
throw new RuntimeException("Please provide apiKey");
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/merge/api/core/ApiError.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
*/
package com.merge.api.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Response;

/**
* This exception type will be thrown for any non-2XX API responses.
*/
Expand All @@ -17,10 +23,25 @@ public class ApiError extends MergeException {
*/
private final Object body;

private final Map<String, List<String>> headers;

public ApiError(String message, int statusCode, Object body) {
super(message);
this.statusCode = statusCode;
this.body = body;
this.headers = new HashMap<>();
}

public ApiError(String message, int statusCode, Object body, Response rawResponse) {
super(message);
this.statusCode = statusCode;
this.body = body;
this.headers = new HashMap<>();
rawResponse.headers().forEach(header -> {
String key = header.component1();
String value = header.component2();
this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value);
});
}

/**
Expand All @@ -37,6 +58,13 @@ public Object body() {
return this.body;
}

/**
* @return the headers
*/
public Map<String, List<String>> headers() {
return this.headers;
}

@java.lang.Override
public String toString() {
return "ApiError{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body + "}";
Expand Down
Loading
Loading